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/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void testQueryBySuperCaseInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId(); HistoricProcessInstanceQuery query = historyService .createHistoricProcessInstanceQuery() .superCaseInstanceId(superCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricProcessInstance subProcessInstance = query.singleResult(); assertNotNull(subProcessInstance); assertEquals(superCaseInstanceId, subProcessInstance.getSuperCaseInstanceId()); assertNull(subProcessInstance.getSuperProcessInstanceId()); }
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; }
@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()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithCaseCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testQueryBySubCaseInstanceId() { String superProcessInstanceId = runtimeService.startProcessInstanceByKey("subProcessQueryTest").getId(); String subCaseInstanceId = caseService .createCaseInstanceQuery() .superProcessInstanceId(superProcessInstanceId) .singleResult() .getId(); HistoricProcessInstanceQuery query = historyService .createHistoricProcessInstanceQuery() .subCaseInstanceId(subCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricProcessInstance superProcessInstance = query.singleResult(); assertNotNull(superProcessInstance); assertEquals(superProcessInstanceId, superProcessInstance.getId()); assertNull(superProcessInstance.getSuperCaseInstanceId()); assertNull(superProcessInstance.getSuperProcessInstanceId()); }
public void testDeleteProcessInstanceWithoutSubprocessInstances() { // given a process instance with subprocesses BpmnModelInstance calling = Bpmn.createExecutableProcess("calling") .startEvent() .callActivity() .calledElement("called") .endEvent("endA") .done(); BpmnModelInstance called = Bpmn.createExecutableProcess("called") .startEvent() .userTask("Task1") .endEvent() .done(); deployment(calling, called); ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling"); // when the process instance is deleted and we do skip sub processes String id = instance.getId(); runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, true); // then List<HistoricProcessInstance> historicSubprocessList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").list(); for (HistoricProcessInstance historicProcessInstance : historicSubprocessList) { assertNull(historicProcessInstance.getSuperProcessInstanceId()); } }
public void testDeleteProcessInstanceWithSubprocessInstances() { // given a process instance with subprocesses BpmnModelInstance calling = Bpmn.createExecutableProcess("calling") .startEvent() .callActivity() .calledElement("called") .endEvent("endA") .done(); BpmnModelInstance called = Bpmn.createExecutableProcess("called") .startEvent() .userTask("Task1") .endEvent() .done(); deployment(calling, called); ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling"); // when the process instance is deleted and we do not skip sub processes String id = instance.getId(); runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, false); // then List<HistoricProcessInstance> historicSubprocessList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").list(); for (HistoricProcessInstance historicProcessInstance : historicSubprocessList) { assertNotNull(historicProcessInstance.getSuperProcessInstanceId()); } }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void testQueryBySuperCaseInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId(); HistoricProcessInstanceQuery query = historyService .createHistoricProcessInstanceQuery() .superCaseInstanceId(superCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricProcessInstance subProcessInstance = query.singleResult(); assertNotNull(subProcessInstance); assertEquals(superCaseInstanceId, subProcessInstance.getSuperCaseInstanceId()); assertNull(subProcessInstance.getSuperProcessInstanceId()); }
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; }
@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()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithCaseCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" }) public void testQueryBySubCaseInstanceId() { String superProcessInstanceId = runtimeService.startProcessInstanceByKey("subProcessQueryTest").getId(); String subCaseInstanceId = caseService .createCaseInstanceQuery() .superProcessInstanceId(superProcessInstanceId) .singleResult() .getId(); HistoricProcessInstanceQuery query = historyService .createHistoricProcessInstanceQuery() .subCaseInstanceId(subCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricProcessInstance superProcessInstance = query.singleResult(); assertNotNull(superProcessInstance); assertEquals(superProcessInstanceId, superProcessInstance.getId()); assertNull(superProcessInstance.getSuperCaseInstanceId()); assertNull(superProcessInstance.getSuperProcessInstanceId()); }
public void testDeleteProcessInstanceWithoutSubprocessInstances() { // given a process instance with subprocesses BpmnModelInstance calling = Bpmn.createExecutableProcess("calling") .startEvent() .callActivity() .calledElement("called") .endEvent("endA") .done(); BpmnModelInstance called = Bpmn.createExecutableProcess("called") .startEvent() .userTask("Task1") .endEvent() .done(); deployment(calling, called); ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling"); // when the process instance is deleted and we do skip sub processes String id = instance.getId(); runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, true); // then List<HistoricProcessInstance> historicSubprocessList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").list(); for (HistoricProcessInstance historicProcessInstance : historicSubprocessList) { assertNull(historicProcessInstance.getSuperProcessInstanceId()); } }
public void testDeleteProcessInstanceWithSubprocessInstances() { // given a process instance with subprocesses BpmnModelInstance calling = Bpmn.createExecutableProcess("calling") .startEvent() .callActivity() .calledElement("called") .endEvent("endA") .done(); BpmnModelInstance called = Bpmn.createExecutableProcess("called") .startEvent() .userTask("Task1") .endEvent() .done(); deployment(calling, called); ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling"); // when the process instance is deleted and we do not skip sub processes String id = instance.getId(); runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, false); // then List<HistoricProcessInstance> historicSubprocessList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").list(); for (HistoricProcessInstance historicProcessInstance : historicSubprocessList) { assertNotNull(historicProcessInstance.getSuperProcessInstanceId()); } }