Search in sources :

Example 21 with TransitionInstance

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

the class ActivityInstanceImpl method writeTree.

protected void writeTree(StringWriter writer, String prefix, boolean isTail) {
    writer.append(prefix);
    if (isTail) {
        writer.append("└── ");
    } else {
        writer.append("├── ");
    }
    writer.append(getActivityId() + "=>" + getId() + "\n");
    for (int i = 0; i < childTransitionInstances.length; i++) {
        TransitionInstance transitionInstance = childTransitionInstances[i];
        boolean transitionIsTail = (i == (childTransitionInstances.length - 1)) && (childActivityInstances.length == 0);
        writeTransition(transitionInstance, writer, prefix + (isTail ? "    " : "│   "), transitionIsTail);
    }
    for (int i = 0; i < childActivityInstances.length; i++) {
        ActivityInstanceImpl child = (ActivityInstanceImpl) childActivityInstances[i];
        child.writeTree(writer, prefix + (isTail ? "    " : "│   "), (i == (childActivityInstances.length - 1)));
    }
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance)

Example 22 with TransitionInstance

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

the class JobPrioritizationTest method testPriorityOnModification.

@Test
public void testPriorityOnModification() {
    // given
    processInstance = runtimeService.startProcessInstanceByKey("serviceTaskProcess");
    TransitionInstance transitionInstance = runtimeService.getActivityInstance(processInstance.getId()).getTransitionInstances("serviceTask")[0];
    // when
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("serviceTask").cancelTransitionInstance(transitionInstance.getId()).execute();
    // then
    Job job = managementService.createJobQuery().singleResult();
    Assert.assertEquals(PriorityBean.PRIORITY, job.getPriority());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 23 with TransitionInstance

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

the class ProcessInstanceModificationAsyncTest method testCancelTransitionInstanceTwiceFailsCase2.

/**
 * CAM-4090
 */
@Deployment(resources = NESTED_ASYNC_BEFORE_TASK_PROCESS)
public void testCancelTransitionInstanceTwiceFailsCase2() {
    // 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");
    try {
        runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance(// compacts the tree;
        transitionInstances[0].getId()).startBeforeActivity(// expand tree again
        "innerTask").startBeforeActivity("innerTask").cancelTransitionInstance(// does not trigger compaction
        transitionInstances[1].getId()).cancelTransitionInstance(// should fail
        transitionInstances[1].getId()).execute();
        fail("should not be possible to cancel the first instance twice");
    } catch (NotValidException e) {
        String transitionInstanceId = transitionInstances[1].getId();
        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)

Example 24 with TransitionInstance

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

the class RuntimeServiceTest method testTransitionInstanceActivityNamePropertyAfterStartEvent.

@Deployment
@Test
public void testTransitionInstanceActivityNamePropertyAfterStartEvent() {
    // 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 25 with TransitionInstance

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

the class RuntimeServiceTest method testActivityInstanceTreeForConcurrentAsyncBeforeTask.

@Deployment
@Test
public void testActivityInstanceTreeForConcurrentAsyncBeforeTask() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("concurrentTasksProcess");
    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) 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)

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