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));
}
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));
}
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));
}
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));
}
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());
}
Aggregations