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");