use of org.springframework.statemachine.config.ObjectStateMachineFactory in project cloudbreak by hortonworks.
the class AbstractActionTest method setup.
@Before
public void setup() throws Exception {
underTest = spy(new TestAction());
underTest.setFailureEvent(Event.FAILURE);
MockitoAnnotations.initMocks(this);
BDDMockito.given(flow.getFlowId()).willReturn(FLOW_ID);
BDDMockito.given(runningFlows.get(anyString())).willReturn(flow);
StateMachineConfigurationBuilder<State, Event> configurationBuilder = new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configurationBuilder.setTaskExecutor(new SyncTaskExecutor());
StateMachineStateBuilder<State, Event> stateBuilder = new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
stateBuilder.withStates().initial(State.INIT).state(State.DOING, underTest, null);
StateMachineTransitionBuilder<State, Event> transitionBuilder = new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
transitionBuilder.withExternal().source(State.INIT).target(State.DOING).event(Event.DOIT);
stateMachine = new ObjectStateMachineFactory<>(configurationBuilder.build(), transitionBuilder.build(), stateBuilder.build()).getStateMachine();
stateMachine.start();
}
Aggregations