Search in sources :

Example 26 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testTransitionInstanceActivityNamePropertyBeforeStartEvent.

@Deployment
@Test
public void testTransitionInstanceActivityNamePropertyBeforeStartEvent() {
    // 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.getActivityName());
    assertEquals("The Start Event", task.getActivityName());
}
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 27 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testGetTransitionInstancesForActivity.

@Deployment
@Test
public void testGetTransitionInstancesForActivity() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSubprocess");
    // complete one async task
    Job job = managementService.createJobQuery().listPage(0, 1).get(0);
    managementService.executeJob(job.getId());
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());
    // when
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    // then
    assertEquals(0, tree.getTransitionInstances("subProcess").length);
    TransitionInstance[] asyncBeforeInstances = tree.getTransitionInstances("innerTask");
    assertEquals(2, asyncBeforeInstances.length);
    assertEquals("innerTask", asyncBeforeInstances[0].getActivityId());
    assertEquals("innerTask", asyncBeforeInstances[1].getActivityId());
    assertFalse(asyncBeforeInstances[0].getId().equals(asyncBeforeInstances[1].getId()));
    TransitionInstance[] asyncEndEventInstances = tree.getTransitionInstances("theSubProcessEnd");
    assertEquals(1, asyncEndEventInstances.length);
    assertEquals("theSubProcessEnd", asyncEndEventInstances[0].getActivityId());
}
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) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 28 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testActivityInstanceTreeForConcurrentAsyncAfterTask.

@Deployment
@Test
public void testActivityInstanceTreeForConcurrentAsyncAfterTask() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("concurrentTasksProcess");
    Task asyncTask = taskService.createTaskQuery().taskDefinitionKey("asyncTask").singleResult();
    assertNotNull(asyncTask);
    taskService.complete(asyncTask.getId());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").transition("asyncTask").done());
    TransitionInstance asyncBeforeTransitionInstance = tree.getChildTransitionInstances()[0];
    String asyncExecutionId = managementService.createJobQuery().singleResult().getExecutionId();
    assertEquals(asyncExecutionId, asyncBeforeTransitionInstance.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 29 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testActivityInstanceTreeForNestedAsyncAfterEndEvent.

@Deployment
@Test
public void testActivityInstanceTreeForNestedAsyncAfterEndEvent() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncEndEventProcess");
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").transition("theSubProcessEnd").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) 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 30 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testTransitionInstanceActivityNamePropertyBeforeTask.

@Deployment
@Test
public void testTransitionInstanceActivityNamePropertyBeforeTask() {
    // 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.getActivityName());
    assertEquals("First Service Task", task.getActivityName());
    instances = tree.getTransitionInstances("secondServiceTask");
    task = instances[0];
    assertNotNull(task);
    assertNotNull(task.getActivityName());
    assertEquals("Second Service Task", task.getActivityName());
}
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)

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