List<HistoricProcessInstance> mockedHistoricProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
HistoricProcessInstanceQuery mockedhistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
when(mockedhistoricProcessInstanceQuery.list()).thenReturn(mockedHistoricProcessInstances);
when(processEngine.getHistoryService().createHistoricProcessInstanceQuery()).thenReturn(mockedhistoricProcessInstanceQuery);
Response response = given()
.queryParam("unfinished", true)
.then()
.expect()
.statusCode(Status.OK.getStatusCode())
.when()
.get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedhistoricProcessInstanceQuery);
inOrder.verify(mockedhistoricProcessInstanceQuery).unfinished();
inOrder.verify(mockedhistoricProcessInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one process instance returned.", 1, instances.size());
Assert.assertNotNull("The returned process instance should not be null.", instances.get(0));
String returnedProcessInstanceId = from(content).getString("[0].id");