StateExecutionImpl extends ModelObject implements StateExecution { @Override public String getVariable(String name) { return getVariable(name, (String) null); } 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 getMissingStringVariableReturnsNull() { assertThat(execution.getVariable("foo"), is(nullValue())); }
@Test public void getMissingStringVariableWithDefaultReturnDefaultValue() { assertThat(execution.getVariable("foo", "default"), is("default")); }
@Test public void getMissingVariableReturnsNull() { assertThat(execution.getVariable("foo", Data.class), is(nullValue())); }
@Test public void getMissingVariableWithDefaultReturnsDefaultValue() { Data defaultData = new Data(42, "foobar"); assertThat(execution.getVariable("foo", Data.class, defaultData), is(defaultData)); }