Search in sources :

Example 11 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 12 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 15 with TransitionInstance

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());
    }
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) NotValidException(org.camunda.bpm.engine.exception.NotValidException) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)34 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)31 Deployment (org.camunda.bpm.engine.test.Deployment)27 Test (org.junit.Test)21 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)20 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)19 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)5 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)5 Task (org.camunda.bpm.engine.task.Task)4 NotValidException (org.camunda.bpm.engine.exception.NotValidException)3 Job (org.camunda.bpm.engine.runtime.Job)3 ArrayList (java.util.ArrayList)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1