org.camunda.bpm.engine.history.HistoricProcessInstance Java Examples
The following examples show how to use
org.camunda.bpm.engine.history.HistoricProcessInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricProcessInstanceQueryOrTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void shouldReturnHistoricProcInstWithVarValue1OrVarValue2() { // given Map<String, Object> vars = new HashMap<String, Object>(); vars.put("stringVar", "abcdef"); runtimeService.startProcessInstanceByKey("oneTaskProcess", vars); vars = new HashMap<String, Object>(); vars.put("stringVar", "ghijkl"); runtimeService.startProcessInstanceByKey("oneTaskProcess", vars); // when List<HistoricProcessInstance> processInstances = historyService.createHistoricProcessInstanceQuery() .or() .variableValueEquals("stringVar", "abcdef") .variableValueEquals("stringVar", "ghijkl") .endOr() .list(); // then assertEquals(2, processInstances.size()); }
Example #2
Source File: UserOperationLogAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryAfterDeletingDeploymentWithReadPermissionOnAnyCategory() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); createGrantAuthorizationWithoutAuthentication(OPERATION_LOG_CATEGORY, ANY, userId, READ); disableAuthorization(); taskService.complete(taskId); enableAuthorization(); deleteDeployment(deploymentId, false); // when UserOperationLogQuery query = historyService.createUserOperationLogQuery(); // then verifyQueryResults(query, 3); disableAuthorization(); List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list(); for (HistoricProcessInstance instance : instances) { historyService.deleteHistoricProcessInstance(instance.getId()); } enableAuthorization(); }
Example #3
Source File: UserOperationLogAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryAfterDeletingDeploymentWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); createGrantAuthorizationWithoutAuthentication(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); disableAuthorization(); taskService.complete(taskId); enableAuthorization(); deleteDeployment(deploymentId, false); // when UserOperationLogQuery query = historyService.createUserOperationLogQuery(); // then verifyQueryResults(query, 3); disableAuthorization(); List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list(); for (HistoricProcessInstance instance : instances) { historyService.deleteHistoricProcessInstance(instance.getId()); } enableAuthorization(); }
Example #4
Source File: GetRunningHistoricProcessInstancesForOptimizeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void startedAfterParameterWorks() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process") .startEvent() .userTask() .endEvent() .done(); testHelper.deploy(simpleDefinition); Date now = new Date(); ClockUtil.setCurrentTime(now); engineRule.getRuntimeService().startProcessInstanceByKey("process"); Date nowPlus2Seconds = new Date(now.getTime() + 2000L); ClockUtil.setCurrentTime(nowPlus2Seconds); runtimeService.startProcessInstanceByKey("process"); // when List<HistoricProcessInstance> runningHistoricProcessInstances = optimizeService.getRunningHistoricProcessInstances(now, null, 10); // then assertThat(runningHistoricProcessInstances.size(), is(1)); }
Example #5
Source File: GetCompletedHistoricProcessInstancesForOptimizeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void fishedAtParameterWorks() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process") .startEvent() .endEvent() .done(); testHelper.deploy(simpleDefinition); Date now = new Date(); ClockUtil.setCurrentTime(now); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Date nowPlus2Seconds = new Date(now.getTime() + 2000L); ClockUtil.setCurrentTime(nowPlus2Seconds); runtimeService.startProcessInstanceByKey("process"); // when List<HistoricProcessInstance> completedHistoricProcessInstances = optimizeService.getCompletedHistoricProcessInstances(null, now, 10); // then assertThat(completedHistoricProcessInstances.size(), is(1)); assertThat(completedHistoricProcessInstances.get(0).getId(), is(processInstance.getId())); }
Example #6
Source File: GetRunningHistoricProcessInstancesForOptimizeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void startedAtParameterWorks() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process") .startEvent() .userTask() .endEvent() .done(); testHelper.deploy(simpleDefinition); Date now = new Date(); ClockUtil.setCurrentTime(now); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Date nowPlus2Seconds = new Date(now.getTime() + 2000L); ClockUtil.setCurrentTime(nowPlus2Seconds); runtimeService.startProcessInstanceByKey("process"); // when List<HistoricProcessInstance> runningHistoricProcessInstances = optimizeService.getRunningHistoricProcessInstances(null, now, 10); // then assertThat(runningHistoricProcessInstances.size(), is(1)); assertThat(runningHistoricProcessInstances.get(0).getId(), is(processInstance.getId())); }
Example #7
Source File: HistoricProcessInstanceQueryOrTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void shouldReturnHistoricProcInstWhereSameCriterionWasAppliedThreeTimesInOneQuery() { // given ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess"); ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // when List<HistoricProcessInstance> processInstances = historyService.createHistoricProcessInstanceQuery() .or() .processInstanceId(processInstance1.getId()) .processInstanceId(processInstance2.getId()) .processInstanceId(processInstance3.getId()) .endOr() .list(); // then assertEquals(1, processInstances.size()); }
Example #8
Source File: ProcessInstanceModificationHistoryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = ONE_TASK_PROCESS) public void testCancelTaskShouldCancelProcessInstance() { // given String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId(); // when runtimeService .createProcessInstanceModification(processInstanceId) .cancelAllForActivity("theTask") .execute(true, false); // then HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(instance); assertEquals(processInstanceId, instance.getId()); assertNotNull(instance.getEndTime()); }
Example #9
Source File: TerminateEndEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * 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()); } }
Example #10
Source File: GetRunningHistoricProcessInstancesForOptimizeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void fetchOnlyRunningProcessInstances() { // given BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process") .startEvent() .userTask() .endEvent() .done(); testHelper.deploy(simpleDefinition); runtimeService.startProcessInstanceByKey("process"); completeAllUserTasks(); ProcessInstance runningProcessInstance = runtimeService.startProcessInstanceByKey("process"); // when List<HistoricProcessInstance> runningHistoricProcessInstances = optimizeService.getRunningHistoricProcessInstances(pastDate(), null, 10); // then assertThat(runningHistoricProcessInstances.size(), is(1)); assertThat(runningHistoricProcessInstances.get(0).getId(), is(runningProcessInstance.getId())); }
Example #11
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testQueryWithRootIncidents() { // given deployment("org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryWithRootIncidents.bpmn20.xml"); deployment(CallActivityModels.oneBpmnCallActivityProcess("Process_1")); runtimeService.startProcessInstanceByKey("Process"); ProcessInstance calledProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("Process_1").singleResult(); testHelper.executeAvailableJobs(); // when List<HistoricProcessInstance> historicProcInstances = historyService.createHistoricProcessInstanceQuery().withRootIncidents().list(); // then assertNotNull(calledProcessInstance); assertEquals(1, historicProcInstances.size()); assertEquals(calledProcessInstance.getId(), historicProcInstances.get(0).getId()); }
Example #12
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment public void testProcessInstanceShouldBeActive() { // given // when String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); // then HistoricProcessInstance historicProcessInstance = historyService .createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); assertNull(historicProcessInstance.getEndTime()); assertNull(historicProcessInstance.getDurationInMillis()); }
Example #13
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testHistoricProcInstExecutedActivityBefore() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic process instance which has executed an activity before the start time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(now.getTime()).singleResult(); //then query returns result, since the query is less-then-equal assertNotNull(historicProcessInstance); //when query historic proc inst which executes an activity an hour before the starting time historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
Example #14
Source File: HistoricProcessInstanceRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public List<HistoricProcessInstanceDto> queryHistoricProcessInstances(HistoricProcessInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) { queryDto.setObjectMapper(objectMapper); HistoricProcessInstanceQuery query = queryDto.toQuery(processEngine); List<HistoricProcessInstance> matchingHistoricProcessInstances; if (firstResult != null || maxResults != null) { matchingHistoricProcessInstances = executePaginatedQuery(query, firstResult, maxResults); } else { matchingHistoricProcessInstances = query.list(); } List<HistoricProcessInstanceDto> historicProcessInstanceDtoResults = new ArrayList<HistoricProcessInstanceDto>(); for (HistoricProcessInstance historicProcessInstance : matchingHistoricProcessInstances) { HistoricProcessInstanceDto resultHistoricProcessInstanceDto = HistoricProcessInstanceDto.fromHistoricProcessInstance(historicProcessInstance); historicProcessInstanceDtoResults.add(resultHistoricProcessInstanceDto); } return historicProcessInstanceDtoResults; }
Example #15
Source File: UserOperationLogAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryAfterDeletingDeploymentWithoutAuthorization() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); disableAuthorization(); taskService.complete(taskId); enableAuthorization(); deleteDeployment(deploymentId, false); // when UserOperationLogQuery query = historyService.createUserOperationLogQuery(); // then verifyQueryResults(query, 0); disableAuthorization(); List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list(); for (HistoricProcessInstance instance : instances) { historyService.deleteHistoricProcessInstance(instance.getId()); } enableAuthorization(); }
Example #16
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @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()); }
Example #17
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testHistoricProcInstExecutedActivityWithEmptyInterval() { // given Calendar now = Calendar.getInstance(); ClockUtil.setCurrentTime(now.getTime()); BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done(); deployment(model); Calendar hourBeforeNow = (Calendar) now.clone(); hourBeforeNow.add(Calendar.HOUR, -1); runtimeService.startProcessInstanceByKey("proc"); //when query historic proc inst which executes an activity an hour before and after the starting time HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .executedActivityBefore(hourBeforeNow.getTime()) .executedActivityAfter(hourBeforeNow.getTime()).singleResult(); //then query returns no result assertNull(historicProcessInstance); }
Example #18
Source File: ProcessInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testSetRetriesByProcessAsyncHistoricQueryBasedWithNegativeRetries() { doThrow(new BadUserRequestException("retries are negative")) .when(mockManagementService).setJobRetriesAsync( anyListOf(String.class), eq((ProcessInstanceQuery) null), any(HistoricProcessInstanceQuery.class), eq(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES)); HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class); when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery); List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances(); when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances); SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto(); body.setRetries(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES); body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto()); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL); }
Example #19
Source File: BoundaryErrorEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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()); } }
Example #20
Source File: HistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testQueryByActiveActivityIdInAndProcessDefinitionKey() { // given deployment(ProcessModels.ONE_TASK_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process"); // when HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processDefinitionKey("Process") .activeActivityIdIn("userTask") .singleResult(); // then assertNotNull(historicProcessInstance); assertEquals(processInstance.getId(), historicProcessInstance.getId()); }
Example #21
Source File: ProcessInstantiationAtActivitiesHistoryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testHistoricProcessInstanceForSynchronousCompletion() { // when the process instance ends immediately ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .startAfterActivity("task1") .execute(); // then HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicInstance); assertEquals(instance.getId(), historicInstance.getId()); assertNotNull(historicInstance.getStartTime()); assertNotNull(historicInstance.getEndTime()); assertEquals("join", historicInstance.getStartActivityId()); }
Example #22
Source File: RestartProcessInstancesCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) { HistoryService historyService = commandContext.getProcessEngineConfiguration() .getHistoryService(); List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery() .executionIdIn(processInstance.getId()) .list(); VariableMap variables = new VariableMapImpl(); for (HistoricVariableInstance variable : historicVariables) { variables.putValueTyped(variable.getName(), variable.getTypedValue()); } return variables; }
Example #23
Source File: ActivityPerfTestWatcher.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void logActivityResults(PerfTestPass pass, PerfTestRun run, HistoryService historyService) { String processInstanceId = run.getVariable(PerfTestConstants.PROCESS_INSTANCE_ID); List<ActivityPerfTestResult> activityResults = new ArrayList<ActivityPerfTestResult>(); HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); Date startTime = processInstance.getStartTime(); List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId) .orderByHistoricActivityInstanceStartTime() .asc() .list(); for (HistoricActivityInstance activityInstance : activityInstances) { if (watchAllActivities || activityIds.contains(activityInstance.getActivityId())) { ActivityPerfTestResult result = new ActivityPerfTestResult(activityInstance); if (activityInstance.getActivityType().equals("startEvent")) { result.setStartTime(startTime); } activityResults.add(result); } } pass.logActivityResult(processInstanceId, activityResults); }
Example #24
Source File: BoundedNumberOfMaxResultsTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) @Test public void shouldReturnSingleResult_BoundedMaxResults() { // given BpmnModelInstance process = Bpmn.createExecutableProcess("process") .startEvent() .endEvent() .done(); testHelper.deploy(process); runtimeService.startProcessInstanceByKey("process"); HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery(); // when HistoricProcessInstance processInstance = historicProcessInstanceQuery.singleResult(); // then assertThat(processInstance).isNotNull(); }
Example #25
Source File: DefaultHistoryEventProducer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public HistoryEvent createProcessInstanceUpdateEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; // create event instance HistoricProcessInstanceEventEntity evt = loadProcessInstanceEventEntity(executionEntity); // initialize event initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_UPDATE); if (executionEntity.isSuspended()) { evt.setState(HistoricProcessInstance.STATE_SUSPENDED); } else { evt.setState(HistoricProcessInstance.STATE_ACTIVE); } return evt; }
Example #26
Source File: HistoryServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/otherOneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByProcessInstanceIds() { HashSet<String> processInstanceIds = new HashSet<String>(); for (int i = 0; i < 4; i++) { processInstanceIds.add(runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS, i + "").getId()); } processInstanceIds.add(runtimeService.startProcessInstanceByKey("otherOneTaskProcess", "1").getId()); // start an instance that will not be part of the query runtimeService.startProcessInstanceByKey("otherOneTaskProcess", "2"); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIds); assertEquals(5, processInstanceQuery.count()); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertNotNull(processInstances); assertEquals(5, processInstances.size()); for (HistoricProcessInstance historicProcessInstance : processInstances) { assertTrue(processInstanceIds.contains(historicProcessInstance.getId())); } // making a query that has contradicting conditions should succeed assertEquals(0, processInstanceQuery.processInstanceId("dummy").count()); }
Example #27
Source File: RemovalTimeStrategyStartTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldResolveHistoricProcessInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .activeActivityIdIn("userTask") .singleResult(); // assume assertThat(historicProcessInstance, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicProcessInstance.getRemovalTime(), is(removalTime)); }
Example #28
Source File: DbDeadlockTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override protected void tearDown() throws Exception { // end interaction with Thread 2 thread2.waitUntilDone(); // end interaction with Thread 1 thread1.waitUntilDone(); processEngineConfiguration.getCommandExecutorTxRequired() .execute(new Command<Void>() { public Void execute(CommandContext commandContext) { List<HistoricProcessInstance> list = commandContext.getDbEntityManager().createHistoricProcessInstanceQuery().list(); for (HistoricProcessInstance historicProcessInstance : list) { commandContext.getDbEntityManager().delete(HistoricProcessInstanceEventEntity.class, "deleteHistoricProcessInstance", historicProcessInstance.getId()); } return null; } }); }
Example #29
Source File: MigrationHistoricProcessInstanceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void testMigrateHistoryProcessInstanceState() { //given HistoricProcessInstanceQuery sourceHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery() .processDefinitionId(sourceProcessDefinition.getId()); HistoricProcessInstanceQuery targetHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery() .processDefinitionId(targetProcessDefinition.getId()); HistoricProcessInstance historicProcessInstanceBeforeMigration = sourceHistoryProcessInstanceQuery.singleResult(); assertEquals(HistoricProcessInstance.STATE_ACTIVE, historicProcessInstanceBeforeMigration.getState()); //when ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId()); runtimeService.newMigration(migrationPlan) .processInstanceQuery(sourceProcessInstanceQuery) .execute(); //then HistoricProcessInstance instance = targetHistoryProcessInstanceQuery.singleResult(); assertEquals(historicProcessInstanceBeforeMigration.getState(), instance.getState()); }
Example #30
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldNotSetRemovalTimeInHierarchy_BaseTimeEnd() { // given testRule.getProcessEngineConfiguration() .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END) .initHistoryRemovalTime(); testRule.process().call().ttl(5).userTask().deploy().start(); List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list(); // assume assertThat(historicProcessInstances.get(0).getRemovalTime()).isNull(); assertThat(historicProcessInstances.get(1).getRemovalTime()).isNull(); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().rootProcessInstances(); // when testRule.syncExec( historyService.setRemovalTimeToHistoricProcessInstances() .calculatedRemovalTime() .byQuery(query) .hierarchical() .executeAsync() ); historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list(); // then assertThat(historicProcessInstances.get(0).getRemovalTime()).isNull(); assertThat(historicProcessInstances.get(1).getRemovalTime()).isNull(); }