StateExecutionImpl extends ModelObject implements StateExecution { @Override public List<WorkflowInstance> queryChildWorkflows(QueryWorkflowInstances query) { QueryWorkflowInstances restrictedQuery = new QueryWorkflowInstances.Builder(query).setParentWorkflowId(instance.id).build(); return workflowDao.queryWorkflowInstances(restrictedQuery); } StateExecutionImpl(WorkflowInstance instance, ObjectStringMapper objectMapper, WorkflowInstanceDao workflowDao,
      WorkflowInstancePreProcessor workflowInstancePreProcessor, WorkflowInstanceService workflowInstanceService); DateTime getNextActivation(); String getNextState(); String getNextStateReason(); String getCurrentStateName(); @Override long getWorkflowInstanceId(); @Override String getWorkflowInstanceExternalId(); @Override String getBusinessKey(); @Override int getRetries(); @Override String getVariable(String name); @Override T getVariable(String name, Class<T> type); @Override @SuppressWarnings("unchecked") T getVariable(String name, Class<T> type, T defaultValue); @Override String getVariable(String name, String defaultValue); @Override void setVariable(String name, String value); @Override void setVariable(String name, Object value); void setNextActivation(DateTime activation); void setNextState(WorkflowState state); void setNextStateReason(String reason); boolean isRetry(); void setRetry(boolean isRetry); boolean isFailed(); Throwable getThrown(); void setFailed(); void setFailed(Throwable t); boolean isRetryCountExceeded(); @Override void addChildWorkflows(WorkflowInstance... childWorkflows); @Override void addWorkflows(WorkflowInstance... workflows); List<WorkflowInstance> getNewChildWorkflows(); List<WorkflowInstance> getNewWorkflows(); @Override List<WorkflowInstance> queryChildWorkflows(QueryWorkflowInstances query); @Override List<WorkflowInstance> getAllChildWorkflows(); @Override void wakeUpParentWorkflow(String... expectedStates); Optional<List<String>> getWakeUpParentWorkflowStates(); @Override WorkflowInstance.Builder workflowInstanceBuilder(); void setStateProcessInvoked(boolean isStateProcessInvoked); boolean isStateProcessInvoked(); @Override void setCreateAction(boolean createAction); boolean createAction(); @Override Optional<Integer> getSignal(); @Override void setSignal(Optional<Integer> signal, String reason); @Override Optional<Long> getParentId(); @Override void setHistoryCleaningForced(boolean historyCleaningForced); boolean isHistoryCleaningForced(); void handleRetryAfter(DateTime activation, AbstractWorkflowDefinition<?> definition); void handleFailure(AbstractWorkflowDefinition<?> definition, String failureReason);  }
@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)); }