@Override protected void applySortBy(HistoricActivityInstanceQuery query, String sortBy, Map<String, Object> parameters, ProcessEngine engine) { if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_ID_VALUE)) { query.orderByHistoricActivityInstanceId(); } else if (sortBy.equals(SORT_BY_PROCESS_INSTANCE_ID_VALUE)) { query.orderByProcessInstanceId(); } else if (sortBy.equals(SORT_BY_PROCESS_DEFINITION_ID_VALUE)) { query.orderByProcessDefinitionId(); } else if (sortBy.equals(SORT_BY_EXECUTION_ID_VALUE)) { query.orderByExecutionId(); } else if (sortBy.equals(SORT_BY_ACTIVITY_ID_VALUE)) { query.orderByActivityId(); } else if (sortBy.equals(SORT_BY_ACTIVITY_NAME_VALUE)) { query.orderByActivityName(); } else if (sortBy.equals(SORT_BY_ACTIVITY_TYPE_VALUE)) { query.orderByActivityType(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_START_TIME_VALUE)) { query.orderByHistoricActivityInstanceStartTime(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_END_TIME_VALUE)) { query.orderByHistoricActivityInstanceEndTime(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_DURATION_VALUE)) { query.orderByHistoricActivityInstanceDuration(); } else if (sortBy.equals(SORT_PARTIALLY_BY_OCCURRENCE)) { query.orderPartiallyByOccurrence(); } else if (sortBy.equals(SORT_BY_TENANT_ID)) { query.orderByTenantId(); } }
@Override protected void applySortBy(HistoricActivityInstanceQuery query, String sortBy, Map<String, Object> parameters, ProcessEngine engine) { if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_ID_VALUE)) { query.orderByHistoricActivityInstanceId(); } else if (sortBy.equals(SORT_BY_PROCESS_INSTANCE_ID_VALUE)) { query.orderByProcessInstanceId(); } else if (sortBy.equals(SORT_BY_PROCESS_DEFINITION_ID_VALUE)) { query.orderByProcessDefinitionId(); } else if (sortBy.equals(SORT_BY_EXECUTION_ID_VALUE)) { query.orderByExecutionId(); } else if (sortBy.equals(SORT_BY_ACTIVITY_ID_VALUE)) { query.orderByActivityId(); } else if (sortBy.equals(SORT_BY_ACTIVITY_NAME_VALUE)) { query.orderByActivityName(); } else if (sortBy.equals(SORT_BY_ACTIVITY_TYPE_VALUE)) { query.orderByActivityType(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_START_TIME_VALUE)) { query.orderByHistoricActivityInstanceStartTime(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_END_TIME_VALUE)) { query.orderByHistoricActivityInstanceEndTime(); } else if (sortBy.equals(SORT_BY_HISTORIC_ACTIVITY_INSTANCE_DURATION_VALUE)) { query.orderByHistoricActivityInstanceDuration(); } else if (sortBy.equals(SORT_PARTIALLY_BY_OCCURRENCE)) { query.orderPartiallyByOccurrence(); } else if (sortBy.equals(SORT_BY_TENANT_ID)) { query.orderByTenantId(); } }
protected HistoricActivityInstance resolveStartActivityInstance(HistoricProcessInstance processInstance) { HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService(); String processInstanceId = processInstance.getId(); String startActivityId = processInstance.getStartActivityId(); ensureNotNull("startActivityId", startActivityId); List<HistoricActivityInstance> historicActivityInstances = historyService .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .activityId(startActivityId) .orderPartiallyByOccurrence() .asc() .list(); ensureNotEmpty("historicActivityInstances", historicActivityInstances); HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0); return startActivityInstance; }
protected HistoricActivityInstance resolveStartActivityInstance(HistoricProcessInstance processInstance) { HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService(); String processInstanceId = processInstance.getId(); String startActivityId = processInstance.getStartActivityId(); ensureNotNull("startActivityId", startActivityId); List<HistoricActivityInstance> historicActivityInstances = historyService .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .activityId(startActivityId) .orderPartiallyByOccurrence() .asc() .list(); ensureNotEmpty("historicActivityInstances", historicActivityInstances); HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0); return startActivityInstance; }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequence.bpmn20.xml"}) public void testSequence() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when runtimeService.startProcessInstanceByKey("process"); // then verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); }
inOrder.verify(mockedQuery).orderPartiallyByOccurrence(); inOrder.verify(mockedQuery).asc(); inOrder.verify(mockedQuery).orderPartiallyByOccurrence(); inOrder.verify(mockedQuery).desc();
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testLoop.bpmn20.xml"}) public void testLoop() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "join", "theScript", "fork", "join", "theScript", "fork", "theService2", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequentialMultiInstance.bpmn20.xml"}) public void testSequentialMultiInstance() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService3", "theEnd"); String taskExecutionId = historyService .createHistoricActivityInstanceQuery() .activityId("theService2") .list() .get(0) .getExecutionId(); query.executionId(taskExecutionId); verifyOrder(query, "theService2#multiInstanceBody", "theService2", "theService2"); query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService1", "theService2#multiInstanceBody", "theService2", "theService2", "theService3", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testForkSameSequenceLengthWithoutWaitStates.bpmn20.xml"}) public void testFork() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService", "fork", "theService2", "theEnd2"); String firstExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theService1").singleResult().getExecutionId(); query.executionId(firstExecutionId); verifyOrder(query, "theService1", "theEnd1"); query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService", "fork", "theService1", "theEnd1", "theService2", "theEnd2"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testParallelMultiInstance.bpmn20.xml"}) public void testParallelMultiInstance() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService3", "theEnd"); List<HistoricActivityInstance> taskActivityInstances = historyService .createHistoricActivityInstanceQuery() .activityId("theService2") .list(); for (HistoricActivityInstance activityInstance : taskActivityInstances) { query.executionId(activityInstance.getExecutionId()); verifyOrder(query, "theService2"); } query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService1", "theService2#multiInstanceBody", "theService2", "theService2", "theService3", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequenceInsideSubProcess.bpmn20.xml"}) public void testSequenceInsideSubProcess() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); String subProcessExecutionId = historyService .createHistoricActivityInstanceQuery() .activityId("subProcess") .singleResult() .getExecutionId(); query.executionId(subProcessExecutionId); verifyOrder(query, "subProcess", "innerStart", "innerService", "innerEnd"); query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService1", "subProcess", "innerStart", "innerService", "innerEnd", "theService2", "theEnd"); }
.orderPartiallyByOccurrence() .asc(); .orderPartiallyByOccurrence() .asc() .orderByActivityId()
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testInterruptingBoundaryEvent.bpmn20.xml"}) public void testInterruptingBoundaryEvent() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); runtimeService.correlateMessage("newMessage"); // then verifyOrder(query, "theStart", "theService1", "theTask", "messageBoundary", "theServiceAfterMessage", "theEnd2"); query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "messageBoundary", "theServiceAfterMessage", "theEnd2"); String taskExecutionId = historyService .createHistoricActivityInstanceQuery() .activityId("theTask") .singleResult() .getExecutionId(); query.executionId(taskExecutionId); verifyOrder(query, "theTask"); }
.orderPartiallyByOccurrence() .asc(); .orderPartiallyByOccurrence() .asc() .orderByActivityId()
protected HistoricActivityInstance resolveStartActivityInstance(HistoricProcessInstance processInstance) { HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService(); String processInstanceId = processInstance.getId(); String startActivityId = processInstance.getStartActivityId(); ensureNotNull("startActivityId", startActivityId); List<HistoricActivityInstance> historicActivityInstances = historyService .createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .activityId(startActivityId) .orderPartiallyByOccurrence() .asc() .list(); ensureNotEmpty("historicActivityInstances", historicActivityInstances); HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0); return startActivityInstance; }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequence.bpmn20.xml"}) public void testSequence() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when runtimeService.startProcessInstanceByKey("process"); // then verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testLoop.bpmn20.xml"}) public void testLoop() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "join", "theScript", "fork", "join", "theScript", "fork", "theService2", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testForkSameSequenceLengthWithoutWaitStates.bpmn20.xml"}) public void testFork() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService", "fork", "theService2", "theEnd2"); String firstExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theService1").singleResult().getExecutionId(); query.executionId(firstExecutionId); verifyOrder(query, "theService1", "theEnd1"); query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService", "fork", "theService1", "theEnd1", "theService2", "theEnd2"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequenceInsideSubProcess.bpmn20.xml"}) public void testSequenceInsideSubProcess() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); String subProcessExecutionId = historyService .createHistoricActivityInstanceQuery() .activityId("subProcess") .singleResult() .getExecutionId(); query.executionId(subProcessExecutionId); verifyOrder(query, "subProcess", "innerStart", "innerService", "innerEnd"); query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); verifyOrder(query, "theStart", "theService1", "subProcess", "innerStart", "innerService", "innerEnd", "theService2", "theEnd"); }
@Deployment(resources = {"org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testInterruptingBoundaryEvent.bpmn20.xml"}) public void testInterruptingBoundaryEvent() { // given HistoricActivityInstanceQuery query = historyService .createHistoricActivityInstanceQuery() .orderPartiallyByOccurrence() .asc(); // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); runtimeService.correlateMessage("newMessage"); // then verifyOrder(query, "theStart", "theService1", "theTask", "messageBoundary", "theServiceAfterMessage", "theEnd2"); query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "messageBoundary", "theServiceAfterMessage", "theEnd2"); String taskExecutionId = historyService .createHistoricActivityInstanceQuery() .activityId("theTask") .singleResult() .getExecutionId(); query.executionId(taskExecutionId); verifyOrder(query, "theTask"); }