newProcessInstanceMock("p2", BUSINESS_KEY, false),
newProcessInstanceMock("p3", BUSINESS_KEY, true)
);
final RuntimeService runtimeService = mock(RuntimeService.class);
final ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);
when(engine.getRuntimeService()).thenReturn(runtimeService);
when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, BUSINESS_KEY))
.thenReturn(processInstanceQuery);
when(processInstanceQuery.orderByProcessInstanceId()).thenReturn(processInstanceQuery);
when(processInstanceQuery.desc()).thenReturn(processInstanceQuery);
when(processInstanceQuery.list()).thenReturn(processes);
return engine;
}