You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are facing a problem regarding usage of whenMvel. We have two transitions from one state to another state, where depending on an Mvel expression we want to execute different actions. The state machine is failing with
java.lang.RuntimeException: Tansition 'initial-[Start, _NoName_, 1, EXTERNAL]->second' is conflicted with 'initial-[Start, _NoName_, 1, EXTERNAL]->second'.
at org.squirrelframework.foundation.fsm.impl.StateImpl.verify(StateImpl.java:560)
at org.squirrelframework.foundation.fsm.impl.StateMachineBuilderImpl.verifyStateMachineDefinition(StateMachineBuilderImpl.java:487)
at org.squirrelframework.foundation.fsm.impl.StateMachineBuilderImpl.prepare(StateMachineBuilderImpl.java:532)
at org.squirrelframework.foundation.fsm.impl.StateMachineBuilderImpl.newStateMachine(StateMachineBuilderImpl.java:706)
at com.buongiorno.be3aapi.services.authflow.TestStateMachineIssues.testMvelDiscriminatesTransition (TestStateMachineIssues.java:28)
(btw, there's a typo in that exception message: 'Tansition').
This is the test case:
public class TestStateMachineIssues {
@Test
public void testSetDebugEnabledDoesntBreak() {
StateMachineBuilder<AuthFlowStateMachine, String, Object, Context> builder = StateMachineBuilderFactory.create(AuthFlowStateMachine.class, String.class, Object.class, Context.class);
builder.externalTransition().from("initial").to("second").on("Start");
AuthFlowStateMachine stateMachine = builder.newStateMachine("initial", StateMachineConfiguration.create().enableDebugMode(true));
stateMachine.fire("Start", new Context());
assertEquals("second", stateMachine.getCurrentState());
}
@Test
public void testMvelDiscriminatesTransitions() {
StateMachineBuilder<AuthFlowStateMachine, String, Object, Context> builder = StateMachineBuilderFactory.create(AuthFlowStateMachine.class, String.class, Object.class, Context.class);
TestAction action1 = new TestAction();
TestAction action2 = new TestAction();
builder.externalTransition().from("initial").to("second").on("Start").whenMvel("3 > 2").perform(action1);
builder.externalTransition().from("initial").to("second").on("Start").whenMvel("3 < 2").perform(action2);
AuthFlowStateMachine stateMachine = builder.newStateMachine("initial", StateMachineConfiguration.create().enableDebugMode(true));
stateMachine.fire("Start", new Context());
assertEquals("second", stateMachine.getCurrentState());
}
}
class TestAction extends AnonymousAction<AuthFlowStateMachine, String, Object, Context> {
@Override
public void execute(String arg0, String arg1, Object arg2, Context arg3, AuthFlowStateMachine arg4) {}
}
class Context {
}
class AuthFlowStateMachine extends AbstractStateMachine<AuthFlowStateMachine, String, Object, Context> {
}
So, it looks like the whenMvel expression is not enough to discriminate between both transitions.
Is there any way around this limitation?
The text was updated successfully, but these errors were encountered:
Yes this is a bug. I just fixed it. Now the condition will be differentiated by its name(originally was by its class name which cause cannot differentiate mvel condition), which means in order to make your test case works you need to specify mvel condition name. You can refer to the following test case. Issue39
Hi,
We are facing a problem regarding usage of whenMvel. We have two transitions from one state to another state, where depending on an Mvel expression we want to execute different actions. The state machine is failing with
(btw, there's a typo in that exception message: 'Tansition').
This is the test case:
So, it looks like the whenMvel expression is not enough to discriminate between both transitions.
Is there any way around this limitation?
The text was updated successfully, but these errors were encountered: