public static HistoricProcessInstance createMockHistoricProcessInstanceUnfinished() { HistoricProcessInstance mock = mock(HistoricProcessInstance.class); when(mock.getId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getDeleteReason()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON); when(mock.getEndTime()).thenReturn(null); when(mock.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_TIME)); when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DURATION_MILLIS); return mock; }
public static HistoricProcessInstance createMockHistoricProcessInstance(String tenantId) { HistoricProcessInstance mock = mock(HistoricProcessInstance.class); when(mock.getId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY); when(mock.getProcessDefinitionName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME); when(mock.getProcessDefinitionVersion()).thenReturn(EXAMPLE_PROCESS_DEFINITION_VERSION); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getDeleteReason()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON); when(mock.getRemovalTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_REMOVAL_TIME)); when(mock.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_END_TIME)); when(mock.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_TIME)); when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DURATION_MILLIS); when(mock.getStartUserId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_USER_ID); when(mock.getStartActivityId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_ACTIVITY_ID); when(mock.getRootProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_ROOT_PROCESS_INSTANCE_ID); when(mock.getSuperProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_PROCESS_INSTANCE_ID); when(mock.getSuperCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_CASE_INSTANCE_ID); when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_CASE_INSTANCE_ID); when(mock.getTenantId()).thenReturn(tenantId); when(mock.getState()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_STATE); return mock; }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testHistoricProcessInstanceDelete() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), "cancel"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicProcessInstance.getDeleteReason()); assertEquals("cancel", historicProcessInstance.getDeleteReason()); assertNotNull(historicProcessInstance.getEndTime()); }
/** See: https://app.camunda.com/jira/browse/CAM-1324 */ @Deployment public void testHistoricProcessInstanceDeleteAsync() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failing"); runtimeService.deleteProcessInstance(pi.getId(), "cancel"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicProcessInstance.getDeleteReason()); assertEquals("cancel", historicProcessInstance.getDeleteReason()); assertNotNull(historicProcessInstance.getEndTime()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) // ACT-1098 public void testDeleteReason() { if(!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) { final String deleteReason = "some delete reason"; ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), deleteReason); HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(deleteReason, hpi.getDeleteReason()); } }
public static HistoricProcessInstanceDto fromHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) { HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto(); dto.id = historicProcessInstance.getId(); dto.businessKey = historicProcessInstance.getBusinessKey(); dto.processDefinitionId = historicProcessInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicProcessInstance.getProcessDefinitionKey(); dto.processDefinitionName = historicProcessInstance.getProcessDefinitionName(); dto.processDefinitionVersion = historicProcessInstance.getProcessDefinitionVersion(); dto.startTime = historicProcessInstance.getStartTime(); dto.endTime = historicProcessInstance.getEndTime(); dto.removalTime = historicProcessInstance.getRemovalTime(); dto.durationInMillis = historicProcessInstance.getDurationInMillis(); dto.startUserId = historicProcessInstance.getStartUserId(); dto.startActivityId = historicProcessInstance.getStartActivityId(); dto.deleteReason = historicProcessInstance.getDeleteReason(); dto.rootProcessInstanceId = historicProcessInstance.getRootProcessInstanceId(); dto.superProcessInstanceId = historicProcessInstance.getSuperProcessInstanceId(); dto.superCaseInstanceId = historicProcessInstance.getSuperCaseInstanceId(); dto.caseInstanceId = historicProcessInstance.getCaseInstanceId(); dto.tenantId = historicProcessInstance.getTenantId(); dto.state = historicProcessInstance.getState(); return dto; }
public static HistoricProcessInstanceDto fromHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) { HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto(); dto.id = historicProcessInstance.getId(); dto.businessKey = historicProcessInstance.getBusinessKey(); dto.processDefinitionId = historicProcessInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicProcessInstance.getProcessDefinitionKey(); dto.processDefinitionName = historicProcessInstance.getProcessDefinitionName(); dto.processDefinitionVersion = historicProcessInstance.getProcessDefinitionVersion(); dto.startTime = historicProcessInstance.getStartTime(); dto.endTime = historicProcessInstance.getEndTime(); dto.removalTime = historicProcessInstance.getRemovalTime(); dto.durationInMillis = historicProcessInstance.getDurationInMillis(); dto.startUserId = historicProcessInstance.getStartUserId(); dto.startActivityId = historicProcessInstance.getStartActivityId(); dto.deleteReason = historicProcessInstance.getDeleteReason(); dto.rootProcessInstanceId = historicProcessInstance.getRootProcessInstanceId(); dto.superProcessInstanceId = historicProcessInstance.getSuperProcessInstanceId(); dto.superCaseInstanceId = historicProcessInstance.getSuperCaseInstanceId(); dto.caseInstanceId = historicProcessInstance.getCaseInstanceId(); dto.tenantId = historicProcessInstance.getTenantId(); dto.state = historicProcessInstance.getState(); return dto; }
/** * CAM-4067 */ @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInSubProcessConcurrent.bpmn") public void testTerminateInSubProcessConcurrentShouldNotEndProcessInstanceInHistory() throws Exception { // when process instance is started and terminate end event in subprocess executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample"); // then the historic process instance should not appear ended assertProcessNotEnded(pi.getId()); if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(hpi); assertNull(hpi.getEndTime()); assertNull(hpi.getDurationInMillis()); assertNull(hpi.getDeleteReason()); } }
/** * CAM-4067 */ @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInSubProcess.bpmn") public void testTerminateInSubProcessShouldNotEndProcessInstanceInHistory() throws Exception { // when process instance is started and terminate end event in subprocess executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample"); // then the historic process instance should not appear ended assertProcessNotEnded(pi.getId()); if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(hpi); assertNull(hpi.getEndTime()); assertNull(hpi.getDurationInMillis()); assertNull(hpi.getDeleteReason()); } }
@Test @RequiredHistoryLevel(ProcessEngineConfigurationImpl.HISTORY_AUDIT) public void testDeleteCalledSubprocess() { // given BpmnModelInstance callingInstance = ProcessModels.newModel("oneTaskProcess") .startEvent() .callActivity() .calledElement("called") .endEvent() .done(); BpmnModelInstance calledInstance = ProcessModels.newModel("called") .startEvent() .userTask() .endEvent() .done(); testRule.deploy(callingInstance, calledInstance); final String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getProcessInstanceId(); String subprocessId = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").singleResult().getId(); runtimeService.deleteProcessInstance(subprocessId, TESTING_INSTANCE_DELETION); assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(subprocessId).singleResult().getDeleteReason()); assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getDeleteReason()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnCallActivity-parent.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.subprocess.bpmn20.xml" }) public void FAILING_testCatchErrorOnCallActivityShouldEndCalledProcessProperly() { // given a process instance that has instantiated (called) a sub process instance runtimeService.startProcessInstanceByKey("catchErrorOnCallActivity").getId(); Task task = taskService.createTaskQuery().singleResult(); assertEquals("Task in subprocess", task.getName()); // when an error end event is triggered in the sub process instance and catched in the super process instance taskService.complete(task.getId()); task = taskService.createTaskQuery().singleResult(); assertEquals("Escalated Task", task.getName()); // then the called historic process instance should have properly ended HistoricProcessInstance historicSubProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("simpleSubProcess").singleResult(); assertNotNull(historicSubProcessInstance); assertNull(historicSubProcessInstance.getDeleteReason()); assertEquals("theEnd", historicSubProcessInstance.getEndActivityId()); }
/** See: https://app.camunda.com/jira/browse/CAM-1324 */ @Deployment public void testHistoricProcessInstanceDeleteAsync() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("failing"); runtimeService.deleteProcessInstance(pi.getId(), "cancel"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicProcessInstance.getDeleteReason()); assertEquals("cancel", historicProcessInstance.getDeleteReason()); assertNotNull(historicProcessInstance.getEndTime()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testHistoricProcessInstanceDelete() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), "cancel"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicProcessInstance.getDeleteReason()); assertEquals("cancel", historicProcessInstance.getDeleteReason()); assertNotNull(historicProcessInstance.getEndTime()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) // ACT-1098 public void testDeleteReason() { if(!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) { final String deleteReason = "some delete reason"; ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), deleteReason); HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(deleteReason, hpi.getDeleteReason()); } }
public static HistoricProcessInstanceDto fromHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) { HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto(); dto.id = historicProcessInstance.getId(); dto.businessKey = historicProcessInstance.getBusinessKey(); dto.processDefinitionId = historicProcessInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicProcessInstance.getProcessDefinitionKey(); dto.processDefinitionName = historicProcessInstance.getProcessDefinitionName(); dto.processDefinitionVersion = historicProcessInstance.getProcessDefinitionVersion(); dto.startTime = historicProcessInstance.getStartTime(); dto.endTime = historicProcessInstance.getEndTime(); dto.removalTime = historicProcessInstance.getRemovalTime(); dto.durationInMillis = historicProcessInstance.getDurationInMillis(); dto.startUserId = historicProcessInstance.getStartUserId(); dto.startActivityId = historicProcessInstance.getStartActivityId(); dto.deleteReason = historicProcessInstance.getDeleteReason(); dto.rootProcessInstanceId = historicProcessInstance.getRootProcessInstanceId(); dto.superProcessInstanceId = historicProcessInstance.getSuperProcessInstanceId(); dto.superCaseInstanceId = historicProcessInstance.getSuperCaseInstanceId(); dto.caseInstanceId = historicProcessInstance.getCaseInstanceId(); dto.tenantId = historicProcessInstance.getTenantId(); dto.state = historicProcessInstance.getState(); return dto; }
/** * CAM-4067 */ @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInSubProcessConcurrent.bpmn") public void testTerminateInSubProcessConcurrentShouldNotEndProcessInstanceInHistory() throws Exception { // when process instance is started and terminate end event in subprocess executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample"); // then the historic process instance should not appear ended assertProcessNotEnded(pi.getId()); if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(hpi); assertNull(hpi.getEndTime()); assertNull(hpi.getDurationInMillis()); assertNull(hpi.getDeleteReason()); } }
/** * CAM-4067 */ @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInSubProcess.bpmn") public void testTerminateInSubProcessShouldNotEndProcessInstanceInHistory() throws Exception { // when process instance is started and terminate end event in subprocess executed ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample"); // then the historic process instance should not appear ended assertProcessNotEnded(pi.getId()); if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(hpi); assertNull(hpi.getEndTime()); assertNull(hpi.getDurationInMillis()); assertNull(hpi.getDeleteReason()); } }
@Test @RequiredHistoryLevel(ProcessEngineConfigurationImpl.HISTORY_AUDIT) public void testDeleteCalledSubprocess() { // given BpmnModelInstance callingInstance = ProcessModels.newModel("oneTaskProcess") .startEvent() .callActivity() .calledElement("called") .endEvent() .done(); BpmnModelInstance calledInstance = ProcessModels.newModel("called") .startEvent() .userTask() .endEvent() .done(); testRule.deploy(callingInstance, calledInstance); final String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getProcessInstanceId(); String subprocessId = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").singleResult().getId(); runtimeService.deleteProcessInstance(subprocessId, TESTING_INSTANCE_DELETION); assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(subprocessId).singleResult().getDeleteReason()); assertEquals(TESTING_INSTANCE_DELETION, historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getDeleteReason()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnCallActivity-parent.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.subprocess.bpmn20.xml" }) public void FAILING_testCatchErrorOnCallActivityShouldEndCalledProcessProperly() { // given a process instance that has instantiated (called) a sub process instance runtimeService.startProcessInstanceByKey("catchErrorOnCallActivity").getId(); Task task = taskService.createTaskQuery().singleResult(); assertEquals("Task in subprocess", task.getName()); // when an error end event is triggered in the sub process instance and catched in the super process instance taskService.complete(task.getId()); task = taskService.createTaskQuery().singleResult(); assertEquals("Escalated Task", task.getName()); // then the called historic process instance should have properly ended HistoricProcessInstance historicSubProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("simpleSubProcess").singleResult(); assertNotNull(historicSubProcessInstance); assertNull(historicSubProcessInstance.getDeleteReason()); assertEquals("theEnd", historicSubProcessInstance.getEndActivityId()); }