use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionSyncTest method testDifferentStates.
@Test
public void testDifferentStates() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition definition = deployment.getDeployedProcessDefinitions().get(0);
List<String> processInstanceIds = helper.startInstances("process1", 1);
Task task = rule.getTaskService().createTaskQuery().singleResult();
rule.getTaskService().complete(task.getId());
List<String> anotherProcessInstanceIds = helper.startInstances("process1", 1);
processInstanceIds.addAll(anotherProcessInstanceIds);
runtimeService.createModification(definition.getId()).startBeforeActivity("user3").processInstanceIds(processInstanceIds).execute();
ActivityInstance updatedTree = null;
String processInstanceId = processInstanceIds.get(0);
updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(definition.getId()).activity("user2").activity("user3").done());
processInstanceId = processInstanceIds.get(1);
updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(definition.getId()).activity("user1").activity("user3").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionSyncTest method testStartBeforeAndCancelAll.
@Test
public void testStartBeforeAndCancelAll() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition definition = deployment.getDeployedProcessDefinitions().get(0);
List<String> processInstanceIds = helper.startInstances("process1", 2);
runtimeService.createModification(definition.getId()).cancelAllForActivity("user1").startBeforeActivity("user2").processInstanceIds(processInstanceIds).execute();
for (String processInstanceId : processInstanceIds) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(definition.getId()).activity("user2").done());
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionSyncTest method testCancelAll.
@Test
public void testCancelAll() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
List<String> processInstanceIds = helper.startInstances("process1", 2);
runtimeService.createModification(processDefinition.getId()).cancelAllForActivity("user1").processInstanceIds(processInstanceIds).execute();
for (String processInstanceId : processInstanceIds) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNull(updatedTree);
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartTransitionAndCancelAll.
@Test
public void executeModificationJobsForStartTransitionAndCancelAll() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
List<String> instances = helper.startInstances("process1", 10);
Batch batch = runtimeService.createModification(processDefinition.getId()).startTransition("seq").cancelAllForActivity("user1").processInstanceIds(instances).executeAsync();
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testIoMappingInvocation.
@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());
}
Aggregations