Search in sources :

Example 1 with Execution

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

the class ExecutionRestServiceQueryTest method createIncompleteMockExecutions.

private List<Execution> createIncompleteMockExecutions() {
    List<Execution> mocks = new ArrayList<Execution>();
    Execution mockExecution = mock(Execution.class);
    when(mockExecution.getId()).thenReturn(MockProvider.EXAMPLE_EXECUTION_ID);
    mocks.add(mockExecution);
    return mocks;
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ArrayList(java.util.ArrayList)

Example 2 with Execution

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

the class MockProvider method createMockExecution.

public static Execution createMockExecution(String tenantId) {
    Execution mock = mock(Execution.class);
    when(mock.getId()).thenReturn(EXAMPLE_EXECUTION_ID);
    when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
    when(mock.isEnded()).thenReturn(EXAMPLE_EXECUTION_IS_ENDED);
    when(mock.getTenantId()).thenReturn(tenantId);
    return mock;
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Execution(org.camunda.bpm.engine.runtime.Execution)

Example 3 with Execution

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

the class ExecutionResourceImpl method getExecution.

@Override
public ExecutionDto getExecution() {
    RuntimeService runtimeService = engine.getRuntimeService();
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    if (execution == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Execution with id " + executionId + " does not exist");
    }
    return ExecutionDto.fromExecution(execution);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) RuntimeService(org.camunda.bpm.engine.RuntimeService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 4 with Execution

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

the class ProcessInstanceQueryTest method testQueryVariablesUpdatedToNullValue.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryVariablesUpdatedToNullValue() {
    // Start process instance with different types of variables
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("longVar", 928374L);
    variables.put("shortVar", (short) 123);
    variables.put("integerVar", 1234);
    variables.put("stringVar", "coca-cola");
    variables.put("dateVar", new Date());
    variables.put("booleanVar", true);
    variables.put("nullVar", null);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().variableValueEquals("longVar", null).variableValueEquals("shortVar", null).variableValueEquals("integerVar", null).variableValueEquals("stringVar", null).variableValueEquals("booleanVar", null).variableValueEquals("dateVar", null);
    ProcessInstanceQuery notQuery = runtimeService.createProcessInstanceQuery().variableValueNotEquals("longVar", null).variableValueNotEquals("shortVar", null).variableValueNotEquals("integerVar", null).variableValueNotEquals("stringVar", null).variableValueNotEquals("booleanVar", null).variableValueNotEquals("dateVar", null);
    assertNull(query.singleResult());
    assertNotNull(notQuery.singleResult());
    // Set all existing variables values to null
    runtimeService.setVariable(processInstance.getId(), "longVar", null);
    runtimeService.setVariable(processInstance.getId(), "shortVar", null);
    runtimeService.setVariable(processInstance.getId(), "integerVar", null);
    runtimeService.setVariable(processInstance.getId(), "stringVar", null);
    runtimeService.setVariable(processInstance.getId(), "dateVar", null);
    runtimeService.setVariable(processInstance.getId(), "nullVar", null);
    runtimeService.setVariable(processInstance.getId(), "booleanVar", null);
    Execution queryResult = query.singleResult();
    assertNotNull(queryResult);
    assertEquals(processInstance.getId(), queryResult.getId());
    assertNull(notQuery.singleResult());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) Execution(org.camunda.bpm.engine.runtime.Execution) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Date(java.util.Date) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with Execution

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

the class RuntimeServiceTest method testFindActiveActivityIdProcessWithErrorEventAndSubProcess.

/**
 * Testcase to reproduce ACT-950 (https://jira.codehaus.org/browse/ACT-950)
 */
@Deployment
@Test
public void testFindActiveActivityIdProcessWithErrorEventAndSubProcess() {
    ProcessInstance processInstance = engineRule.getProcessEngine().getRuntimeService().startProcessInstanceByKey("errorEventSubprocess");
    List<String> activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
    assertEquals(3, activeActivities.size());
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(2, tasks.size());
    Task parallelUserTask = null;
    for (Task task : tasks) {
        if (!task.getName().equals("ParallelUserTask") && !task.getName().equals("MainUserTask")) {
            fail("Expected: <ParallelUserTask> or <MainUserTask> but was <" + task.getName() + ">.");
        }
        if (task.getName().equals("ParallelUserTask")) {
            parallelUserTask = task;
        }
    }
    assertNotNull(parallelUserTask);
    taskService.complete(parallelUserTask.getId());
    Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("subprocess1WaitBeforeError").singleResult();
    runtimeService.signal(execution.getId());
    activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
    assertEquals(2, activeActivities.size());
    tasks = taskService.createTaskQuery().list();
    assertEquals(2, tasks.size());
    Task beforeErrorUserTask = null;
    for (Task task : tasks) {
        if (!task.getName().equals("BeforeError") && !task.getName().equals("MainUserTask")) {
            fail("Expected: <BeforeError> or <MainUserTask> but was <" + task.getName() + ">.");
        }
        if (task.getName().equals("BeforeError")) {
            beforeErrorUserTask = task;
        }
    }
    assertNotNull(beforeErrorUserTask);
    taskService.complete(beforeErrorUserTask.getId());
    activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
    assertEquals(2, activeActivities.size());
    tasks = taskService.createTaskQuery().list();
    assertEquals(2, tasks.size());
    Task afterErrorUserTask = null;
    for (Task task : tasks) {
        if (!task.getName().equals("AfterError") && !task.getName().equals("MainUserTask")) {
            fail("Expected: <AfterError> or <MainUserTask> but was <" + task.getName() + ">.");
        }
        if (task.getName().equals("AfterError")) {
            afterErrorUserTask = task;
        }
    }
    assertNotNull(afterErrorUserTask);
    taskService.complete(afterErrorUserTask.getId());
    tasks = taskService.createTaskQuery().list();
    assertEquals(1, tasks.size());
    assertEquals("MainUserTask", tasks.get(0).getName());
    activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
    assertEquals(1, activeActivities.size());
    assertEquals("MainUserTask", activeActivities.get(0));
    taskService.complete(tasks.get(0).getId());
    testRule.assertProcessEnded(processInstance.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Execution(org.camunda.bpm.engine.runtime.Execution) 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

Execution (org.camunda.bpm.engine.runtime.Execution)279 Deployment (org.camunda.bpm.engine.test.Deployment)188 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)143 Task (org.camunda.bpm.engine.task.Task)99 Test (org.junit.Test)95 HashMap (java.util.HashMap)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)33 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)23 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 ThrowErrorDelegate.leaveExecution (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution)18 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)14 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)14 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)13 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)12 ArrayList (java.util.ArrayList)11