use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testTransitionInstanceActivityTypePropertyBeforeStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testTransitionInstanceActivityNamePropertyBeforeStartEvent.bpmn20.xml")
@Test
public void testTransitionInstanceActivityTypePropertyBeforeStartEvent() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
// then
TransitionInstance[] instances = tree.getTransitionInstances("start");
TransitionInstance task = instances[0];
assertNotNull(task);
assertNotNull(task.getActivityType());
assertEquals("startEvent", task.getActivityType());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testActivityInstanceTreeForNestedAsyncAfterTask.
@Deployment
@Test
public void testActivityInstanceTreeForNestedAsyncAfterTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").transition("theTask").done());
TransitionInstance asyncAfterTransitionInstance = tree.getChildActivityInstances()[0].getChildTransitionInstances()[0];
String asyncExecutionId = managementService.createJobQuery().singleResult().getExecutionId();
assertEquals(asyncExecutionId, asyncAfterTransitionInstance.getExecutionId());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testTransitionInstanceActivityTypePropertyAfterTask.
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testTransitionInstanceActivityNamePropertyAfterTask.bpmn20.xml")
@Test
public void testTransitionInstanceActivityTypePropertyAfterTask() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
// then
TransitionInstance[] instances = tree.getTransitionInstances("firstServiceTask");
TransitionInstance task = instances[0];
assertNotNull(task);
assertNotNull(task.getActivityType());
assertEquals("serviceTask", task.getActivityType());
instances = tree.getTransitionInstances("secondServiceTask");
task = instances[0];
assertNotNull(task);
assertNotNull(task.getActivityType());
assertEquals("serviceTask", task.getActivityType());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstanceConcurrent.
@Test
public void testMigrateAsyncBeforeTransitionInstanceConcurrent() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
ProcessInstance processInstance = rule.getRuntimeService().createProcessInstanceById(migrationPlan.getSourceProcessDefinitionId()).startBeforeActivity("userTask").startBeforeActivity("userTask").execute();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
TransitionInstance[] transitionInstances = testHelper.snapshotAfterMigration.getActivityTree().getTransitionInstances("userTask");
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("userTask").concurrent().noScope().id(transitionInstances[0].getExecutionId()).up().child("userTask").concurrent().noScope().id(transitionInstances[1].getExecutionId()).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).transition("userTask").transition("userTask").done());
Assert.assertEquals(2, testHelper.snapshotAfterMigration.getJobs().size());
// and it is possible to successfully execute the migrated job
for (Job job : testHelper.snapshotAfterMigration.getJobs()) {
rule.getManagementService().executeJob(job.getId());
testHelper.completeTask("userTask");
}
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testCancelTransitionInstanceTwiceFails.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_ASYNC_BEFORE_TASK_PROCESS)
public void testCancelTransitionInstanceTwiceFails() {
// given there are two transition instances in an inner scope
// and an active activity instance in an outer scope
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedOneTaskProcess").startBeforeActivity("innerTask").startBeforeActivity("innerTask").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
// when i cancel both transition instances
TransitionInstance[] transitionInstances = tree.getTransitionInstances("innerTask");
// this test ensures that the replacedBy link of executions is not followed
// in case the original execution was actually removed/cancelled
String transitionInstanceId = transitionInstances[0].getId();
try {
runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance(transitionInstanceId).cancelTransitionInstance(transitionInstanceId).execute();
fail("should not be possible to cancel the first instance twice");
} catch (NotValidException e) {
assertTextPresentIgnoreCase("Cannot perform instruction: Cancel transition instance '" + transitionInstanceId + "'; Transition instance '" + transitionInstanceId + "' does not exist: transitionInstance is null", e.getMessage());
}
}
Aggregations