use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryByCaseInstanceIdHierarchy.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceId.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-super.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-sub.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
// then
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricProcessInstance hpi : query.list()) {
assertEquals(caseInstanceId, hpi.getCaseInstanceId());
}
// complete existing user task -> completes the process instance(s)
String taskId = taskService.createTaskQuery().caseInstanceId(caseInstanceId).singleResult().getId();
taskService.complete(taskId);
// the completed historic process instance is still associated with the
// case instance id
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricProcessInstance hpi : query.list()) {
assertEquals(caseInstanceId, hpi.getCaseInstanceId());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryByInvalidCaseInstanceId.
public void testQueryByInvalidCaseInstanceId() {
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
query.caseInstanceId("invalid");
assertEquals(0, query.count());
assertEquals(0, query.list().size());
query.caseInstanceId(null);
assertEquals(0, query.count());
assertEquals(0, query.list().size());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryBySuperCaseInstanceId.
@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());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryBySubCaseInstanceId.
@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());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery.
@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyInt())).thenReturn(batchEntity);
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_JOB_RETRIES);
body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
Response response = given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
verifyBatchJson(response.asString());
verify(mockManagementService, times(1)).setJobRetriesAsync(eq(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_JOB_RETRIES));
}
Aggregations