Skip to content

Commit

Permalink
Remove wrong tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Nov 17, 2023
1 parent 864acec commit c05123d
Showing 1 changed file with 0 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1342,127 +1342,6 @@ public void testMigrateParallelMultiInstanceTaskWithLocalVariables() {
assertProcessEnded(processInstance.getId());
}

@Test
public void testMigrateParallelMultiInstanceTaskWithLocalVariablesWithMigrationMapping() {
ProcessDefinition startProcessDefinition = deployProcessDefinition("my deploy",
"org/flowable/engine/test/api/runtime/migration/parallel-multi-instance-task-local-variable.bpmn20.xml");

// Start the processInstance
Map<String, Object> variableMap = new HashMap<>();
ArrayNode collectionArray = processEngineConfiguration.getObjectMapper().createArrayNode();
ObjectNode element1Node = collectionArray.addObject();
element1Node.put("name", "John Doe");
element1Node.put("age", 30);
ObjectNode element2Node = collectionArray.addObject();
element2Node.put("name", "Jane Doe");
element2Node.put("age", 29);
variableMap.put("myCollection", collectionArray);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(startProcessDefinition.getId(), variableMap);

// Progress to the MI subProcess
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(task).extracting(Task::getTaskDefinitionKey).isEqualTo("beforeMultiInstance");
completeTask(task);

// Confirm the state to migrate
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().list();
// MI subProcess root execution, actual subProcess and 1 task
assertThat(executions)
.extracting(Execution::getActivityId)
.containsExactly("task", "task", "task");
assertThat(executions)
.extracting("processDefinitionId")
.containsOnly(startProcessDefinition.getId());
Execution miRoot = executions.stream().filter(e -> ((ExecutionEntity) e).isMultiInstanceRoot()).findFirst().get();
Map<String, Object> miRootVars = runtimeService.getVariables(miRoot.getId());
assertThat(miRootVars)
.extracting("nrOfActiveInstances", "nrOfCompletedInstances")
.containsExactly(2, 0);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertThat(tasks)
.extracting(Task::getTaskDefinitionKey)
.containsOnly("task");
assertThat(tasks)
.extracting(Task::getProcessDefinitionId)
.containsOnly(startProcessDefinition.getId());
assertThat(tasks)
.extracting(Task::getAssignee)
.containsOnly("kermit");
List<Integer> loopCounters = tasks.stream().map(aTask -> taskService.getVariable(aTask.getId(), "loopCounter", Integer.class))
.collect(Collectors.toList());
assertThat(loopCounters).containsExactlyInAnyOrder(0, 1);

for (Task miTask : tasks) {
Execution execution = runtimeService.createExecutionQuery().executionId(miTask.getExecutionId()).singleResult();
runtimeService.setVariableLocal(execution.getId(), "localVar", "test");
taskService.setAssignee(miTask.getId(), "othervalue");
}

tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertThat(tasks)
.extracting(Task::getAssignee)
.containsOnly("othervalue");

ProcessDefinition migrateToProcessDefinition = deployProcessDefinition("my deploy",
"org/flowable/engine/test/api/runtime/migration/parallel-multi-instance-task-local-variable.bpmn20.xml");

// Prepare and action the migration
ProcessInstanceMigrationBuilder processInstanceMigrationBuilder = processMigrationService.createProcessInstanceMigrationBuilder()
.migrateToProcessDefinition(migrateToProcessDefinition.getId())
.addActivityMigrationMapping(ActivityMigrationMapping.createMappingFor("task", "task"));
ProcessInstanceMigrationValidationResult processInstanceMigrationValidationResult = processInstanceMigrationBuilder
.validateMigration(processInstance.getId());
assertThat(processInstanceMigrationValidationResult.isMigrationValid()).isTrue();
processInstanceMigrationBuilder.migrate(processInstance.getId());

//Confirm
executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().list();
assertThat(executions).hasSize(3);
assertThat(executions)
.extracting(Execution::getActivityId)
.containsExactly("task", "task", "task");
assertThat(executions)
.extracting("processDefinitionId")
.containsOnly(migrateToProcessDefinition.getId());

tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertThat(tasks).hasSize(2);
assertThat(tasks)
.extracting(Task::getTaskDefinitionKey)
.containsOnly("task");
assertThat(tasks)
.extracting(Task::getProcessDefinitionId)
.containsOnly(migrateToProcessDefinition.getId());
assertThat(tasks)
.extracting(Task::getAssignee)
.containsOnly("kermit");
loopCounters = tasks.stream().map(aTask -> taskService.getVariable(aTask.getId(), "loopCounter", Integer.class))
.collect(Collectors.toList());
assertThat(loopCounters).containsExactlyInAnyOrder(0, 1);

for (Task miTask : tasks) {
Execution execution = runtimeService.createExecutionQuery().executionId(miTask.getExecutionId()).singleResult();
assertThat(runtimeService.getVariableLocal(execution.getId(), "localVar")).isEqualTo("test");
}

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(migrateToProcessDefinition, processInstance, "userTask", "beforeMultiInstance", "task", "task");

checkTaskInstance(migrateToProcessDefinition, processInstance, "beforeMultiInstance", "task", "task", "task", "task");
}

// Complete the process
completeProcessInstanceTasks(processInstance.getId());

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(migrateToProcessDefinition, processInstance, "userTask", "beforeMultiInstance", "task", "task", "afterMultiInstance");

checkTaskInstance(migrateToProcessDefinition, processInstance, "beforeMultiInstance", "task", "task", "task", "task", "afterMultiInstance");
}

assertProcessEnded(processInstance.getId());
}

@Test
public void testMigrateParallelMultiInstanceSubProcessWithLocalVariables() {
ProcessDefinition startProcessDefinition = deployProcessDefinition("my deploy",
Expand Down Expand Up @@ -1571,115 +1450,6 @@ public void testMigrateParallelMultiInstanceSubProcessWithLocalVariables() {
assertProcessEnded(processInstance.getId());
}

@Test
public void testMigrateParallelMultiInstanceSubProcessWithLocalVariablesWithMigrationMapping() {
ProcessDefinition startProcessDefinition = deployProcessDefinition("my deploy",
"org/flowable/engine/test/api/runtime/migration/parallel-multi-instance-subprocess-local-variable.bpmn20.xml");

// Start the processInstance
Map<String, Object> variableMap = new HashMap<>();
ArrayNode collectionArray = processEngineConfiguration.getObjectMapper().createArrayNode();
ObjectNode element1Node = collectionArray.addObject();
element1Node.put("name", "John Doe");
element1Node.put("age", 30);
ObjectNode element2Node = collectionArray.addObject();
element2Node.put("name", "Jane Doe");
element2Node.put("age", 29);
variableMap.put("myCollection", collectionArray);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(startProcessDefinition.getId(), variableMap);

// Progress to the MI subProcess
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(task).extracting(Task::getTaskDefinitionKey).isEqualTo("beforeMultiInstance");
completeTask(task);

// Confirm the state to migrate
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().list();
// MI subProcess root execution, actual subProcess and 1 task
assertThat(executions)
.extracting(Execution::getActivityId)
.containsExactly("parallelMISubProcess", "parallelMISubProcess", "parallelMISubProcess", "subTask1", "subTask1");
assertThat(executions)
.extracting("processDefinitionId")
.containsOnly(startProcessDefinition.getId());
Execution miRoot = executions.stream().filter(e -> ((ExecutionEntity) e).isMultiInstanceRoot()).findFirst().get();
Map<String, Object> miRootVars = runtimeService.getVariables(miRoot.getId());
assertThat(miRootVars)
.extracting("nrOfActiveInstances", "nrOfCompletedInstances")
.containsExactly(2, 0);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertThat(tasks)
.extracting(Task::getTaskDefinitionKey)
.containsOnly("subTask1");
assertThat(tasks)
.extracting(Task::getProcessDefinitionId)
.containsOnly(startProcessDefinition.getId());
List<Integer> loopCounters = tasks.stream().map(aTask -> taskService.getVariable(aTask.getId(), "loopCounter", Integer.class))
.collect(Collectors.toList());
assertThat(loopCounters).containsExactlyInAnyOrder(0, 1);

for (Task miTask : tasks) {
Execution execution = runtimeService.createExecutionQuery().executionId(miTask.getExecutionId()).singleResult();
runtimeService.setVariableLocal(execution.getId(), "localVar", "test");
}

ProcessDefinition migrateToProcessDefinition = deployProcessDefinition("my deploy",
"org/flowable/engine/test/api/runtime/migration/parallel-multi-instance-subprocess-local-variable.bpmn20.xml");

// Prepare and action the migration
ProcessInstanceMigrationBuilder processInstanceMigrationBuilder = processMigrationService.createProcessInstanceMigrationBuilder()
.migrateToProcessDefinition(migrateToProcessDefinition.getId())
.addActivityMigrationMapping(ActivityMigrationMapping.createMappingFor("subTask1", "subTask1"));
ProcessInstanceMigrationValidationResult processInstanceMigrationValidationResult = processInstanceMigrationBuilder
.validateMigration(processInstance.getId());
assertThat(processInstanceMigrationValidationResult.isMigrationValid()).isTrue();
processInstanceMigrationBuilder.migrate(processInstance.getId());

//Confirm
executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().list();
assertThat(executions).hasSize(5);
assertThat(executions)
.extracting(Execution::getActivityId)
.containsExactly("parallelMISubProcess", "parallelMISubProcess", "parallelMISubProcess", "subTask1", "subTask1");
assertThat(executions)
.extracting("processDefinitionId")
.containsOnly(migrateToProcessDefinition.getId());

tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertThat(tasks).hasSize(2);
assertThat(tasks)
.extracting(Task::getTaskDefinitionKey)
.containsOnly("subTask1");
assertThat(tasks)
.extracting(Task::getProcessDefinitionId)
.containsOnly(migrateToProcessDefinition.getId());
loopCounters = tasks.stream().map(aTask -> taskService.getVariable(aTask.getId(), "loopCounter", Integer.class))
.collect(Collectors.toList());
assertThat(loopCounters).containsExactlyInAnyOrder(0, 1);

for (Task miTask : tasks) {
Execution execution = runtimeService.createExecutionQuery().executionId(miTask.getExecutionId()).singleResult();
assertThat(runtimeService.getVariableLocal(execution.getId(), "localVar")).isEqualTo("test");
}

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(migrateToProcessDefinition, processInstance, "userTask", "beforeMultiInstance", "subTask1", "subTask1", "subTask1", "subTask1");

checkTaskInstance(migrateToProcessDefinition, processInstance, "beforeMultiInstance", "subTask1", "subTask1", "subTask1", "subTask1");
}

// Complete the process
completeProcessInstanceTasks(processInstance.getId());

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(migrateToProcessDefinition, processInstance, "userTask", "beforeMultiInstance", "subTask1", "subTask1", "subTask1", "subTask1", "afterMultiInstance");

checkTaskInstance(migrateToProcessDefinition, processInstance, "beforeMultiInstance", "subTask1", "subTask1", "subTask1", "subTask1", "afterMultiInstance");
}

assertProcessEnded(processInstance.getId());
}

@Test
public void testMigrateParallelMultiInstanceServiceTaskWithLocalVariables() {
ProcessDefinition startProcessDefinition = deployProcessDefinition("my deploy",
Expand Down

0 comments on commit c05123d

Please sign in to comment.