This commit is contained in:
Keith Donald
2008-03-07 14:54:16 +00:00
parent 8ca484af35
commit 448a00b6f6
3 changed files with 32 additions and 0 deletions

View File

@@ -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.

View File

@@ -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()));

View File

@@ -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") {