ProcessInstanceQuery instanceQuery = mock(ProcessInstanceQuery.class);
when(instanceQuery.list()).thenReturn(mockProcessInstanceList);
when(processEngine.getRuntimeService().createProcessInstanceQuery()).thenReturn(instanceQuery);
Response response = given()
.queryParam("processInstanceIds", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST_WITH_DUP)
.then()
.expect()
.statusCode(Status.OK.getStatusCode())
.when()
.get(PROCESS_INSTANCE_QUERY_URL);
// assert query invocation
InOrder inOrder = Mockito.inOrder(instanceQuery);
Set<String> expectedSet = MockProvider.createMockSetFromList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST);
inOrder.verify(instanceQuery).processInstanceIds(expectedSet);
inOrder.verify(instanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be two process definitions returned.", 2, instances.size());
String returnedInstanceId1 = from(content).getString("[0].id");
String returnedInstanceId2 = from(content).getString("[1].id");