Add tests for turnstile sample

This commit is contained in:
Janne Valkealahti
2015-05-30 09:29:10 +01:00
parent 9fc17338e6
commit 7d26f505a1
2 changed files with 162 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.state.State;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -43,7 +44,12 @@ public class AbstractStateMachineCommands<S, E> implements CommandMarker {
@CliCommand(value = "sm state", help = "Prints current state")
public String state() {
return StringUtils.collectionToCommaDelimitedString(stateMachine.getState().getIds());
State<S, E> state = stateMachine.getState();
if (state != null) {
return StringUtils.collectionToCommaDelimitedString(state.getIds());
} else {
return "No state";
}
}
@CliCommand(value = "sm start", help = "Start a state machine")