If I have a StateMachine set up as below:
transitionConfigurer
.withExternal()
.source(FIRST)
.event(EVENT_1)
.target(SECOND)
.and()
.withChoice()
.source(SECOND)
.first(THIRD, new Guard(someService))
.last(FIRST)
.and()
.withExternal()
.source(THIRD)
.event(EVENT_2)
.target(FIRST);
How can I test the withChoice using a StateMachineTestPlan.
I have a StateMachineTestPlan set up as below, this creates a State Machine with an initial state of SECOND, I want to then be able to test the choice. However, when I perform the .step() in the test plan nothing happens:
createStateMachineAndSetInitialState(SECOND, workflowCreator);
StateMachineTestPlan<State, Event> plan = StateMachineTestPlanBuilder.<State, Event> builder()
.defaultAwaitTime(1)
.stateMachine(machine)
.step()
.expectState(THIRD)
.and()
.build();
plan.test();
First of all, can you please share your custom override for the method below?
You need to make sure you have configured choice states like this:
It seems like you reached state (SECOND) but did not enter in the CHOICE pseudo-state. In which state have your test stopped at?