polish
This commit is contained in:
@@ -75,6 +75,16 @@ public class Transition extends AnnotatedObject implements TransitionDefinition
|
||||
*/
|
||||
private TargetStateResolver targetStateResolver;
|
||||
|
||||
/**
|
||||
* Create a new transition that always matches and always executes, but its execution does nothing by default.
|
||||
* @see #setMatchingCriteria(TransitionCriteria)
|
||||
* @see #setExecutionCriteria(TransitionCriteria)
|
||||
* @see #setTargetStateResolver(TargetStateResolver)
|
||||
*/
|
||||
public Transition() {
|
||||
this(WildcardTransitionCriteria.INSTANCE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new transition that always matches and always executes, transitioning to the target state calculated by
|
||||
* the provided targetStateResolver.
|
||||
|
||||
@@ -71,6 +71,9 @@ class TextToTargetStateResolver extends AbstractConverter {
|
||||
|
||||
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
|
||||
String targetStateId = (String) source;
|
||||
if (targetStateId == null) {
|
||||
return null;
|
||||
}
|
||||
ExpressionParser parser = flowBuilderContext.getExpressionParser();
|
||||
if (targetStateId.startsWith(BEAN_PREFIX)) {
|
||||
return flowBuilderContext.getBeanFactory().getBean(targetStateId.substring(BEAN_PREFIX.length()));
|
||||
|
||||
@@ -98,6 +98,25 @@ public class TransitionTests extends TestCase {
|
||||
assertSame(source, context.getCurrentState());
|
||||
}
|
||||
|
||||
public void testExecuteTransitionNullTargetStateResolver() {
|
||||
Flow flow = new Flow("flow");
|
||||
final TransitionableState source = new TransitionableState(flow, "state 1") {
|
||||
public void exit(RequestControlContext context) {
|
||||
exitCalled = true;
|
||||
}
|
||||
|
||||
protected void doEnter(RequestControlContext context) throws FlowExecutionException {
|
||||
}
|
||||
};
|
||||
MockRequestControlContext context = new MockRequestControlContext(flow);
|
||||
context.setCurrentState(source);
|
||||
Transition t = new Transition();
|
||||
boolean stateExited = t.execute(source, context);
|
||||
assertFalse(stateExited);
|
||||
assertFalse(exitCalled);
|
||||
assertSame(source, context.getCurrentState());
|
||||
}
|
||||
|
||||
public void testTransitionExecutionRefused() {
|
||||
Flow flow = new Flow("flow");
|
||||
final TransitionableState source = new TransitionableState(flow, "state 1") {
|
||||
|
||||
Reference in New Issue
Block a user