コード例 #1
0
ファイル: Issue39.java プロジェクト: vgaur/squirrel
 @Test
 public void testMvelDiscriminatesTransitionsByConditionName() {
   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("script1:::3 > 2")
       .perform(action1);
   builder
       .externalTransition()
       .from("initial")
       .to("second")
       .on("Start")
       .whenMvel("script2:::3 < 2")
       .perform(action2);
   AuthFlowStateMachine stateMachine =
       builder.newStateMachine(
           "initial", StateMachineConfiguration.create().enableDebugMode(true));
   stateMachine.fire("Start", new Context());
   Assert.assertEquals("second", stateMachine.getCurrentState());
 }
コード例 #2
0
ファイル: Issue39.java プロジェクト: vgaur/squirrel
 @Test(expected = RuntimeException.class)
 public void testMvelCannotDiscriminatesTransitionsByConditionName() {
   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));
 }
コード例 #3
0
ファイル: Issue39.java プロジェクト: vgaur/squirrel
  @Test(expected = RuntimeException.class)
  public void testCannotDiscriminatesTransitionsByConditionName() {
    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")
        .when(
            new Condition<Context>() {
              @Override
              public boolean isSatisfied(Context context) {
                return true;
              }

              @Override
              public String name() {
                return "duplicateName";
              }
            })
        .perform(action1);
    builder
        .externalTransition()
        .from("initial")
        .to("second")
        .on("Start")
        .when(
            new Condition<Context>() {
              @Override
              public boolean isSatisfied(Context context) {
                return true;
              }

              @Override
              public String name() {
                return "duplicateName";
              }
            })
        .perform(action2);
    AuthFlowStateMachine stateMachine =
        builder.newStateMachine(
            "initial", StateMachineConfiguration.create().enableDebugMode(true));
  }