use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstances.
public List<HistoricCaseInstanceDto> queryHistoricCaseInstances(HistoricCaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricCaseInstance> matchingHistoricCaseInstances;
if (firstResult != null || maxResults != null) {
matchingHistoricCaseInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingHistoricCaseInstances = query.list();
}
List<HistoricCaseInstanceDto> historicCaseInstanceDtoResults = new ArrayList<HistoricCaseInstanceDto>();
for (HistoricCaseInstance historicCaseInstance : matchingHistoricCaseInstances) {
HistoricCaseInstanceDto resultHistoricCaseInstanceDto = HistoricCaseInstanceDto.fromHistoricCaseInstance(historicCaseInstance);
historicCaseInstanceDtoResults.add(resultHistoricCaseInstanceDto);
}
return historicCaseInstanceDtoResults;
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceQueryTest method testCaseQueryNotClosed.
@Test
public void testCaseQueryNotClosed() {
List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances();
HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class);
when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances);
when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery);
Response response = given().queryParam("notClosed", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery);
inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed();
inOrder.verify(mockedHistoricCaseInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals(1, instances.size());
Assert.assertNotNull(instances.get(0));
String returnedCaseInstanceId = from(content).getString("[0].id");
String returnedCloseTime = from(content).getString("[0].closeTime");
Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId);
Assert.assertEquals(null, returnedCloseTime);
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricCaseInstanceNotClosed.
public static HistoricCaseInstance createMockHistoricCaseInstanceNotClosed() {
HistoricCaseInstance mock = createMockHistoricCaseInstance();
when(mock.getCloseTime()).thenReturn(null);
when(mock.getDurationInMillis()).thenReturn(null);
when(mock.isActive()).thenReturn(true);
when(mock.isCompleted()).thenReturn(false);
when(mock.isTerminated()).thenReturn(false);
when(mock.isClosed()).thenReturn(false);
return mock;
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseInstanceCmdsTenantCheckTest method terminateCaseExecutionWithAuthenticatedTenant.
@Test
public void terminateCaseExecutionWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
caseService.terminateCaseExecution(caseInstanceId);
HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance();
assertThat(historicCaseInstance, notNullValue());
assertThat(historicCaseInstance.isTerminated(), is(true));
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseInstanceCmdsTenantCheckTest method closeCaseInstanceWithAuthenticatedTenant.
@Test
public void closeCaseInstanceWithAuthenticatedTenant() {
caseService.completeCaseExecution(caseInstanceId);
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
caseService.closeCaseInstance(caseInstanceId);
identityService.clearAuthentication();
HistoricCaseInstance historicCaseInstance = getHistoricCaseInstance();
assertThat(historicCaseInstance, notNullValue());
assertThat(historicCaseInstance.isClosed(), is(true));
}
Aggregations