use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createHistoricActivityInstanceMock.
private void createHistoricActivityInstanceMock() {
List<HistoricActivityInstance> activities = new ArrayList<HistoricActivityInstance>();
HistoricActivityInstance mockInstance = MockProvider.createMockHistoricActivityInstance();
activities.add(mockInstance);
HistoricActivityInstanceQuery mockHistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockHistoricActivityInstanceQuery.list()).thenReturn(activities);
when(mockHistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockHistoricActivityInstanceQuery);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceImpl method queryHistoricActivityInstancesCount.
@Override
public CountResultDto queryHistoricActivityInstancesCount(HistoricActivityInstanceQueryDto queryDto) {
queryDto.setObjectMapper(objectMapper);
HistoricActivityInstanceQuery query = queryDto.toQuery(processEngine);
long count = query.count();
CountResultDto result = new CountResultDto();
result.setCount(count);
return result;
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceQueryTest method setUpMockHistoricActivityInstanceQuery.
private HistoricActivityInstanceQuery setUpMockHistoricActivityInstanceQuery(List<HistoricActivityInstance> mockedHistoricActivityInstances) {
HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances);
when(mockedhistoricActivityInstanceQuery.count()).thenReturn((long) mockedHistoricActivityInstances.size());
when(processEngine.getHistoryService().createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery);
return mockedhistoricActivityInstanceQuery;
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceQueryTest method testUnfinishedHistoricActivityQuery.
@Test
public void testUnfinishedHistoricActivityQuery() {
List<HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances();
HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances);
when(processEngine.getHistoryService().createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery);
Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery);
inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished();
inOrder.verify(mockedhistoricActivityInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one activity instance returned.", 1, instances.size());
Assert.assertNotNull("The returned activity instance should not be null.", instances.get(0));
String returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
String returnedActivityEndTime = from(content).getString("[0].endTime");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
Assert.assertNull(returnedActivityEndTime);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceQueryTest method testUnfinishedHistoricActivityQueryAsPost.
@Test
public void testUnfinishedHistoricActivityQueryAsPost() {
List<HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances();
HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances);
when(processEngine.getHistoryService().createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery);
Map<String, Boolean> body = new HashMap<String, Boolean>();
body.put("unfinished", true);
Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery);
inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished();
inOrder.verify(mockedhistoricActivityInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one activity instance returned.", 1, instances.size());
Assert.assertNotNull("The returned activity instance should not be null.", instances.get(0));
String returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
String returnedActivityEndTime = from(content).getString("[0].endTime");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
Assert.assertNull(returnedActivityEndTime);
}
Aggregations