@SuppressWarnings("deprecation") // deprecated method is tested here @Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testHistoricProcessInstanceUserIdAndActivityId() { identityService.setAuthenticatedUserId("johndoe"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("johndoe", historicProcessInstance.getStartUserId()); assertEquals("theStart", historicProcessInstance.getStartActivityId()); List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertEquals(1, tasks.size()); taskService.complete(tasks.get(0).getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("theEnd", historicProcessInstance.getEndActivityId()); }
@Deployment public void testEndTimeAndEndActivity() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); String taskId = taskService .createTaskQuery() .taskDefinitionKey("userTask2") .singleResult() .getId(); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); // when (1) taskService.complete(taskId); // then (1) HistoricProcessInstance historicProcessInstance = query.singleResult(); assertNull(historicProcessInstance.getEndActivityId()); assertNull(historicProcessInstance.getEndTime()); // when (2) runtimeService.deleteProcessInstance(processInstanceId, null); // then (2) historicProcessInstance = query.singleResult(); assertNull(historicProcessInstance.getEndActivityId()); assertNotNull(historicProcessInstance.getEndTime()); }
@Deployment public void testDeeplyNestedErrorThrownOnlyAutomaticSteps() { // input == 1 -> error2 is thrown -> caught on subprocess2 -> end event in subprocess -> proc inst end 1 String procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); HistoricProcessInstance hip; int historyLevel = processEngineConfiguration.getHistoryLevel().getId(); if (historyLevel> ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } // input == 2 -> error2 is thrown -> caught on subprocess1 -> proc inst end 2 procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); if (historyLevel> ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } }
@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()); }
@SuppressWarnings("deprecation") // deprecated method is tested here @Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testHistoricProcessInstanceUserIdAndActivityId() { identityService.setAuthenticatedUserId("johndoe"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("johndoe", historicProcessInstance.getStartUserId()); assertEquals("theStart", historicProcessInstance.getStartActivityId()); List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertEquals(1, tasks.size()); taskService.complete(tasks.get(0).getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("theEnd", historicProcessInstance.getEndActivityId()); }
@Deployment public void testEndTimeAndEndActivity() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); String taskId = taskService .createTaskQuery() .taskDefinitionKey("userTask2") .singleResult() .getId(); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); // when (1) taskService.complete(taskId); // then (1) HistoricProcessInstance historicProcessInstance = query.singleResult(); assertNull(historicProcessInstance.getEndActivityId()); assertNull(historicProcessInstance.getEndTime()); // when (2) runtimeService.deleteProcessInstance(processInstanceId, null); // then (2) historicProcessInstance = query.singleResult(); assertNull(historicProcessInstance.getEndActivityId()); assertNotNull(historicProcessInstance.getEndTime()); }
@Deployment public void testDeeplyNestedErrorThrownOnlyAutomaticSteps() { // input == 1 -> error2 is thrown -> caught on subprocess2 -> end event in subprocess -> proc inst end 1 String procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); HistoricProcessInstance hip; int historyLevel = processEngineConfiguration.getHistoryLevel().getId(); if (historyLevel> ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } // input == 2 -> error2 is thrown -> caught on subprocess1 -> proc inst end 2 procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); if (historyLevel> ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } }
@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()); }