protected void ensureSameProcessDefinition(HistoricProcessInstance instance, String processDefinitionId) { if (!processDefinitionId.equals(instance.getProcessDefinitionId())) { throw LOG.processDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(instance, processDefinitionId); } }
protected void ensureSameProcessDefinition(HistoricProcessInstance instance, String processDefinitionId) { if (!processDefinitionId.equals(instance.getProcessDefinitionId())) { throw LOG.processDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(instance, processDefinitionId); } }
@Override public String getProperty(HistoricProcessInstance obj) { return obj.getProcessDefinitionId(); } });
public ProcessEngineException processDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(HistoricProcessInstance historicProcessInstance, String processDefinitionId) { return new ProcessEngineException(exceptionMessage( "039", "Historic process instance '{}' cannot be restarted. Its process definition '{}' does not match given process definition '{}'", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId(), processDefinitionId )); }
public ProcessEngineException processDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(HistoricProcessInstance historicProcessInstance, String processDefinitionId) { return new ProcessEngineException(exceptionMessage( "039", "Historic process instance '{}' cannot be restarted. Its process definition '{}' does not match given process definition '{}'", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId(), processDefinitionId )); }
public ProcessEngineException historicProcessInstanceActive(HistoricProcessInstance historicProcessInstance) { return new ProcessEngineException(exceptionMessage( "040", "Historic process instance '{}' cannot be restarted. It is not completed or terminated.", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId() )); }
public ProcessEngineException historicProcessInstanceActive(HistoricProcessInstance historicProcessInstance) { return new ProcessEngineException(exceptionMessage( "040", "Historic process instance '{}' cannot be restarted. It is not completed or terminated.", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId() )); }
private void assertThatInstanceHasAllImportantInformation(HistoricProcessInstance historicProcessInstance) { assertThat(historicProcessInstance, notNullValue()); assertThat(historicProcessInstance.getId(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionKey(), is("process")); assertThat(historicProcessInstance.getProcessDefinitionVersion(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionId(), notNullValue()); assertThat(historicProcessInstance.getDurationInMillis(), notNullValue()); assertThat(historicProcessInstance.getStartTime(), notNullValue()); assertThat(historicProcessInstance.getEndTime(), notNullValue()); }
private void assertThatInstanceHasAllImportantInformation(HistoricProcessInstance historicProcessInstance) { assertThat(historicProcessInstance, notNullValue()); assertThat(historicProcessInstance.getId(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionKey(), is("process")); assertThat(historicProcessInstance.getProcessDefinitionVersion(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionId(), notNullValue()); assertThat(historicProcessInstance.getStartTime(), notNullValue()); assertThat(historicProcessInstance.getEndTime(), nullValue()); }
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; }
@Override public Object execute(CommandContext commandContext) { //when List<String> historicProcessInstanceIdsForCleanup = commandContext.getHistoricProcessInstanceManager().findHistoricProcessInstanceIdsForCleanup( batchSize, 0, 60); //then assertEquals(resultCount, historicProcessInstanceIdsForCleanup.size()); if (resultCount > 0) { List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery() .processInstanceIds(new HashSet<String>(historicProcessInstanceIdsForCleanup)).list(); for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) { assertNotNull(historicProcessInstance.getEndTime()); List<ProcessDefinition> processDefinitions = engineRule.getRepositoryService().createProcessDefinitionQuery() .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).list(); assertEquals(1, processDefinitions.size()); ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) processDefinitions.get(0); assertTrue(historicProcessInstance.getEndTime().before(DateUtils.addDays(ClockUtil.getCurrentTime(), processDefinition.getHistoryTimeToLive()))); } } return null; } });
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/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/checkCreditProcess.bpmn20.xml"}) public void testOrderProcessWithCallActivity() { // After the process has started, the 'verify credit history' task should be // active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); Task verifyCreditTask = taskQuery.singleResult(); // Completing the task with approval, will end the subprocess and continue // the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); // verify HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(historicProcessInstance); assertTrue(historicProcessInstance.getProcessDefinitionId().contains("checkCreditProcess")); }
@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()); }
assertEquals(processInstance.getId(), historicProcessInstance.getId()); assertEquals(processInstance.getBusinessKey(), historicProcessInstance.getBusinessKey()); assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId()); assertEquals(noon, historicProcessInstance.getStartTime()); assertNull(historicProcessInstance.getEndTime()); assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId()); assertEquals(noon, historicProcessInstance.getStartTime()); assertEquals(twentyFiveSecsAfterNoon, historicProcessInstance.getEndTime());
public ProcessEngineException historicProcessInstanceActive(HistoricProcessInstance historicProcessInstance) { return new ProcessEngineException(exceptionMessage( "040", "Historic process instance '{}' cannot be restarted. It is not completed or terminated.", historicProcessInstance.getId(), historicProcessInstance.getProcessDefinitionId() )); }
private void assertThatInstanceHasAllImportantInformation(HistoricProcessInstance historicProcessInstance) { assertThat(historicProcessInstance, notNullValue()); assertThat(historicProcessInstance.getId(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionKey(), is("process")); assertThat(historicProcessInstance.getProcessDefinitionVersion(), notNullValue()); assertThat(historicProcessInstance.getProcessDefinitionId(), notNullValue()); assertThat(historicProcessInstance.getStartTime(), notNullValue()); assertThat(historicProcessInstance.getEndTime(), nullValue()); }
.processInstanceId(processInstance.getId()) .singleResult(); assertEquals(processDefinitionV2.getId(), historicProcessInstance.getProcessDefinitionId());