Search in sources :

Example 51 with HistoricProcessInstance

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

the class HistoricProcessInstanceStateTest method testCompletedOnEndEvent.

@Test
public void testCompletedOnEndEvent() {
    BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().endEvent().done();
    ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance);
    processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
    HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition);
    assertThat(entity.getState(), is(HistoricProcessInstance.STATE_COMPLETED));
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 52 with HistoricProcessInstance

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

the class HistoricProcessInstanceStateTest method testSuspensionByProcessDefinition.

@Test
public void testSuspensionByProcessDefinition() {
    BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().userTask().endEvent().done();
    ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance);
    ProcessInstance processInstance1 = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
    ProcessInstance processInstance2 = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
    // suspend all
    processEngineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionId(processDefinition.getId()).suspend();
    HistoricProcessInstance hpi1 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
    HistoricProcessInstance hpi2 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
    assertThat(hpi1.getState(), is(HistoricProcessInstance.STATE_SUSPENDED));
    assertThat(hpi2.getState(), is(HistoricProcessInstance.STATE_SUSPENDED));
    // activate all
    processEngineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(processDefinition.getKey()).activate();
    hpi1 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
    hpi2 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
    assertThat(hpi1.getState(), is(HistoricProcessInstance.STATE_ACTIVE));
    assertThat(hpi2.getState(), is(HistoricProcessInstance.STATE_ACTIVE));
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 53 with HistoricProcessInstance

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

the class HistoricProcessInstanceStateTest method testWithCallActivity.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceStateTest.testWithCallActivity.bpmn" })
public void testWithCallActivity() {
    processEngineRule.getRuntimeService().startProcessInstanceByKey("Main_Process");
    assertThat(processEngineRule.getRuntimeService().createProcessInstanceQuery().active().list().size(), is(0));
    HistoricProcessInstance entity1 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("Main_Process").singleResult();
    HistoricProcessInstance entity2 = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("Sub_Process").singleResult();
    assertThat(entity1, is(notNullValue()));
    assertThat(entity2, is(notNullValue()));
    assertThat(entity1.getState(), is(HistoricProcessInstance.STATE_COMPLETED));
    assertThat(entity2.getState(), is(HistoricProcessInstance.STATE_INTERNALLY_TERMINATED));
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 54 with HistoricProcessInstance

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

the class HistoricProcessInstanceStateTest method testCancellationState.

@Test
public void testCancellationState() {
    BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().userTask().endEvent().done();
    ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance);
    ProcessInstance processInstance = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
    HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition);
    assertThat(entity.getState(), is(HistoricProcessInstance.STATE_ACTIVE));
    // same call as in ProcessInstanceResourceImpl
    processEngineRule.getRuntimeService().deleteProcessInstance(processInstance.getId(), REASON, false, true);
    entity = getHistoricProcessInstanceWithAssertion(processDefinition);
    assertThat(entity.getState(), is(HistoricProcessInstance.STATE_EXTERNALLY_TERMINATED));
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 55 with HistoricProcessInstance

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

the class FullHistoryTest method testDeleteProcessInstanceSkipCustomListener.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testDeleteProcessInstanceSkipCustomListener() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
    // when
    runtimeService.deleteProcessInstance(processInstanceId, null, true);
    // then
    HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
    assertNotNull(instance.getEndTime());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Test(org.junit.Test) 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