From 0942eb099e3e8bcf6c2444d56edd12eb35093ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 19:02:00 +0100 Subject: [PATCH 01/12] #3835 initial implementation for processes --- .../flowable-process-assertions/pom.xml | 40 +++ .../process/FlowableProcessAssertions.java | 19 ++ .../HistoricProcessInstanceAssert.java | 150 +++++++++ .../process/ProcessInstanceAssert.java | 182 +++++++++++ .../process/ProcessServicesProvider.java | 25 ++ .../flowable/assertions/process/Utils.java | 32 ++ .../HistoricProcessInstanceAssertTest.java | 111 +++++++ .../LongRunningProcessInstanceAssertTest.java | 49 +++ .../process/ProcessInstanceAssertTest.java | 289 ++++++++++++++++++ .../assertions/process/TestUtils.java | 13 + .../src/test/resources/flowable.cfg.xml | 89 ++++++ .../src/test/resources/log4j.properties | 9 + .../src/test/resources/oneTask.bpmn20.xml | 14 + .../oneTaskWithBoundaryEvent.bpmn20.xml | 18 ++ .../src/test/resources/twoTasks.bpmn20.xml | 16 + modules/flowable-assertions/pom.xml | 25 ++ .../ReceiveTaskTest.waitTimer.bpmn20.xml | 17 ++ .../resources/processes/oneTask.bpmn20.xml | 14 + .../boot/OneTaskProcessGroovyTest.groovy | 27 ++ .../spring/boot/OneTaskProcessSpec.groovy | 42 +++ .../test/spring/boot/OneTaskProcessTest.java | 29 ++ pom.xml | 4 +- 22 files changed, 1213 insertions(+), 1 deletion(-) create mode 100644 modules/flowable-assertions/flowable-process-assertions/pom.xml create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml create mode 100644 modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml create mode 100644 modules/flowable-assertions/pom.xml create mode 100644 modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml create mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml create mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy create mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy create mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java diff --git a/modules/flowable-assertions/flowable-process-assertions/pom.xml b/modules/flowable-assertions/flowable-process-assertions/pom.xml new file mode 100644 index 00000000000..e840a9e0479 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + org.flowable + flowable-assertions + 7.1.0-SNAPSHOT + + + flowable-process-assertions + + + + org.assertj + assertj-core + compile + + + org.flowable + flowable-engine + + + com.zaxxer + HikariCP + test + + + com.h2database + h2 + test + + + org.junit.jupiter + junit-jupiter + test + + + \ No newline at end of file diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java new file mode 100644 index 00000000000..48bb56b00ac --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java @@ -0,0 +1,19 @@ +package org.flowable.assertions.process; + +import org.assertj.core.api.Assertions; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; + +/** + * @author martin.grofcik + */ +public class FlowableProcessAssertions extends Assertions { + + public static ProcessInstanceAssert assertThat(ProcessInstance processInstance) { + return new ProcessInstanceAssert(processInstance); + } + public static HistoricProcessInstanceAssert assertThat(HistoricProcessInstance historicProcessInstance) { + return new HistoricProcessInstanceAssert(historicProcessInstance); + } + +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java new file mode 100644 index 00000000000..3aed654fc5e --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java @@ -0,0 +1,150 @@ +package org.flowable.assertions.process; + +import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.Assertions; +import org.assertj.core.api.ListAssert; +import org.flowable.engine.ProcessEngine; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.identitylink.api.IdentityLink; +import org.flowable.identitylink.api.history.HistoricIdentityLink; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.flowable.variable.api.history.HistoricVariableInstance; + +import static org.flowable.assertions.process.FlowableProcessAssertions.assertThat; +import static org.flowable.assertions.process.Utils.*; + +/** + * @author martin.grofcik + */ + +public class HistoricProcessInstanceAssert extends AbstractAssert { + + protected final ProcessServicesProvider processServicesProvider; + + protected HistoricProcessInstanceAssert(ProcessEngine processEngine, HistoricProcessInstance historicProcessInstance) { + super(historicProcessInstance, HistoricProcessInstanceAssert.class); + processServicesProvider = ProcessServicesProvider.of(processEngine); + } + + protected HistoricProcessInstanceAssert(HistoricProcessInstance historicProcessInstance) { + this(getProcessEngine(), historicProcessInstance); + } + + /** + * Assert historic activities ordered by activity instance start time. + * + * @return Assertion of {@link HistoricActivityInstance} list. + */ + public ListAssert activities() { + processExistsInHistory(); + + return assertThat(processServicesProvider.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(actual.getId()) + .orderByHistoricActivityInstanceStartTime().desc().list()); + } + + /** + * Assert historic process instance exists in the history and is finished. + * + * @return Historic process instance assertion. + */ + public HistoricProcessInstanceAssert isFinished() { + processExistsInHistory(); + + if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().finished().processInstanceId(actual.getId()).count() != 1) { + failWithMessage(getProcessDescription(actual)+" to be finished, but is running in history."); + } + + return this; + } + + public ListAssert variables() { + processExistsInHistory(); + + return assertThat(processServicesProvider.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(actual.getId()).orderByVariableName().asc().list()); + } + + /** + * Assert that process instance has variable in history. + * + * @param variableName variable to check. + * @return Historic process instance assertion + */ + + public HistoricProcessInstanceAssert hasVariable(String variableName) { + processExistsInHistory(); + + if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 1) { + failWithMessage(getProcessDescription(actual)+" has variable <%s> but variable does not exist in history.", variableName); + } + + return this; + } + + /** + * Assert that process instance does not have variable in history. + * @param variableName variable to check + * @return Historic process instance assertion + */ + public HistoricProcessInstanceAssert doesNotHaveVariable(String variableName) { + processExistsInHistory(); + + if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 0) { + failWithMessage(getProcessDescription(actual)+" does not have variable <%s> but variable exists in history.", variableName); + } + + return this; + } + + /** + * Assert that process instance has variable in history with value equals to expectedValue. + * + * @param variableName variable to check. + * @param expectedValue expected variable value. + * @return Historic process instance assertion + */ + public HistoricProcessInstanceAssert hasVariableWithValue(String variableName, Object expectedValue) { + processExistsInHistory(); + hasVariable(variableName); + + HistoricVariableInstance actualVariable = processServicesProvider.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(actual.getId()).variableName(variableName).singleResult(); + Assertions.assertThat(actualVariable.getValue()).isEqualTo(expectedValue); + return this; + } + + /** + * Assert list of historic identity links without ordering. + * + * @return Assertion of #{@link IdentityLink} list. + */ + public ListAssert identityLinks() { + processExistsInHistory(); + + return assertThat(processServicesProvider.getHistoryService().getHistoricIdentityLinksForProcessInstance(actual.getId())); + } + + /** + * Assert list of user tasks in the history ordered by the task name ascending. + * Process, Task variables and identityLinks are included. + * + * @return Assertion of {@link HistoricTaskInstance} list. + */ + public ListAssert userTasks() { + processExistsInHistory(); + + return assertThat(processServicesProvider.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(actual.getId()).orderByTaskName().asc() + .includeProcessVariables().includeIdentityLinks().includeTaskLocalVariables().list()); + } + + private void processExistsInHistory() { + isNotNull(); + isInHistory(); + } + + private void isInHistory() { + if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).count() != 1) { + failWithMessage(getProcessDescription(actual)+"> exists in history but process instance not found."); + } + } + +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java new file mode 100644 index 00000000000..2d2497667fb --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java @@ -0,0 +1,182 @@ +package org.flowable.assertions.process; + +import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.Assertions; +import org.assertj.core.api.ListAssert; +import org.flowable.engine.ProcessEngine; +import org.flowable.engine.runtime.ActivityInstance; +import org.flowable.engine.runtime.Execution; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.eventsubscription.api.EventSubscription; +import org.flowable.identitylink.api.IdentityLink; +import org.flowable.task.api.Task; +import org.flowable.variable.api.persistence.entity.VariableInstance; + +import static org.flowable.assertions.process.FlowableProcessAssertions.assertThat; +import static org.flowable.assertions.process.Utils.*; +/** + * @author martin.grofcik + */ +public class ProcessInstanceAssert extends AbstractAssert { + protected final ProcessServicesProvider processServicesProvider; + + protected ProcessInstanceAssert(ProcessEngine processEngine, ProcessInstance processInstance) { + super(processInstance, ProcessInstanceAssert.class); + processServicesProvider = ProcessServicesProvider.of(processEngine); + } + + protected ProcessInstanceAssert(ProcessInstance processInstance) { + this(getProcessEngine(), processInstance); + } + + /** + * Assert that process instance exists in runtime. + * + * @return Process instance assert. + */ + public ProcessInstanceAssert isRunning() { + isNotNull(); + + if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).count() < 1) { + failWithMessage(getProcessDescription(actual)+" to be running but is not.", actual.getId()); + } + return this; + } + + /** + * Assert that process instance has variable in runtime. + * + * @param variableName variable to check. + * @return Process instance assertion + */ + public ProcessInstanceAssert hasVariable(String variableName) { + isNotNull(); + + if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 1) { + failWithMessage(getProcessDescription(actual)+" has variable <%s> but variable does not exist.", variableName); + } + + return this; + } + + /** + * Assert that process instance has variable in runtime with value equals to expectedValue. + * + * @param variableName variable to check. + * @param expectedValue expected variable value. + * @return Process instance assertion + */ + public ProcessInstanceAssert hasVariableWithValue(String variableName, Object expectedValue) { + isNotNull(); + hasVariable(variableName); + + VariableInstance actualVariable = processServicesProvider.getRuntimeService().createVariableInstanceQuery().processInstanceId(actual.getId()).variableName(variableName).singleResult(); + Assertions.assertThat(actualVariable.getValue()).isEqualTo(expectedValue); + return this; + } + + /** + * Assert that process instance does not have variable in runtime. + * @param variableName variable to check + * @return Process instance assertion + */ + public ProcessInstanceAssert doesNotHaveVariable(String variableName) { + isNotNull(); + + if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 0) { + failWithMessage(getProcessDescription(actual)+" does not have variable <%s> but variable exists.", variableName); + } + + return this; + } + + /** + * Assert that process instance does on exist in runtime. + * + * @return Process instance assertion + */ + public ProcessInstanceAssert doesNotExist() { + isNotNull(); + + if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).count() != 0) { + failWithMessage(getProcessDescription(actual)+" is finished but instance exists in runtime."); + } + + return this; + } + + /** + * @return Historic process instance assertion + */ + public HistoricProcessInstanceAssert inHistory() { + return assertThat(processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).singleResult()); + } + + /** + * Assert list of runtime process instance activities ordered by activity start time. + * + * @return Assertion of #{@link ActivityInstance} list. + */ + public ListAssert activities() { + isNotNull(); + + return assertThat(processServicesProvider.getRuntimeService().createActivityInstanceQuery().processInstanceId(actual.getId()).orderByActivityInstanceStartTime().asc().list()); + } + + /** + * Assert list of runtime execution instances without ordering. + * + * @return Assertion of #{@link Execution} list. + */ + public ListAssert executions() { + isNotNull(); + + return assertThat(processServicesProvider.getRuntimeService().createExecutionQuery().processInstanceId(actual.getId()).list()); + } + + /** + * Assert list of runtime variable instances ordered by variable name ascending. + * + * @return Assertion of #{@link VariableInstance} list. + */ + public ListAssert variables() { + isNotNull(); + + return assertThat(processServicesProvider.getRuntimeService().createVariableInstanceQuery().processInstanceId(actual.getId()).orderByVariableName().asc().list()); + } + + /** + * Assert list of runtime identity links without ordering. + * + * @return Assertion of #{@link IdentityLink} list. + */ + public ListAssert identityLinks() { + isNotNull(); + + return assertThat(processServicesProvider.getRuntimeService().getIdentityLinksForProcessInstance(actual.getId())); + } + + /** + * Assert list of user tasks in the runtime ordered by the task name ascending. + * + * @return Assertion of {@link Task} list. + */ + public ListAssert userTasks() { + isNotNull(); + + return assertThat(getTaskService().createTaskQuery().processInstanceId(actual.getId()).orderByTaskName().asc() + .includeProcessVariables().includeIdentityLinks().includeTaskLocalVariables().list()); + } + + /** + * Assert list of event subscriptions in the runtime ordered by the event name ascending. + * + * @return Assertion of {@link EventSubscription} list. + */ + + public ListAssert eventSubscription() { + isNotNull(); + + return assertThat(processServicesProvider.getRuntimeService().createEventSubscriptionQuery().processInstanceId(actual.getId()).orderByEventName().asc().list()); + } +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java new file mode 100644 index 00000000000..3c30f19ab62 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java @@ -0,0 +1,25 @@ +package org.flowable.assertions.process; + +import org.flowable.engine.HistoryService; +import org.flowable.engine.ProcessEngine; +import org.flowable.engine.RuntimeService; + +public class ProcessServicesProvider { + final ProcessEngine processEngine; + + private ProcessServicesProvider(ProcessEngine processEngine) { + this.processEngine = processEngine; + } + + static ProcessServicesProvider of(ProcessEngine processEngine) { + return new ProcessServicesProvider(processEngine); + } + + RuntimeService getRuntimeService() { + return processEngine.getRuntimeService(); + } + + HistoryService getHistoryService() { + return processEngine.getHistoryService(); + } +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java new file mode 100644 index 00000000000..3b86bb22066 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java @@ -0,0 +1,32 @@ +package org.flowable.assertions.process; + +import org.flowable.engine.*; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; + +/** + * @author martin.grofcik + */ +public class Utils { + + protected static String getProcessDescription(ProcessInstance actual) { + return getProcessDescription(actual.getProcessDefinitionKey(), actual.getId()); + } + + protected static String getProcessDescription(HistoricProcessInstance actual) { + return getProcessDescription(actual.getProcessDefinitionKey(), actual.getId()); + } + + protected static String getProcessDescription(String processDefinitionKey, String id) { + return "Expected process instance <"+processDefinitionKey+", "+id+">"; + } + + protected static TaskService getTaskService() { + return getProcessEngine().getTaskService(); + } + + protected static ProcessEngine getProcessEngine() { + return ProcessEngines.getProcessEngines().get("default"); + } + +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java new file mode 100644 index 00000000000..adfec97b4e1 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java @@ -0,0 +1,111 @@ +package org.flowable.assertions.process; + +import org.assertj.core.groups.Tuple; +import org.flowable.engine.HistoryService; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.engine.test.Deployment; +import org.flowable.engine.test.FlowableTest; +import org.flowable.task.api.Task; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.flowable.assertions.process.TestUtils.createOneTaskProcess; + +/** + * @author martin.grofcik + */ +@FlowableTest +class HistoricProcessInstanceAssertTest { + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void isFinishedForFinishedProcessInstance(RuntimeService runtimeService, TaskService taskService, HistoryService historyService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().activities().extracting(HistoricActivityInstance::getActivityId).contains( + "theStart", "theStart-theTask", "theTask" + ); + + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().isFinished() + .activities().extracting(HistoricActivityInstance::getActivityId).contains( + "theStart", "theStart-theTask", "theTask", "theTask-theEnd", "theEnd" + ); + + HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); + FlowableProcessAssertions.assertThat(historicProcessInstance).isFinished() + .activities().extracting(HistoricActivityInstance::getActivityId).contains( + "theStart", "theStart-theTask", "theTask", "theTask-theEnd", "theEnd" + ); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void variables(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + .inHistory().variables().isEmpty(); + + runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + .inHistory() + .hasVariable("testVariable") + .hasVariableWithValue("testVariable", "variableValue") + .variables().hasSize(1).extracting("name", "value"). + containsExactly(Tuple.tuple("testVariable", "variableValue")); + + Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); + taskService.complete(task.getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + .doesNotExist() + .inHistory() + .isFinished() + .hasVariable("testVariable") + .hasVariableWithValue("testVariable", "variableValue") + .variables().hasSize(1).extracting("name", "value"). + containsExactly(Tuple.tuple("testVariable", "variableValue")); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void hasVariable(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + .inHistory().variables().isEmpty(); + + runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + .inHistory().variables().hasSize(1).extracting("name", "value"). + containsExactly(Tuple.tuple("testVariable", "variableValue")); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void doesNotHaveVariable(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + .inHistory().doesNotHaveVariable("nonExistingVariable"); + + runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + .inHistory().doesNotHaveVariable("nonExistingVariable") + .hasVariable("testVariable"); + + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().doesNotHaveVariable("testVariable")) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance does not have variable but variable exists in history."); + } + +} \ No newline at end of file diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java new file mode 100644 index 00000000000..f8478a158cd --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java @@ -0,0 +1,49 @@ +package org.flowable.assertions.process; + +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.engine.history.HistoricActivityInstance; +import org.flowable.engine.runtime.ActivityInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.engine.test.Deployment; +import org.flowable.engine.test.FlowableTest; +import org.junit.jupiter.api.Test; + +/** + * @author martin.grofcik + */ +@FlowableTest +class LongRunningProcessInstanceAssertTest { + + @Test + @Deployment(resources = "twoTasks.bpmn20.xml") + void useOneAssertInstanceThroughAllTest(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance twoTasksProcess = runtimeService.createProcessInstanceBuilder().processDefinitionKey("twoTasksProcess").start(); + ProcessInstanceAssert asserThatProcessInstance = FlowableProcessAssertions.assertThat( + twoTasksProcess + ); + asserThatProcessInstance.isRunning() + .activities().extracting(ActivityInstance::getActivityId).containsExactlyInAnyOrder( + "theStart", "theStart-theTask", "theTask1" + ); + + taskService.complete(geTaskIdForProcessInstance(twoTasksProcess.getId(), taskService)); + + asserThatProcessInstance.isRunning().activities().extracting(ActivityInstance::getActivityId).containsExactlyInAnyOrder( + "theStart", "theStart-theTask", "theTask1", "theTask1-theTask2", "theTask2" + ); + + taskService.complete(geTaskIdForProcessInstance(twoTasksProcess.getId(), taskService)); + + asserThatProcessInstance.doesNotExist().inHistory() + .activities().extracting(HistoricActivityInstance::getActivityId).containsExactlyInAnyOrder( + "theStart", "theStart-theTask", "theTask1", "theTask1-theTask2", "theTask2", "theTask-theEnd", + "theEnd" + ); + } + + private String geTaskIdForProcessInstance(String processInstanceId, TaskService taskService) { + return taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult().getId(); + } + +} \ No newline at end of file diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java new file mode 100644 index 00000000000..1e27cf330bc --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java @@ -0,0 +1,289 @@ +package org.flowable.assertions.process; + +import org.assertj.core.groups.Tuple; +import org.flowable.engine.ManagementService; +import org.flowable.engine.ProcessEngineConfiguration; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.engine.impl.test.JobTestHelper; +import org.flowable.engine.runtime.ActivityInstance; +import org.flowable.engine.runtime.Execution; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.engine.test.Deployment; +import org.flowable.engine.test.FlowableTest; +import org.flowable.eventsubscription.api.EventSubscription; +import org.flowable.identitylink.api.IdentityLink; +import org.flowable.identitylink.api.IdentityLinkType; +import org.flowable.identitylink.api.history.HistoricIdentityLink; +import org.flowable.task.api.Task; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.flowable.assertions.process.TestUtils.createOneTaskProcess; + +/** + * @author martin.grofcik + */ +@FlowableTest +class ProcessInstanceAssertTest { + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void isRunning(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning(); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void isRunningForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning()) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance to be running but is not."); + } + + @Test + void isRunningForNull() { + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat((ProcessInstance) null).isRunning()) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expecting actual not to be null"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void hasVariable(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("variableName"); + FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("variableName").isRunning(); + FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning().hasVariable("variableName"); + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("nonExistingVariable")) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance has variable but variable does not exist."); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void hasVariableForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("variableName")) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance has variable but variable does not exist."); + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("nonExistingVariable")) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance has variable but variable does not exist."); + } + + @Test + void hasVariableForNull() { + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat((ProcessInstance) null).hasVariable("variableName")) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expecting actual not to be null"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void doesNotHaveVariable(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("NonExistingVariableName"); + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("NonExistingVariableName").isRunning(); + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("variableName")) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance does not have variable but variable exists."); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void doesNotHaveVariableForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("variableName"); + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("nonExistingVariable"); + } + + @Test + void doesNotHaveVariableForNull() { + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat((ProcessInstance) null).doesNotHaveVariable("variableName")) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expecting actual not to be null"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void doesNotExistForRunningInstance(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist()) + .isInstanceOf(AssertionError.class) + .hasMessage("Expected process instance is finished but instance exists in runtime."); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void doesNotExistForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist(); + } + + @Test + void doesNotExistForNull() { + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat((ProcessInstance) null).doesNotExist()) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expecting actual not to be null"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void activitiesForRunningInstance(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).activities().extracting(ActivityInstance::getActivityId) + .contains("theStart", "theStart-theTask", "theTask"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void activitiesForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).activities().isEmpty(); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void executions(RuntimeService runtimeService, TaskService taskService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Running process has at least 2 active executions." + + "(ProcessInstance + Child)") + .executions().extracting(Execution::getId).contains(oneTaskProcess.getId()) + .hasSize(2); + + taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist().as("There must be no execution for the finished process.") + .executions().hasSize(0); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void variables(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).variables().isEmpty(); + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("nonExistingVar", "anyValue")) + .isInstanceOf(AssertionError.class).hasMessage("Expected process instance has variable but variable does not exist."); + + runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "initialValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "initialValue")); + FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("testVariable", "initialValue"); + + runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "updatedValue"); + + FlowableProcessAssertions.assertThat(oneTaskProcess).variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "updatedValue")); + FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("testVariable", "updatedValue").isRunning(); + + runtimeService.setVariable(oneTaskProcess.getId(), "firstVariable", "initialValue"); + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variables are ordered by names ascending.") + .variables().extracting("name") + .containsExactly("firstVariable", "testVariable"); + + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void identityLinks(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + + FlowableProcessAssertions.assertThat(oneTaskProcess).identityLinks().isEmpty(); + FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().identityLinks().isEmpty(); + + runtimeService.addUserIdentityLink(oneTaskProcess.getId(), "testUser", IdentityLinkType.ASSIGNEE); + runtimeService.addGroupIdentityLink(oneTaskProcess.getId(), "testGroup", IdentityLinkType.CANDIDATE); + + FlowableProcessAssertions.assertThat(oneTaskProcess).identityLinks().hasSize(2) + .extracting(IdentityLink::getUserId, IdentityLink::getGroupId, IdentityLink::getType) + .containsExactlyInAnyOrder(Tuple.tuple("testUser", null, IdentityLinkType.ASSIGNEE), + Tuple.tuple(null, "testGroup", IdentityLinkType.CANDIDATE)); + FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().identityLinks().hasSize(2) + .extracting(HistoricIdentityLink::getUserId, HistoricIdentityLink::getGroupId, HistoricIdentityLink::getType) + .containsExactlyInAnyOrder(Tuple.tuple("testUser", null, IdentityLinkType.ASSIGNEE), + Tuple.tuple(null, "testGroup", IdentityLinkType.CANDIDATE)); + + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void userTasks(RuntimeService runtimeService, ManagementService managementService, + TaskService taskService, ProcessEngineConfiguration processEngineConfiguration) { + ProcessInstance oneTaskProcess = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").startAsync(); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Process instance is started asynchronously and did not reach userTask") + .userTasks().isEmpty(); + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Process instance is started asynchronously and did not reach userTask in history") + .inHistory().userTasks().isEmpty(); + + JobTestHelper.waitForJobExecutorToProcessAllJobs(processEngineConfiguration, managementService, 10_000, 500); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Async executions executed and userTask reached.") + .userTasks().hasSize(1).extracting(Task::getTaskDefinitionKey).containsExactly("theTask"); + FlowableProcessAssertions.assertThat(oneTaskProcess).as("Async executions executed and userTask reached in history.") + .inHistory().userTasks().hasSize(1).extracting(HistoricTaskInstance::getTaskDefinitionKey) + .containsExactly("theTask"); + + Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); + taskService.complete(task.getId()); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("User tasks are empty for non existing process").doesNotExist() + .userTasks().isEmpty(); + FlowableProcessAssertions.assertThat(oneTaskProcess).as("The userTask is completed, but must exist in history.") + .inHistory().isFinished() + .userTasks().hasSize(1).extracting(HistoricTaskInstance::getTaskDefinitionKey) + .containsExactly("theTask"); + } + + @Test + @Deployment(resources = "oneTask.bpmn20.xml") + void subscriptionsWithoutSubscription(RuntimeService runtimeService) { + ProcessInstance oneTaskProcess = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start(); + + FlowableProcessAssertions.assertThat(oneTaskProcess).as("One task process does not have any subscription") + .eventSubscription().isEmpty(); + + } + + @Test + @Deployment(resources = "oneTaskWithBoundaryEvent.bpmn20.xml") + void subscriptions(RuntimeService runtimeService) { + ProcessInstance oneTaskProcessWithSubscription = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcessWithBoundaryEvent").start(); + + FlowableProcessAssertions.assertThat(oneTaskProcessWithSubscription).as("One task process with subscription has exactly one subscription") + .eventSubscription().hasSize(1).extracting(EventSubscription::getEventName).contains("eventMessage"); + } + + @Test + void activitiesForNull() { + assertThatThrownBy(() -> FlowableProcessAssertions.assertThat((ProcessInstance) null).doesNotExist()) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("Expecting actual not to be null"); + } + +} \ No newline at end of file diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java new file mode 100644 index 00000000000..fc1861a5080 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java @@ -0,0 +1,13 @@ +package org.flowable.assertions.process; + +import org.flowable.engine.RuntimeService; +import org.flowable.engine.runtime.ProcessInstance; + +/** + * @author martin.grofcik + */ +abstract class TestUtils { + static ProcessInstance createOneTaskProcess(RuntimeService runtimeService) { + return runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start(); + } +} diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml new file mode 100644 index 00000000000..9f1f9937cc2 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties new file mode 100644 index 00000000000..3cb5809086f --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties @@ -0,0 +1,9 @@ +log4j.rootLogger=INFO, CA + +# ConsoleAppender +log4j.appender.CA=org.apache.log4j.ConsoleAppender +log4j.appender.CA.layout=org.apache.log4j.PatternLayout +log4j.appender.CA.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n + +log4j.logger.org.apache.ibatis=INFO +log4j.logger.javax.activation=INFO diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml new file mode 100644 index 00000000000..1649c6f4ff4 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml new file mode 100644 index 00000000000..53bad04ca24 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml new file mode 100644 index 00000000000..accf69c9c30 --- /dev/null +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/modules/flowable-assertions/pom.xml b/modules/flowable-assertions/pom.xml new file mode 100644 index 00000000000..1098a519ae9 --- /dev/null +++ b/modules/flowable-assertions/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + org.flowable + flowable-root + 7.1.0-SNAPSHOT + ../../pom.xml + + pom + + flowable-assertions + + + flowable-process-assertions + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml b/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml new file mode 100644 index 00000000000..42802d82a93 --- /dev/null +++ b/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + PT1S + + + + + + \ No newline at end of file diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml new file mode 100644 index 00000000000..9b3637ceea9 --- /dev/null +++ b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy new file mode 100644 index 00000000000..66ffcc96116 --- /dev/null +++ b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy @@ -0,0 +1,27 @@ +package org.flowable.test.spring.boot + +import flowable.Application +import org.flowable.engine.RuntimeService +import org.flowable.engine.runtime.ProcessInstance +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest + +import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat + +@SpringBootTest(classes = Application.class) +class OneTaskProcessGroovyTest { + @Autowired + RuntimeService runtimeService; + + @Test + void "happy path"() { + ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start() + + assertThat(processInstance).isRunning() + .doesNotHaveVariable('nonExistingVariable') + .activities().extracting('activityId') + .contains('theStart', 'theStart-theTask', 'theTask') + + } +} diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy new file mode 100644 index 00000000000..9d1ed52fbf1 --- /dev/null +++ b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy @@ -0,0 +1,42 @@ +package org.flowable.test.spring.boot + +import flowable.Application +import org.flowable.engine.RuntimeService +import org.flowable.engine.TaskService +import org.flowable.engine.runtime.ProcessInstance +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ContextConfiguration +import spock.lang.Specification + +import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat + +@SpringBootTest(classes = Application.class) +@ContextConfiguration +class OneTaskProcessSpec extends Specification { + @Autowired + RuntimeService runtimeService + @Autowired + TaskService taskService + + def 'happy path'() { + given: + path = [] + + when: + ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start() + + then: + assertThat(processInstance).isRunning() + .doesNotHaveVariable('nonExistingVariable') + .activities().extracting('activityId') + .contains(path << ['theStart', 'theStart-theTask', 'theTask']) + + when: + + cleanup: + runtimeService.deleteProcessInstance(processInstance.id, 'removing test process instance') + } + +} diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java new file mode 100644 index 00000000000..3ee8dd88c73 --- /dev/null +++ b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java @@ -0,0 +1,29 @@ +package org.flowable.test.spring.boot; + +import flowable.Application; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.runtime.ActivityInstance; +import org.flowable.engine.runtime.ProcessInstance; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat; + +@SpringBootTest(classes = Application.class) +public class OneTaskProcessTest { + @Autowired + RuntimeService runtimeService; + + @Test + void happyPath() { + ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start(); + + assertThat(processInstance) + .isRunning() + .doesNotHaveVariable("nonExistingVariable") + .activities().extracting(ActivityInstance::getActivityId).contains( + "theStart", "theStart-theTask", "theTask" + ); + } +} diff --git a/pom.xml b/pom.xml index 3a76fe2bcb9..a174c3f859c 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,9 @@ modules/flowable-spring-security modules/flowable-http-common modules/flowable-mail - + modules/flowable-assertions + modules/flowable-assertions/flowable-process-assertions + From 289b7081f0a0685e95befeff7cd2bab7ac4f7313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 19:12:33 +0100 Subject: [PATCH 02/12] #3835 test clean up --- .../HistoricProcessInstanceAssertTest.java | 24 ++++--- .../process/ProcessInstanceAssertTest.java | 63 ++++++++++--------- .../boot/OneTaskProcessGroovyTest.groovy | 27 -------- .../spring/boot/OneTaskProcessSpec.groovy | 42 ------------- .../test/spring/boot/OneTaskProcessTest.java | 29 --------- 5 files changed, 49 insertions(+), 136 deletions(-) delete mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy delete mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy delete mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java index adfec97b4e1..0af5e616c8b 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java @@ -26,13 +26,14 @@ class HistoricProcessInstanceAssertTest { void isFinishedForFinishedProcessInstance(RuntimeService runtimeService, TaskService taskService, HistoryService historyService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().activities().extracting(HistoricActivityInstance::getActivityId).contains( + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.inHistory().activities().extracting(HistoricActivityInstance::getActivityId).contains( "theStart", "theStart-theTask", "theTask" ); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); - FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().isFinished() + assertThatOneTaskProcess.inHistory().isFinished() .activities().extracting(HistoricActivityInstance::getActivityId).contains( "theStart", "theStart-theTask", "theTask", "theTask-theEnd", "theEnd" ); @@ -49,12 +50,13 @@ void isFinishedForFinishedProcessInstance(RuntimeService runtimeService, TaskSer void variables(RuntimeService runtimeService, TaskService taskService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.as("No variable exists in the process scope.") .inHistory().variables().isEmpty(); runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + assertThatOneTaskProcess.as("Variable exists in the process scope, the variable must be present in the history.") .inHistory() .hasVariable("testVariable") .hasVariableWithValue("testVariable", "variableValue") @@ -64,7 +66,7 @@ void variables(RuntimeService runtimeService, TaskService taskService) { Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); taskService.complete(task.getId()); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + assertThatOneTaskProcess.as("Variable exists in the process scope, the variable must be present in the history.") .doesNotExist() .inHistory() .isFinished() @@ -79,12 +81,13 @@ void variables(RuntimeService runtimeService, TaskService taskService) { void hasVariable(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.as("No variable exists in the process scope.") .inHistory().variables().isEmpty(); runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + assertThatOneTaskProcess.as("Variable exists in the process scope, the variable must be present in the history.") .inHistory().variables().hasSize(1).extracting("name", "value"). containsExactly(Tuple.tuple("testVariable", "variableValue")); } @@ -94,16 +97,17 @@ void hasVariable(RuntimeService runtimeService) { void doesNotHaveVariable(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("No variable exists in the process scope.") + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.as("No variable exists in the process scope.") .inHistory().doesNotHaveVariable("nonExistingVariable"); runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "variableValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variable exists in the process scope, the variable must be present in the history.") + assertThatOneTaskProcess.as("Variable exists in the process scope, the variable must be present in the history.") .inHistory().doesNotHaveVariable("nonExistingVariable") .hasVariable("testVariable"); - assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().doesNotHaveVariable("testVariable")) + assertThatThrownBy(() -> assertThatOneTaskProcess.inHistory().doesNotHaveVariable("testVariable")) .isInstanceOf(AssertionError.class) .hasMessage("Expected process instance does not have variable but variable exists in history."); } diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java index 1e27cf330bc..02ae9888374 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java @@ -60,10 +60,11 @@ void hasVariable(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("variableName"); - FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("variableName").isRunning(); - FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning().hasVariable("variableName"); - assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariable("nonExistingVariable")) + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.hasVariable("variableName"); + assertThatOneTaskProcess.hasVariable("variableName").isRunning(); + assertThatOneTaskProcess.isRunning().hasVariable("variableName"); + assertThatThrownBy(() -> assertThatOneTaskProcess.hasVariable("nonExistingVariable")) .isInstanceOf(AssertionError.class) .hasMessage("Expected process instance has variable but variable does not exist."); } @@ -96,9 +97,10 @@ void doesNotHaveVariable(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("NonExistingVariableName"); - FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("NonExistingVariableName").isRunning(); - assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("variableName")) + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.doesNotHaveVariable("NonExistingVariableName"); + assertThatOneTaskProcess.doesNotHaveVariable("NonExistingVariableName").isRunning(); + assertThatThrownBy(() -> assertThatOneTaskProcess.doesNotHaveVariable("variableName")) .isInstanceOf(AssertionError.class) .hasMessage("Expected process instance does not have variable but variable exists."); } @@ -110,8 +112,9 @@ void doesNotHaveVariableForNonRunningProcess(RuntimeService runtimeService, Task runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); - FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("variableName"); - FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotHaveVariable("nonExistingVariable"); + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.doesNotHaveVariable("variableName"); + assertThatOneTaskProcess.doesNotHaveVariable("nonExistingVariable"); } @Test @@ -170,14 +173,15 @@ void activitiesForNonRunningProcess(RuntimeService runtimeService, TaskService t void executions(RuntimeService runtimeService, TaskService taskService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Running process has at least 2 active executions." + + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.as("Running process has at least 2 active executions." + "(ProcessInstance + Child)") .executions().extracting(Execution::getId).contains(oneTaskProcess.getId()) .hasSize(2); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); - FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist().as("There must be no execution for the finished process.") + assertThatOneTaskProcess.doesNotExist().as("There must be no execution for the finished process.") .executions().hasSize(0); } @@ -186,23 +190,24 @@ void executions(RuntimeService runtimeService, TaskService taskService) { void variables(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).variables().isEmpty(); - assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("nonExistingVar", "anyValue")) + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.variables().isEmpty(); + assertThatThrownBy(() -> assertThatOneTaskProcess.hasVariableWithValue("nonExistingVar", "anyValue")) .isInstanceOf(AssertionError.class).hasMessage("Expected process instance has variable but variable does not exist."); runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "initialValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "initialValue")); - FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("testVariable", "initialValue"); + assertThatOneTaskProcess.variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "initialValue")); + assertThatOneTaskProcess.hasVariableWithValue("testVariable", "initialValue"); runtimeService.setVariable(oneTaskProcess.getId(), "testVariable", "updatedValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "updatedValue")); - FlowableProcessAssertions.assertThat(oneTaskProcess).hasVariableWithValue("testVariable", "updatedValue").isRunning(); + assertThatOneTaskProcess.variables().extracting("name", "value").contains(Tuple.tuple("testVariable", "updatedValue")); + assertThatOneTaskProcess.hasVariableWithValue("testVariable", "updatedValue").isRunning(); runtimeService.setVariable(oneTaskProcess.getId(), "firstVariable", "initialValue"); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Variables are ordered by names ascending.") + assertThatOneTaskProcess.as("Variables are ordered by names ascending.") .variables().extracting("name") .containsExactly("firstVariable", "testVariable"); @@ -213,17 +218,18 @@ void variables(RuntimeService runtimeService) { void identityLinks(RuntimeService runtimeService) { ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); - FlowableProcessAssertions.assertThat(oneTaskProcess).identityLinks().isEmpty(); - FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().identityLinks().isEmpty(); + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.identityLinks().isEmpty(); + assertThatOneTaskProcess.inHistory().identityLinks().isEmpty(); runtimeService.addUserIdentityLink(oneTaskProcess.getId(), "testUser", IdentityLinkType.ASSIGNEE); runtimeService.addGroupIdentityLink(oneTaskProcess.getId(), "testGroup", IdentityLinkType.CANDIDATE); - FlowableProcessAssertions.assertThat(oneTaskProcess).identityLinks().hasSize(2) + assertThatOneTaskProcess.identityLinks().hasSize(2) .extracting(IdentityLink::getUserId, IdentityLink::getGroupId, IdentityLink::getType) .containsExactlyInAnyOrder(Tuple.tuple("testUser", null, IdentityLinkType.ASSIGNEE), Tuple.tuple(null, "testGroup", IdentityLinkType.CANDIDATE)); - FlowableProcessAssertions.assertThat(oneTaskProcess).inHistory().identityLinks().hasSize(2) + assertThatOneTaskProcess.inHistory().identityLinks().hasSize(2) .extracting(HistoricIdentityLink::getUserId, HistoricIdentityLink::getGroupId, HistoricIdentityLink::getType) .containsExactlyInAnyOrder(Tuple.tuple("testUser", null, IdentityLinkType.ASSIGNEE), Tuple.tuple(null, "testGroup", IdentityLinkType.CANDIDATE)); @@ -236,25 +242,26 @@ void userTasks(RuntimeService runtimeService, ManagementService managementServic TaskService taskService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance oneTaskProcess = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").startAsync(); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Process instance is started asynchronously and did not reach userTask") + ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); + assertThatOneTaskProcess.as("Process instance is started asynchronously and did not reach userTask") .userTasks().isEmpty(); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Process instance is started asynchronously and did not reach userTask in history") + assertThatOneTaskProcess.as("Process instance is started asynchronously and did not reach userTask in history") .inHistory().userTasks().isEmpty(); JobTestHelper.waitForJobExecutorToProcessAllJobs(processEngineConfiguration, managementService, 10_000, 500); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Async executions executed and userTask reached.") + assertThatOneTaskProcess.as("Async executions executed and userTask reached.") .userTasks().hasSize(1).extracting(Task::getTaskDefinitionKey).containsExactly("theTask"); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("Async executions executed and userTask reached in history.") + assertThatOneTaskProcess.as("Async executions executed and userTask reached in history.") .inHistory().userTasks().hasSize(1).extracting(HistoricTaskInstance::getTaskDefinitionKey) .containsExactly("theTask"); Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); taskService.complete(task.getId()); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("User tasks are empty for non existing process").doesNotExist() + assertThatOneTaskProcess.as("User tasks are empty for non existing process").doesNotExist() .userTasks().isEmpty(); - FlowableProcessAssertions.assertThat(oneTaskProcess).as("The userTask is completed, but must exist in history.") + assertThatOneTaskProcess.as("The userTask is completed, but must exist in history.") .inHistory().isFinished() .userTasks().hasSize(1).extracting(HistoricTaskInstance::getTaskDefinitionKey) .containsExactly("theTask"); diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy deleted file mode 100644 index 66ffcc96116..00000000000 --- a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessGroovyTest.groovy +++ /dev/null @@ -1,27 +0,0 @@ -package org.flowable.test.spring.boot - -import flowable.Application -import org.flowable.engine.RuntimeService -import org.flowable.engine.runtime.ProcessInstance -import org.junit.jupiter.api.Test -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest - -import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat - -@SpringBootTest(classes = Application.class) -class OneTaskProcessGroovyTest { - @Autowired - RuntimeService runtimeService; - - @Test - void "happy path"() { - ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start() - - assertThat(processInstance).isRunning() - .doesNotHaveVariable('nonExistingVariable') - .activities().extracting('activityId') - .contains('theStart', 'theStart-theTask', 'theTask') - - } -} diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy deleted file mode 100644 index 9d1ed52fbf1..00000000000 --- a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessSpec.groovy +++ /dev/null @@ -1,42 +0,0 @@ -package org.flowable.test.spring.boot - -import flowable.Application -import org.flowable.engine.RuntimeService -import org.flowable.engine.TaskService -import org.flowable.engine.runtime.ProcessInstance -import org.junit.jupiter.api.Test -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ContextConfiguration -import spock.lang.Specification - -import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat - -@SpringBootTest(classes = Application.class) -@ContextConfiguration -class OneTaskProcessSpec extends Specification { - @Autowired - RuntimeService runtimeService - @Autowired - TaskService taskService - - def 'happy path'() { - given: - path = [] - - when: - ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start() - - then: - assertThat(processInstance).isRunning() - .doesNotHaveVariable('nonExistingVariable') - .activities().extracting('activityId') - .contains(path << ['theStart', 'theStart-theTask', 'theTask']) - - when: - - cleanup: - runtimeService.deleteProcessInstance(processInstance.id, 'removing test process instance') - } - -} diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java deleted file mode 100644 index 3ee8dd88c73..00000000000 --- a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/test/java/org/flowable/test/spring/boot/OneTaskProcessTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.flowable.test.spring.boot; - -import flowable.Application; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.runtime.ActivityInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.crp.flowable.assertions.CrpFlowableAssertions.assertThat; - -@SpringBootTest(classes = Application.class) -public class OneTaskProcessTest { - @Autowired - RuntimeService runtimeService; - - @Test - void happyPath() { - ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("oneTaskProcess").start(); - - assertThat(processInstance) - .isRunning() - .doesNotHaveVariable("nonExistingVariable") - .activities().extracting(ActivityInstance::getActivityId).contains( - "theStart", "theStart-theTask", "theTask" - ); - } -} From dde9a98c4eb5d3df0c5bead0e278b5a257bfaefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 19:14:36 +0100 Subject: [PATCH 03/12] #3835 test clean up --- .../ReceiveTaskTest.waitTimer.bpmn20.xml | 17 ----------------- .../main/resources/processes/oneTask.bpmn20.xml | 14 -------------- 2 files changed, 31 deletions(-) delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml delete mode 100644 modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml diff --git a/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml b/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml deleted file mode 100644 index 42802d82a93..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/examples/bpmn/receivetask/ReceiveTaskTest.waitTimer.bpmn20.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - PT1S - - - - - - \ No newline at end of file diff --git a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml b/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml deleted file mode 100644 index 9b3637ceea9..00000000000 --- a/modules/flowable-spring-boot/flowable-spring-boot-samples/flowable-spring-boot-sample-rest-api/src/main/resources/processes/oneTask.bpmn20.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - From 2b59e75b2b5d4a5d4571c74c8bef3921499807c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 19:28:23 +0100 Subject: [PATCH 04/12] #3835 adding modules into pom --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a174c3f859c..b9b39492876 100644 --- a/pom.xml +++ b/pom.xml @@ -536,8 +536,7 @@ modules/flowable-spring-security modules/flowable-http-common modules/flowable-mail - modules/flowable-assertions - modules/flowable-assertions/flowable-process-assertions + modules/flowable-assertions @@ -1025,6 +1024,7 @@ modules/flowable-ldap modules/flowable-ldap-configurator modules/flowable-jmx + modules/flowable-assertions tooling/archetypes/flowable-archetype-unittest From e2e01c462fd86047df2331bd633115ee048cb2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 19:02:00 +0100 Subject: [PATCH 05/12] #3835 formatting --- .../flowable/assertions/process/ProcessServicesProvider.java | 3 +++ pom.xml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java index 3c30f19ab62..7d682ec6ffb 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java @@ -4,6 +4,9 @@ import org.flowable.engine.ProcessEngine; import org.flowable.engine.RuntimeService; +/** + * @author martin.grofcik + */ public class ProcessServicesProvider { final ProcessEngine processEngine; diff --git a/pom.xml b/pom.xml index b9b39492876..c1d73b484b1 100644 --- a/pom.xml +++ b/pom.xml @@ -536,8 +536,8 @@ modules/flowable-spring-security modules/flowable-http-common modules/flowable-mail - modules/flowable-assertions - + modules/flowable-assertions + From 1f431ccbd2b2a3bafea8f29eb74deff5e1afe51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 21:06:31 +0100 Subject: [PATCH 06/12] #3835 license --- .../process/FlowableProcessAssertions.java | 13 +++++++++++++ .../process/HistoricProcessInstanceAssert.java | 13 +++++++++++++ .../assertions/process/ProcessInstanceAssert.java | 14 ++++++++++++++ .../process/ProcessServicesProvider.java | 13 +++++++++++++ .../org/flowable/assertions/process/Utils.java | 13 +++++++++++++ .../process/HistoricProcessInstanceAssertTest.java | 13 +++++++++++++ .../LongRunningProcessInstanceAssertTest.java | 13 +++++++++++++ .../process/ProcessInstanceAssertTest.java | 13 +++++++++++++ .../org/flowable/assertions/process/TestUtils.java | 13 +++++++++++++ 9 files changed, 118 insertions(+) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java index 48bb56b00ac..e29a569e347 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.assertj.core.api.Assertions; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java index 3aed654fc5e..1f043a95665 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.assertj.core.api.AbstractAssert; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java index 2d2497667fb..ac66bf97ffd 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.assertj.core.api.AbstractAssert; @@ -14,6 +27,7 @@ import static org.flowable.assertions.process.FlowableProcessAssertions.assertThat; import static org.flowable.assertions.process.Utils.*; + /** * @author martin.grofcik */ diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java index 7d682ec6ffb..88e0286a32d 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.flowable.engine.HistoryService; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java index 3b86bb22066..9ac75fe8c93 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.flowable.engine.*; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java index 0af5e616c8b..5a8e62685bc 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.assertj.core.groups.Tuple; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java index f8478a158cd..5ee48c2e162 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.flowable.engine.RuntimeService; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java index 02ae9888374..7241c56704d 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.assertj.core.groups.Tuple; diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java index fc1861a5080..b21aa98b15f 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java @@ -1,3 +1,16 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.flowable.assertions.process; import org.flowable.engine.RuntimeService; From 537de3a837a5b04dcaa674748a03abdc0ee579e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 21:12:34 +0100 Subject: [PATCH 07/12] Update modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java Co-authored-by: David B Malkovsky --- .../assertions/process/HistoricProcessInstanceAssert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java index 1f043a95665..b131c20d282 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java @@ -65,7 +65,7 @@ public HistoricProcessInstanceAssert isFinished() { processExistsInHistory(); if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().finished().processInstanceId(actual.getId()).count() != 1) { - failWithMessage(getProcessDescription(actual)+" to be finished, but is running in history."); + failWithMessage(getProcessDescription(actual) + " to be finished, but is running in history."); } return this; From e3a3f49cb8ed12a9bea6ad4cd9ce0a19a326ff4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 21:13:31 +0100 Subject: [PATCH 08/12] Update modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java Co-authored-by: David B Malkovsky --- .../assertions/process/HistoricProcessInstanceAssert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java index b131c20d282..7ea7de6a9b4 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java @@ -88,7 +88,7 @@ public HistoricProcessInstanceAssert hasVariable(String variableName) { processExistsInHistory(); if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 1) { - failWithMessage(getProcessDescription(actual)+" has variable <%s> but variable does not exist in history.", variableName); + failWithMessage(getProcessDescription(actual) + " has variable <%s> but variable does not exist in history.", variableName); } return this; From 363f2151961858bc2317ec34c3648167d1710757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 21:14:02 +0100 Subject: [PATCH 09/12] Update modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java Co-authored-by: David B Malkovsky --- .../org/flowable/assertions/process/ProcessInstanceAssert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java index ac66bf97ffd..d0c3211e165 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java @@ -105,7 +105,7 @@ public ProcessInstanceAssert doesNotHaveVariable(String variableName) { } /** - * Assert that process instance does on exist in runtime. + * Assert that process instance does not exist in runtime. * * @return Process instance assertion */ From c14a4528172aa3faa8a4c1013e94519ebce90997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Fri, 2 Feb 2024 21:22:19 +0100 Subject: [PATCH 10/12] #3835 imports --- .../process/HistoricProcessInstanceAssert.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java index 1f043a95665..248bf309740 100644 --- a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java +++ b/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java @@ -13,8 +13,11 @@ package org.flowable.assertions.process; +import static org.assertj.core.api.Assertions.assertThat; +import static org.flowable.assertions.process.Utils.getProcessDescription; +import static org.flowable.assertions.process.Utils.getProcessEngine; + import org.assertj.core.api.AbstractAssert; -import org.assertj.core.api.Assertions; import org.assertj.core.api.ListAssert; import org.flowable.engine.ProcessEngine; import org.flowable.engine.history.HistoricActivityInstance; @@ -24,13 +27,9 @@ import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.variable.api.history.HistoricVariableInstance; -import static org.flowable.assertions.process.FlowableProcessAssertions.assertThat; -import static org.flowable.assertions.process.Utils.*; - /** * @author martin.grofcik */ - public class HistoricProcessInstanceAssert extends AbstractAssert { protected final ProcessServicesProvider processServicesProvider; @@ -121,7 +120,7 @@ public HistoricProcessInstanceAssert hasVariableWithValue(String variableName, O hasVariable(variableName); HistoricVariableInstance actualVariable = processServicesProvider.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(actual.getId()).variableName(variableName).singleResult(); - Assertions.assertThat(actualVariable.getValue()).isEqualTo(expectedValue); + assertThat(actualVariable.getValue()).isEqualTo(expectedValue); return this; } From c4bbe51d303d62f108b98da9e24ff0962f3fe32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Tue, 20 Feb 2024 08:33:51 +0100 Subject: [PATCH 11/12] #3835 module change flowable-assertions -> flowable-assertj --- modules/flowable-assertions/pom.xml | 25 ------------------- .../pom.xml | 6 +++-- .../process/FlowableProcessAssertions.java | 0 .../HistoricProcessInstanceAssert.java | 0 .../process/ProcessInstanceAssert.java | 0 .../process/ProcessServicesProvider.java | 0 .../flowable/assertions/process/Utils.java | 0 .../HistoricProcessInstanceAssertTest.java | 0 .../LongRunningProcessInstanceAssertTest.java | 0 .../process/ProcessInstanceAssertTest.java | 0 .../assertions/process/TestUtils.java | 0 .../src/test/resources/flowable.cfg.xml | 0 .../src/test/resources/log4j.properties | 0 .../src/test/resources/oneTask.bpmn20.xml | 0 .../oneTaskWithBoundaryEvent.bpmn20.xml | 0 .../src/test/resources/twoTasks.bpmn20.xml | 0 pom.xml | 4 +-- 17 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 modules/flowable-assertions/pom.xml rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/pom.xml (88%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/main/java/org/flowable/assertions/process/Utils.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/java/org/flowable/assertions/process/TestUtils.java (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/resources/flowable.cfg.xml (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/resources/log4j.properties (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/resources/oneTask.bpmn20.xml (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml (100%) rename modules/{flowable-assertions/flowable-process-assertions => flowable-assertj}/src/test/resources/twoTasks.bpmn20.xml (100%) diff --git a/modules/flowable-assertions/pom.xml b/modules/flowable-assertions/pom.xml deleted file mode 100644 index 1098a519ae9..00000000000 --- a/modules/flowable-assertions/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - 4.0.0 - - org.flowable - flowable-root - 7.1.0-SNAPSHOT - ../../pom.xml - - pom - - flowable-assertions - - - flowable-process-assertions - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-assertions/flowable-process-assertions/pom.xml b/modules/flowable-assertj/pom.xml similarity index 88% rename from modules/flowable-assertions/flowable-process-assertions/pom.xml rename to modules/flowable-assertj/pom.xml index e840a9e0479..5fb3762fa71 100644 --- a/modules/flowable-assertions/flowable-process-assertions/pom.xml +++ b/modules/flowable-assertj/pom.xml @@ -5,11 +5,12 @@ 4.0.0 org.flowable - flowable-assertions + flowable-root + ../.. 7.1.0-SNAPSHOT - flowable-process-assertions + flowable-assertj @@ -20,6 +21,7 @@ org.flowable flowable-engine + provided com.zaxxer diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java b/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java b/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java b/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java b/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/Utils.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/main/java/org/flowable/assertions/process/Utils.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertions/process/Utils.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java b/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/TestUtils.java similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/java/org/flowable/assertions/process/TestUtils.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertions/process/TestUtils.java diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml b/modules/flowable-assertj/src/test/resources/flowable.cfg.xml similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/resources/flowable.cfg.xml rename to modules/flowable-assertj/src/test/resources/flowable.cfg.xml diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties b/modules/flowable-assertj/src/test/resources/log4j.properties similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/resources/log4j.properties rename to modules/flowable-assertj/src/test/resources/log4j.properties diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml b/modules/flowable-assertj/src/test/resources/oneTask.bpmn20.xml similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTask.bpmn20.xml rename to modules/flowable-assertj/src/test/resources/oneTask.bpmn20.xml diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml b/modules/flowable-assertj/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml rename to modules/flowable-assertj/src/test/resources/oneTaskWithBoundaryEvent.bpmn20.xml diff --git a/modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml b/modules/flowable-assertj/src/test/resources/twoTasks.bpmn20.xml similarity index 100% rename from modules/flowable-assertions/flowable-process-assertions/src/test/resources/twoTasks.bpmn20.xml rename to modules/flowable-assertj/src/test/resources/twoTasks.bpmn20.xml diff --git a/pom.xml b/pom.xml index c1d73b484b1..3ca4e154691 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,7 @@ modules/flowable-spring-security modules/flowable-http-common modules/flowable-mail - modules/flowable-assertions + modules/flowable-assertj @@ -1024,7 +1024,7 @@ modules/flowable-ldap modules/flowable-ldap-configurator modules/flowable-jmx - modules/flowable-assertions + modules/flowable-assertj tooling/archetypes/flowable-archetype-unittest From 86f9192c3c45778a6cc0ea1593cf21c5a3aedb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Grof=C4=8D=C3=ADk?= Date: Tue, 20 Feb 2024 08:40:51 +0100 Subject: [PATCH 12/12] #3835 package change org.flowable.assertions -> org.flowable.assertj --- .../process/FlowableProcessAssertions.java | 2 +- .../HistoricProcessInstanceAssert.java | 14 ++++----- .../process/ProcessInstanceAssert.java | 17 +++++------ .../process/ProcessServicesProvider.java | 2 +- .../process/Utils.java | 2 +- .../HistoricProcessInstanceAssertTest.java | 11 ++++--- .../LongRunningProcessInstanceAssertTest.java | 2 +- .../process/ProcessInstanceAssertTest.java | 29 +++++++++---------- .../process/TestUtils.java | 2 +- 9 files changed, 38 insertions(+), 43 deletions(-) rename modules/flowable-assertj/src/main/java/org/flowable/{assertions => assertj}/process/FlowableProcessAssertions.java (96%) rename modules/flowable-assertj/src/main/java/org/flowable/{assertions => assertj}/process/HistoricProcessInstanceAssert.java (89%) rename modules/flowable-assertj/src/main/java/org/flowable/{assertions => assertj}/process/ProcessInstanceAssert.java (89%) rename modules/flowable-assertj/src/main/java/org/flowable/{assertions => assertj}/process/ProcessServicesProvider.java (96%) rename modules/flowable-assertj/src/main/java/org/flowable/{assertions => assertj}/process/Utils.java (97%) rename modules/flowable-assertj/src/test/java/org/flowable/{assertions => assertj}/process/HistoricProcessInstanceAssertTest.java (93%) rename modules/flowable-assertj/src/test/java/org/flowable/{assertions => assertj}/process/LongRunningProcessInstanceAssertTest.java (98%) rename modules/flowable-assertj/src/test/java/org/flowable/{assertions => assertj}/process/ProcessInstanceAssertTest.java (92%) rename modules/flowable-assertj/src/test/java/org/flowable/{assertions => assertj}/process/TestUtils.java (95%) diff --git a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/FlowableProcessAssertions.java similarity index 96% rename from modules/flowable-assertj/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertj/process/FlowableProcessAssertions.java index e29a569e347..866fe74a99f 100644 --- a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/FlowableProcessAssertions.java +++ b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/FlowableProcessAssertions.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.assertj.core.api.Assertions; import org.flowable.engine.history.HistoricProcessInstance; diff --git a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/HistoricProcessInstanceAssert.java similarity index 89% rename from modules/flowable-assertj/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertj/process/HistoricProcessInstanceAssert.java index 734e04ca810..d59bcd5b376 100644 --- a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/HistoricProcessInstanceAssert.java +++ b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/HistoricProcessInstanceAssert.java @@ -11,11 +11,9 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import static org.assertj.core.api.Assertions.assertThat; -import static org.flowable.assertions.process.Utils.getProcessDescription; -import static org.flowable.assertions.process.Utils.getProcessEngine; import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.ListAssert; @@ -40,7 +38,7 @@ protected HistoricProcessInstanceAssert(ProcessEngine processEngine, HistoricPro } protected HistoricProcessInstanceAssert(HistoricProcessInstance historicProcessInstance) { - this(getProcessEngine(), historicProcessInstance); + this(Utils.getProcessEngine(), historicProcessInstance); } /** @@ -64,7 +62,7 @@ public HistoricProcessInstanceAssert isFinished() { processExistsInHistory(); if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().finished().processInstanceId(actual.getId()).count() != 1) { - failWithMessage(getProcessDescription(actual) + " to be finished, but is running in history."); + failWithMessage(Utils.getProcessDescription(actual) + " to be finished, but is running in history."); } return this; @@ -87,7 +85,7 @@ public HistoricProcessInstanceAssert hasVariable(String variableName) { processExistsInHistory(); if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 1) { - failWithMessage(getProcessDescription(actual) + " has variable <%s> but variable does not exist in history.", variableName); + failWithMessage(Utils.getProcessDescription(actual) + " has variable <%s> but variable does not exist in history.", variableName); } return this; @@ -102,7 +100,7 @@ public HistoricProcessInstanceAssert doesNotHaveVariable(String variableName) { processExistsInHistory(); if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 0) { - failWithMessage(getProcessDescription(actual)+" does not have variable <%s> but variable exists in history.", variableName); + failWithMessage(Utils.getProcessDescription(actual)+" does not have variable <%s> but variable exists in history.", variableName); } return this; @@ -155,7 +153,7 @@ private void processExistsInHistory() { private void isInHistory() { if (processServicesProvider.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(actual.getId()).count() != 1) { - failWithMessage(getProcessDescription(actual)+"> exists in history but process instance not found."); + failWithMessage(Utils.getProcessDescription(actual)+"> exists in history but process instance not found."); } } diff --git a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessInstanceAssert.java similarity index 89% rename from modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessInstanceAssert.java index d0c3211e165..b134eb071ba 100644 --- a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessInstanceAssert.java +++ b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessInstanceAssert.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.Assertions; @@ -25,8 +25,7 @@ import org.flowable.task.api.Task; import org.flowable.variable.api.persistence.entity.VariableInstance; -import static org.flowable.assertions.process.FlowableProcessAssertions.assertThat; -import static org.flowable.assertions.process.Utils.*; +import static org.flowable.assertj.process.FlowableProcessAssertions.assertThat; /** * @author martin.grofcik @@ -40,7 +39,7 @@ protected ProcessInstanceAssert(ProcessEngine processEngine, ProcessInstance pro } protected ProcessInstanceAssert(ProcessInstance processInstance) { - this(getProcessEngine(), processInstance); + this(Utils.getProcessEngine(), processInstance); } /** @@ -52,7 +51,7 @@ public ProcessInstanceAssert isRunning() { isNotNull(); if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).count() < 1) { - failWithMessage(getProcessDescription(actual)+" to be running but is not.", actual.getId()); + failWithMessage(Utils.getProcessDescription(actual)+" to be running but is not.", actual.getId()); } return this; } @@ -67,7 +66,7 @@ public ProcessInstanceAssert hasVariable(String variableName) { isNotNull(); if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 1) { - failWithMessage(getProcessDescription(actual)+" has variable <%s> but variable does not exist.", variableName); + failWithMessage(Utils.getProcessDescription(actual)+" has variable <%s> but variable does not exist.", variableName); } return this; @@ -98,7 +97,7 @@ public ProcessInstanceAssert doesNotHaveVariable(String variableName) { isNotNull(); if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).variableExists(variableName).count() != 0) { - failWithMessage(getProcessDescription(actual)+" does not have variable <%s> but variable exists.", variableName); + failWithMessage(Utils.getProcessDescription(actual)+" does not have variable <%s> but variable exists.", variableName); } return this; @@ -113,7 +112,7 @@ public ProcessInstanceAssert doesNotExist() { isNotNull(); if (processServicesProvider.getRuntimeService().createProcessInstanceQuery().processInstanceId(actual.getId()).count() != 0) { - failWithMessage(getProcessDescription(actual)+" is finished but instance exists in runtime."); + failWithMessage(Utils.getProcessDescription(actual)+" is finished but instance exists in runtime."); } return this; @@ -178,7 +177,7 @@ public ListAssert identityLinks() { public ListAssert userTasks() { isNotNull(); - return assertThat(getTaskService().createTaskQuery().processInstanceId(actual.getId()).orderByTaskName().asc() + return assertThat(Utils.getTaskService().createTaskQuery().processInstanceId(actual.getId()).orderByTaskName().asc() .includeProcessVariables().includeIdentityLinks().includeTaskLocalVariables().list()); } diff --git a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessServicesProvider.java similarity index 96% rename from modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessServicesProvider.java index 88e0286a32d..5a13ed5ef87 100644 --- a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/ProcessServicesProvider.java +++ b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/ProcessServicesProvider.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.flowable.engine.HistoryService; import org.flowable.engine.ProcessEngine; diff --git a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/Utils.java b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/Utils.java similarity index 97% rename from modules/flowable-assertj/src/main/java/org/flowable/assertions/process/Utils.java rename to modules/flowable-assertj/src/main/java/org/flowable/assertj/process/Utils.java index 9ac75fe8c93..12da07c1e10 100644 --- a/modules/flowable-assertj/src/main/java/org/flowable/assertions/process/Utils.java +++ b/modules/flowable-assertj/src/main/java/org/flowable/assertj/process/Utils.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.flowable.engine.*; import org.flowable.engine.history.HistoricProcessInstance; diff --git a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/HistoricProcessInstanceAssertTest.java similarity index 93% rename from modules/flowable-assertj/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertj/process/HistoricProcessInstanceAssertTest.java index 5a8e62685bc..4db6d14735a 100644 --- a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/HistoricProcessInstanceAssertTest.java +++ b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/HistoricProcessInstanceAssertTest.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.assertj.core.groups.Tuple; import org.flowable.engine.HistoryService; @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.flowable.assertions.process.TestUtils.createOneTaskProcess; /** * @author martin.grofcik @@ -37,7 +36,7 @@ class HistoricProcessInstanceAssertTest { @Test @Deployment(resources = "oneTask.bpmn20.xml") void isFinishedForFinishedProcessInstance(RuntimeService runtimeService, TaskService taskService, HistoryService historyService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.inHistory().activities().extracting(HistoricActivityInstance::getActivityId).contains( @@ -61,7 +60,7 @@ void isFinishedForFinishedProcessInstance(RuntimeService runtimeService, TaskSer @Test @Deployment(resources = "oneTask.bpmn20.xml") void variables(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.as("No variable exists in the process scope.") @@ -92,7 +91,7 @@ void variables(RuntimeService runtimeService, TaskService taskService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void hasVariable(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.as("No variable exists in the process scope.") @@ -108,7 +107,7 @@ void hasVariable(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void doesNotHaveVariable(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.as("No variable exists in the process scope.") diff --git a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/LongRunningProcessInstanceAssertTest.java similarity index 98% rename from modules/flowable-assertj/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertj/process/LongRunningProcessInstanceAssertTest.java index 5ee48c2e162..243b4793fec 100644 --- a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/LongRunningProcessInstanceAssertTest.java +++ b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/LongRunningProcessInstanceAssertTest.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; diff --git a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/ProcessInstanceAssertTest.java similarity index 92% rename from modules/flowable-assertj/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertj/process/ProcessInstanceAssertTest.java index 7241c56704d..c4d09e6aa09 100644 --- a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/ProcessInstanceAssertTest.java +++ b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/ProcessInstanceAssertTest.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.assertj.core.groups.Tuple; import org.flowable.engine.ManagementService; @@ -33,7 +33,6 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.flowable.assertions.process.TestUtils.createOneTaskProcess; /** * @author martin.grofcik @@ -44,7 +43,7 @@ class ProcessInstanceAssertTest { @Test @Deployment(resources = "oneTask.bpmn20.xml") void isRunning(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning(); } @@ -52,7 +51,7 @@ void isRunning(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void isRunningForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).isRunning()) @@ -70,7 +69,7 @@ void isRunningForNull() { @Test @Deployment(resources = "oneTask.bpmn20.xml") void hasVariable(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); @@ -85,7 +84,7 @@ void hasVariable(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void hasVariableForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); @@ -107,7 +106,7 @@ void hasVariableForNull() { @Test @Deployment(resources = "oneTask.bpmn20.xml") void doesNotHaveVariable(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); @@ -121,7 +120,7 @@ void doesNotHaveVariable(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void doesNotHaveVariableForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); runtimeService.setVariable(oneTaskProcess.getId(), "variableName", "variableValue"); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); @@ -140,7 +139,7 @@ void doesNotHaveVariableForNull() { @Test @Deployment(resources = "oneTask.bpmn20.xml") void doesNotExistForRunningInstance(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); assertThatThrownBy(() -> FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist()) .isInstanceOf(AssertionError.class) @@ -150,7 +149,7 @@ void doesNotExistForRunningInstance(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void doesNotExistForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); FlowableProcessAssertions.assertThat(oneTaskProcess).doesNotExist(); @@ -166,7 +165,7 @@ void doesNotExistForNull() { @Test @Deployment(resources = "oneTask.bpmn20.xml") void activitiesForRunningInstance(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); FlowableProcessAssertions.assertThat(oneTaskProcess).activities().extracting(ActivityInstance::getActivityId) .contains("theStart", "theStart-theTask", "theTask"); @@ -175,7 +174,7 @@ void activitiesForRunningInstance(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void activitiesForNonRunningProcess(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); taskService.complete(taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult().getId()); FlowableProcessAssertions.assertThat(oneTaskProcess).activities().isEmpty(); @@ -184,7 +183,7 @@ void activitiesForNonRunningProcess(RuntimeService runtimeService, TaskService t @Test @Deployment(resources = "oneTask.bpmn20.xml") void executions(RuntimeService runtimeService, TaskService taskService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.as("Running process has at least 2 active executions." + @@ -201,7 +200,7 @@ void executions(RuntimeService runtimeService, TaskService taskService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void variables(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.variables().isEmpty(); @@ -229,7 +228,7 @@ void variables(RuntimeService runtimeService) { @Test @Deployment(resources = "oneTask.bpmn20.xml") void identityLinks(RuntimeService runtimeService) { - ProcessInstance oneTaskProcess = createOneTaskProcess(runtimeService); + ProcessInstance oneTaskProcess = TestUtils.createOneTaskProcess(runtimeService); ProcessInstanceAssert assertThatOneTaskProcess = FlowableProcessAssertions.assertThat(oneTaskProcess); assertThatOneTaskProcess.identityLinks().isEmpty(); diff --git a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/TestUtils.java b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/TestUtils.java similarity index 95% rename from modules/flowable-assertj/src/test/java/org/flowable/assertions/process/TestUtils.java rename to modules/flowable-assertj/src/test/java/org/flowable/assertj/process/TestUtils.java index b21aa98b15f..de2fd1e69f3 100644 --- a/modules/flowable-assertj/src/test/java/org/flowable/assertions/process/TestUtils.java +++ b/modules/flowable-assertj/src/test/java/org/flowable/assertj/process/TestUtils.java @@ -11,7 +11,7 @@ * limitations under the License. */ -package org.flowable.assertions.process; +package org.flowable.assertj.process; import org.flowable.engine.RuntimeService; import org.flowable.engine.runtime.ProcessInstance;