Fix choice state create

- Fix so that we don't need to define choice
  pseudostate as state.
This commit is contained in:
Janne Valkealahti
2015-05-15 16:15:34 +01:00
parent d29c240ad0
commit d5811c3ac4
2 changed files with 14 additions and 0 deletions

View File

@@ -171,6 +171,7 @@ public class DefaultStateConfigurer<S, E>
@Override
public StateConfigurer<S, E> choice(S choice) {
state(choice);
choices.add(choice);
return this;
}

View File

@@ -31,6 +31,7 @@ import org.springframework.statemachine.AbstractStateMachineTests.TestStates;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.StateData;
import org.springframework.statemachine.config.builders.StateMachineStateBuilder;
import org.springframework.statemachine.state.PseudoStateKind;
public class DefaultStateConfigurerTests {
@@ -140,6 +141,18 @@ public class DefaultStateConfigurerTests {
assertThat(builder.data.iterator().next().getState(), is(TestStates.SF));
}
@Test
public void testChoiceStateNoState() throws Exception {
DefaultStateConfigurer<TestStates, TestEvents> configurer = new DefaultStateConfigurer<TestStates, TestEvents>();
TestStateMachineStateBuilder builder = new TestStateMachineStateBuilder();
configurer.choice(TestStates.S1);
configurer.configure(builder);
assertThat(builder.data, notNullValue());
assertThat(builder.data.size(), is(1));
assertThat(builder.data.iterator().next().getState(), is(TestStates.S1));
assertThat(builder.data.iterator().next().getPseudoStateKind(), is(PseudoStateKind.CHOICE));
}
private static class TestStateMachineStateBuilder extends StateMachineStateBuilder<TestStates, TestEvents> {
Collection<StateData<TestStates, TestEvents>> data;