public void assertVariableMigratedToExecution(VariableInstance variableBefore, String executionId) { assertVariableMigratedToExecution(variableBefore, executionId, variableBefore.getActivityInstanceId()); }
protected <T extends VariableInstance> T build(T mockVariable) { when(mockVariable.getId()).thenReturn(id); when(mockVariable.getName()).thenReturn(name); when(mockVariable.getTypeName()).thenReturn(typedValue.getType().getName()); if (ObjectValue.class.isAssignableFrom(typedValue.getClass())) { ObjectValue objectValue = (ObjectValue) typedValue; if (objectValue.isDeserialized()) { when(mockVariable.getValue()).thenReturn(typedValue.getValue()); } else { when(mockVariable.getValue()).thenReturn(null); } } else { when(mockVariable.getValue()).thenReturn(typedValue.getValue()); } when(mockVariable.getTypedValue()).thenReturn(typedValue); when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId); when(mockVariable.getExecutionId()).thenReturn(executionId); when(mockVariable.getCaseInstanceId()).thenReturn(caseInstanceId); when(mockVariable.getCaseExecutionId()).thenReturn(caseExecutionId); when(mockVariable.getTaskId()).thenReturn(taskId); when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId); when(mockVariable.getTenantId()).thenReturn(tenantId); when(mockVariable.getErrorMessage()).thenReturn(errorMessage); return mockVariable; }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.getId(); delegateInstance.processInstanceId = variableInstance.getProcessInstanceId(); delegateInstance.executionId = variableInstance.getExecutionId(); delegateInstance.caseExecutionId = variableInstance.getCaseExecutionId(); delegateInstance.caseInstanceId = variableInstance.getCaseInstanceId(); delegateInstance.taskId = variableInstance.getTaskId(); delegateInstance.activityInstanceId = variableInstance.getActivityInstanceId(); delegateInstance.tenantId = variableInstance.getTenantId(); delegateInstance.errorMessage = variableInstance.getErrorMessage(); delegateInstance.name = variableInstance.getName(); delegateInstance.value = variableInstance.getTypedValue(); return delegateInstance; }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.getId(); delegateInstance.processInstanceId = variableInstance.getProcessInstanceId(); delegateInstance.executionId = variableInstance.getExecutionId(); delegateInstance.caseExecutionId = variableInstance.getCaseExecutionId(); delegateInstance.caseInstanceId = variableInstance.getCaseInstanceId(); delegateInstance.taskId = variableInstance.getTaskId(); delegateInstance.activityInstanceId = variableInstance.getActivityInstanceId(); delegateInstance.tenantId = variableInstance.getTenantId(); delegateInstance.errorMessage = variableInstance.getErrorMessage(); delegateInstance.name = variableInstance.getName(); delegateInstance.value = variableInstance.getTypedValue(); return delegateInstance; }
@Deployment public void testParallelMultiInstanceSubProcess() { // given a process instance in sequential MI ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess"); // when VariableInstance nrOfInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfInstances").singleResult(); VariableInstance nrOfActiveInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfActiveInstances").singleResult(); VariableInstance nrOfCompletedInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfCompletedInstances").singleResult(); List<VariableInstance> loopCounters = runtimeService.createVariableInstanceQuery() .variableName("loopCounter").list(); // then the activity instance ids of the variable instances should be correct ActivityInstance tree = runtimeService.getActivityInstance(instance.getId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfActiveInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfCompletedInstances.getActivityInstanceId()); Set<String> loopCounterActivityInstanceIds = new HashSet<String>(); for (VariableInstance loopCounter : loopCounters) { loopCounterActivityInstanceIds.add(loopCounter.getActivityInstanceId()); } assertEquals(4, loopCounterActivityInstanceIds.size()); for (ActivityInstance subProcessInstance : tree.getActivityInstances("miSubProcess")) { assertTrue(loopCounterActivityInstanceIds.contains(subProcessInstance.getId())); } }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.getId(); dto.name = variableInstance.getName(); dto.processInstanceId = variableInstance.getProcessInstanceId(); dto.executionId = variableInstance.getExecutionId(); dto.caseExecutionId = variableInstance.getCaseExecutionId(); dto.caseInstanceId = variableInstance.getCaseInstanceId(); dto.taskId = variableInstance.getTaskId(); dto.activityInstanceId = variableInstance.getActivityInstanceId(); dto.tenantId = variableInstance.getTenantId(); if(variableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, variableInstance.getTypedValue()); } else { dto.errorMessage = variableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(variableInstance.getTypeName()); } return dto; }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.getId(); dto.name = variableInstance.getName(); dto.processInstanceId = variableInstance.getProcessInstanceId(); dto.executionId = variableInstance.getExecutionId(); dto.caseExecutionId = variableInstance.getCaseExecutionId(); dto.caseInstanceId = variableInstance.getCaseInstanceId(); dto.taskId = variableInstance.getTaskId(); dto.activityInstanceId = variableInstance.getActivityInstanceId(); dto.tenantId = variableInstance.getTenantId(); if(variableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, variableInstance.getTypedValue()); } else { dto.errorMessage = variableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(variableInstance.getTypeName()); } return dto; }
@Deployment public void testSequentialMultiInstanceSubProcess() { // given a process instance in sequential MI ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess"); // when VariableInstance nrOfInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfInstances").singleResult(); VariableInstance nrOfActiveInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfActiveInstances").singleResult(); VariableInstance nrOfCompletedInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfCompletedInstances").singleResult(); VariableInstance loopCounter = runtimeService.createVariableInstanceQuery() .variableName("loopCounter").singleResult(); // then the activity instance ids of the variable instances should be correct ActivityInstance tree = runtimeService.getActivityInstance(instance.getId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfActiveInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfCompletedInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), loopCounter.getActivityInstanceId()); }
@Deployment public void testScopeActivityInstanceId() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId); ActivityInstance theTaskInstance = tree.getActivityInstances("theTask")[0]; // when VariableInstance variableInstance = runtimeService .createVariableInstanceQuery() .singleResult(); // then assertEquals(theTaskInstance.getId(), variableInstance.getActivityInstanceId()); }
public void assertVariableMigratedToExecution(VariableInstance variableBefore, String executionId) { assertVariableMigratedToExecution(variableBefore, executionId, variableBefore.getActivityInstanceId()); }
@Test public void testIoMappingInvocation() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(instance) .activityBuilder("user1") .camundaInputParameter("foo", "bar") .done() ); ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId()); Batch batch = runtimeService .createModification(processDefinition.getId()) .startAfterActivity("user2") .processInstanceIds(Arrays.asList(processInstance.getId())) .executeAsync(); helper.executeSeedJob(batch); // when helper.executeJobs(batch); // then VariableInstance inputVariable = runtimeService.createVariableInstanceQuery().singleResult(); Assert.assertNotNull(inputVariable); assertEquals("foo", inputVariable.getName()); assertEquals("bar", inputVariable.getValue()); ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId()); assertEquals(activityInstance.getActivityInstances("user1")[0].getId(), inputVariable.getActivityInstanceId()); }
@Test public void testIoMappingInvocationForRemovedScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .activityBuilder("subProcess") .camundaOutputParameter("foo", "bar") .done()); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); // when ProcessInstance processInstance = rule.getRuntimeService() .startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId()); rule.getRuntimeService() .newMigration(migrationPlan) .processInstanceIds(Arrays.asList(processInstance.getId())) .execute(); // then VariableInstance inputVariable = rule.getRuntimeService().createVariableInstanceQuery().singleResult(); Assert.assertNotNull(inputVariable); assertEquals("foo", inputVariable.getName()); assertEquals("bar", inputVariable.getValue()); assertEquals(processInstance.getId(), inputVariable.getActivityInstanceId()); }
@Test public void testIoMappingInvocationForNewlyCreatedScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .activityBuilder("subProcess") .camundaInputParameter("foo", "bar") .done() ); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); // when ProcessInstance processInstance = rule.getRuntimeService() .startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId()); rule.getRuntimeService() .newMigration(migrationPlan) .processInstanceIds(Arrays.asList(processInstance.getId())) .execute(); // then VariableInstance inputVariable = rule.getRuntimeService().createVariableInstanceQuery().singleResult(); Assert.assertNotNull(inputVariable); assertEquals("foo", inputVariable.getName()); assertEquals("bar", inputVariable.getValue()); ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId()); assertEquals(activityInstance.getActivityInstances("subProcess")[0].getId(), inputVariable.getActivityInstanceId()); }
@Test public void testIoMappingInvocationForNewlyCreatedScope() { // given ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .activityBuilder("subProcess") .camundaInputParameter("foo", "bar") .done() ); MigrationPlan migrationPlan = engineRule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId()); Batch batch = engineRule.getRuntimeService().newMigration(migrationPlan) .processInstanceIds(Arrays.asList(processInstance.getId())) .executeAsync(); helper.executeSeedJob(batch); // when helper.executeJobs(batch); // then VariableInstance inputVariable = engineRule.getRuntimeService().createVariableInstanceQuery().singleResult(); Assert.assertNotNull(inputVariable); assertEquals("foo", inputVariable.getName()); assertEquals("bar", inputVariable.getValue()); ActivityInstance activityInstance = engineRule.getRuntimeService().getActivityInstance(processInstance.getId()); assertEquals(activityInstance.getActivityInstances("subProcess")[0].getId(), inputVariable.getActivityInstanceId()); }
public void assertVariableMigratedToExecution(VariableInstance variableBefore, String executionId, String activityInstanceId) { VariableInstance variableAfter = snapshotAfterMigration.getVariable(variableBefore.getId()); Assert.assertNotNull("Variable with id " + variableBefore.getId() + " does not exist", variableAfter); Assert.assertEquals(activityInstanceId, variableAfter.getActivityInstanceId()); Assert.assertEquals(variableBefore.getCaseExecutionId(), variableAfter.getCaseExecutionId()); Assert.assertEquals(variableBefore.getCaseInstanceId(), variableAfter.getCaseInstanceId()); Assert.assertEquals(variableBefore.getErrorMessage(), variableAfter.getErrorMessage()); Assert.assertEquals(executionId, variableAfter.getExecutionId()); Assert.assertEquals(variableBefore.getId(), variableAfter.getId()); Assert.assertEquals(variableBefore.getName(), variableAfter.getName()); Assert.assertEquals(variableBefore.getProcessInstanceId(), variableAfter.getProcessInstanceId()); Assert.assertEquals(variableBefore.getTaskId(), variableAfter.getTaskId()); Assert.assertEquals(variableBefore.getTenantId(), variableAfter.getTenantId()); Assert.assertEquals(variableBefore.getTypeName(), variableAfter.getTypeName()); Assert.assertEquals(variableBefore.getValue(), variableAfter.getValue()); }
public static DelegateCaseVariableInstanceImpl fromVariableInstance(VariableInstance variableInstance) { DelegateCaseVariableInstanceImpl delegateInstance = new DelegateCaseVariableInstanceImpl(); delegateInstance.variableId = variableInstance.getId(); delegateInstance.processInstanceId = variableInstance.getProcessInstanceId(); delegateInstance.executionId = variableInstance.getExecutionId(); delegateInstance.caseExecutionId = variableInstance.getCaseExecutionId(); delegateInstance.caseInstanceId = variableInstance.getCaseInstanceId(); delegateInstance.taskId = variableInstance.getTaskId(); delegateInstance.activityInstanceId = variableInstance.getActivityInstanceId(); delegateInstance.tenantId = variableInstance.getTenantId(); delegateInstance.errorMessage = variableInstance.getErrorMessage(); delegateInstance.name = variableInstance.getName(); delegateInstance.value = variableInstance.getTypedValue(); return delegateInstance; }
@Deployment public void testSequentialMultiInstanceSubProcess() { // given a process instance in sequential MI ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess"); // when VariableInstance nrOfInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfInstances").singleResult(); VariableInstance nrOfActiveInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfActiveInstances").singleResult(); VariableInstance nrOfCompletedInstances = runtimeService.createVariableInstanceQuery() .variableName("nrOfCompletedInstances").singleResult(); VariableInstance loopCounter = runtimeService.createVariableInstanceQuery() .variableName("loopCounter").singleResult(); // then the activity instance ids of the variable instances should be correct ActivityInstance tree = runtimeService.getActivityInstance(instance.getId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfActiveInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), nrOfCompletedInstances.getActivityInstanceId()); assertEquals(tree.getActivityInstances("miSubProcess#multiInstanceBody")[0].getId(), loopCounter.getActivityInstanceId()); }
public static VariableInstanceDto fromVariableInstance(VariableInstance variableInstance) { VariableInstanceDto dto = new VariableInstanceDto(); dto.id = variableInstance.getId(); dto.name = variableInstance.getName(); dto.processInstanceId = variableInstance.getProcessInstanceId(); dto.executionId = variableInstance.getExecutionId(); dto.caseExecutionId = variableInstance.getCaseExecutionId(); dto.caseInstanceId = variableInstance.getCaseInstanceId(); dto.taskId = variableInstance.getTaskId(); dto.activityInstanceId = variableInstance.getActivityInstanceId(); dto.tenantId = variableInstance.getTenantId(); if(variableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, variableInstance.getTypedValue()); } else { dto.errorMessage = variableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(variableInstance.getTypeName()); } return dto; }
@Deployment public void testScopeActivityInstanceId() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId); ActivityInstance theTaskInstance = tree.getActivityInstances("theTask")[0]; // when VariableInstance variableInstance = runtimeService .createVariableInstanceQuery() .singleResult(); // then assertEquals(theTaskInstance.getId(), variableInstance.getActivityInstanceId()); }
public void assertVariableMigratedToExecution(VariableInstance variableBefore, String executionId, String activityInstanceId) { VariableInstance variableAfter = snapshotAfterMigration.getVariable(variableBefore.getId()); Assert.assertNotNull("Variable with id " + variableBefore.getId() + " does not exist", variableAfter); Assert.assertEquals(activityInstanceId, variableAfter.getActivityInstanceId()); Assert.assertEquals(variableBefore.getCaseExecutionId(), variableAfter.getCaseExecutionId()); Assert.assertEquals(variableBefore.getCaseInstanceId(), variableAfter.getCaseInstanceId()); Assert.assertEquals(variableBefore.getErrorMessage(), variableAfter.getErrorMessage()); Assert.assertEquals(executionId, variableAfter.getExecutionId()); Assert.assertEquals(variableBefore.getId(), variableAfter.getId()); Assert.assertEquals(variableBefore.getName(), variableAfter.getName()); Assert.assertEquals(variableBefore.getProcessInstanceId(), variableAfter.getProcessInstanceId()); Assert.assertEquals(variableBefore.getTaskId(), variableAfter.getTaskId()); Assert.assertEquals(variableBefore.getTenantId(), variableAfter.getTenantId()); Assert.assertEquals(variableBefore.getTypeName(), variableAfter.getTypeName()); Assert.assertEquals(variableBefore.getValue(), variableAfter.getValue()); }