Search in sources :

Example 81 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.

the class HistoryServiceTest method testHistoricProcessInstanceQueryByProcessDefinitionKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/checkCreditProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByProcessDefinitionKey() {
    String processDefinitionKey = ONE_TASK_PROCESS;
    runtimeService.startProcessInstanceByKey(processDefinitionKey);
    runtimeService.startProcessInstanceByKey("orderProcess");
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey).singleResult();
    assertNotNull(historicProcessInstance);
    assertTrue(historicProcessInstance.getProcessDefinitionId().startsWith(processDefinitionKey));
    assertEquals("theStart", historicProcessInstance.getStartActivityId());
    // now complete the task to end the process instance
    Task task = taskService.createTaskQuery().processDefinitionKey("checkCreditProcess").singleResult();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("creditApproved", true);
    taskService.complete(task.getId(), map);
    // and make sure the super process instance is set correctly on the
    // HistoricProcessInstance
    HistoricProcessInstance historicProcessInstanceSub = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("checkCreditProcess").singleResult();
    HistoricProcessInstance historicProcessInstanceSuper = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("orderProcess").singleResult();
    assertEquals(historicProcessInstanceSuper.getId(), historicProcessInstanceSub.getSuperProcessInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 82 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.

the class HistoryServiceTest method testOrderProcessWithCallActivity.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/checkCreditProcess.bpmn20.xml" })
public void testOrderProcessWithCallActivity() {
    // After the process has started, the 'verify credit history' task should be
    // active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
    TaskQuery taskQuery = taskService.createTaskQuery();
    Task verifyCreditTask = taskQuery.singleResult();
    // Completing the task with approval, will end the subprocess and continue
    // the original process
    taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
    Task prepareAndShipTask = taskQuery.singleResult();
    assertEquals("Prepare and Ship", prepareAndShipTask.getName());
    // verify
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult();
    assertNotNull(historicProcessInstance);
    assertTrue(historicProcessInstance.getProcessDefinitionId().contains("checkCreditProcess"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 83 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationHistoryTest method testCancelTaskShouldCancelProcessInstance.

@Deployment(resources = ONE_TASK_PROCESS)
public void testCancelTaskShouldCancelProcessInstance() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
    // when
    runtimeService.createProcessInstanceModification(processInstanceId).cancelAllForActivity("theTask").execute(true, false);
    // then
    HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
    assertNotNull(instance.getEndTime());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 84 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricActivityInstancesForSubprocess.

@Deployment(resources = SUBPROCESS_PROCESS)
public void testHistoricActivityInstancesForSubprocess() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("subprocess").startBeforeActivity("innerTask").startBeforeActivity("theSubProcessStart").execute();
    // then
    HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
    assertNotNull(historicInstance);
    assertEquals(instance.getId(), historicInstance.getId());
    assertNotNull(historicInstance.getStartTime());
    assertNull(historicInstance.getEndTime());
    // should be the first activity started
    assertEquals("innerTask", historicInstance.getStartActivityId());
    // subprocess, subprocess start event, two innerTasks
    assertEquals(4, historyService.createHistoricActivityInstanceQuery().count());
    HistoricActivityInstance subProcessInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult();
    assertNotNull(subProcessInstance);
    assertEquals("subProcess", subProcessInstance.getActivityId());
    assertNotNull(subProcessInstance.getId());
    assertFalse(instance.getId().equals(subProcessInstance.getId()));
    assertNotNull(subProcessInstance.getStartTime());
    assertNull(subProcessInstance.getEndTime());
    HistoricActivityInstance startEventInstance = historyService.createHistoricActivityInstanceQuery().activityId("theSubProcessStart").singleResult();
    assertNotNull(startEventInstance);
    assertEquals("theSubProcessStart", startEventInstance.getActivityId());
    assertNotNull(startEventInstance.getId());
    assertFalse(instance.getId().equals(startEventInstance.getId()));
    assertNotNull(startEventInstance.getStartTime());
    assertNotNull(startEventInstance.getEndTime());
    List<HistoricActivityInstance> innerTaskInstances = historyService.createHistoricActivityInstanceQuery().activityId("innerTask").list();
    assertEquals(2, innerTaskInstances.size());
    for (HistoricActivityInstance innerTaskInstance : innerTaskInstances) {
        assertNotNull(innerTaskInstance);
        assertEquals("innerTask", innerTaskInstance.getActivityId());
        assertNotNull(innerTaskInstance.getId());
        assertFalse(instance.getId().equals(innerTaskInstance.getId()));
        assertNotNull(innerTaskInstance.getStartTime());
        assertNull(innerTaskInstance.getEndTime());
    }
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 85 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceForSynchronousCompletion.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricProcessInstanceForSynchronousCompletion() {
    // when the process instance ends immediately
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startAfterActivity("task1").execute();
    // then
    HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
    assertNotNull(historicInstance);
    assertEquals(instance.getId(), historicInstance.getId());
    assertNotNull(historicInstance.getStartTime());
    assertNotNull(historicInstance.getEndTime());
    assertEquals("join", historicInstance.getStartActivityId());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)113 Deployment (org.camunda.bpm.engine.test.Deployment)46 Test (org.junit.Test)37 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)36 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)25 Task (org.camunda.bpm.engine.task.Task)19 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 ArrayList (java.util.ArrayList)15 Calendar (java.util.Calendar)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 GregorianCalendar (java.util.GregorianCalendar)11 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)9 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)9 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)7 List (java.util.List)5 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4