@Test
public void queryChildWorkflowsIsRestrictedToChildsOfCurrentWorkflow() {

  QueryWorkflowInstances query = new QueryWorkflowInstances.Builder()
          .setParentActionId(42L).addTypes("a","b")
          .setBusinessKey("123").build();
  List<WorkflowInstance> result = singletonList(mock(WorkflowInstance.class));
  when(workflowDao.queryWorkflowInstances(queryCaptor.capture())).thenReturn(result);
  assertThat(execution.queryChildWorkflows(query), is(result));
  QueryWorkflowInstances actualQuery = queryCaptor.getValue();
  assertThat(actualQuery.parentWorkflowId, is(99L));
  assertThat(actualQuery.types, is(asList("a", "b")));
  assertThat(actualQuery.businessKey, is("123"));
  assertThat(actualQuery.includeCurrentStateVariables, is(false));
}