public void ParallelStateWithCatchers() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End()) .Branches( StateMachineBuilder.SubStateMachine() .Comment("Branch one") .StartAt("BranchOneInitial") .State("BranchOneInitial", StateMachineBuilder.SucceedState()), StateMachineBuilder.SubStateMachine() .Comment("Branch two") .StartAt("BranchTwoInitial") .State("BranchTwoInitial", StateMachineBuilder.SucceedState()) ) .Catchers(StateMachineBuilder.Catcher() .ErrorEquals("Foo", "Bar") .Transition(StateMachineBuilder.Next("RecoveryState")) .ResultPath("$.result"), StateMachineBuilder.Catcher() .CatchAll() .Transition(StateMachineBuilder.Next("OtherRecoveryState")) .ResultPath("$.result") )) .State("RecoveryState", StateMachineBuilder.SucceedState()) .State("OtherRecoveryState", StateMachineBuilder.SucceedState()) .Build(); AssertStateMachine(stateMachine, "ParallelStateWithCatchers.json"); }
public void ParallelState_ChoiceStateWithTerminalPath_IsValid() { AssertHasPathToTerminal( StateMachineBuilder.StateMachine() .StartAt("Parallel") .State("Parallel", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End()) .Branch(StateMachineBuilder.SubStateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.PassState() .Transition(StateMachineBuilder .Next("Choice"))) .State("Choice", StateMachineBuilder.ChoiceState() .DefaultStateName("Default") .Choice(StateMachineBuilder.Choice() .Transition(StateMachineBuilder .Next("Initial")) .Condition(StateMachineBuilder .StringEquals("$.foo", "bar"))) .Choice(StateMachineBuilder.Choice() .Transition(StateMachineBuilder .Next("Default")) .Condition(StateMachineBuilder .StringEquals("$.foo", "bar")))) .State("Default", StateMachineBuilder .PassState().Transition(StateMachineBuilder.End()))))); }
public void ParallelStateWithRetriers() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End()) .Branches( StateMachineBuilder.SubStateMachine() .Comment("Branch one") .StartAt("BranchOneInitial") .State("BranchOneInitial", StateMachineBuilder.SucceedState()), StateMachineBuilder.SubStateMachine() .Comment("Branch two") .StartAt("BranchTwoInitial") .State("BranchTwoInitial", StateMachineBuilder.SucceedState()) ) .Retriers(StateMachineBuilder.Retrier() .ErrorEquals("Foo", "Bar") .IntervalSeconds(10) .BackoffRate(1.0) .MaxAttempts(3), StateMachineBuilder.Retrier() .RetryOnAllErrors() .IntervalSeconds(10) .BackoffRate(1.0) .MaxAttempts(3) )) .Build(); AssertStateMachine(stateMachine, "ParallelStateWithRetriers.json"); }
public void SimpleParallelState() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.ParallelState() .Comment("My parallel state") .InputPath("$.input") .OutputPath("$.output") .ResultPath("$.result") .Parameters(JObject.FromObject(new { value = "param" })) .ResultSelector(JObject.FromObject(new { value = "param" })) .Transition(StateMachineBuilder.Next("NextState")) .Branches( StateMachineBuilder.SubStateMachine() .Comment("Branch one") .StartAt("BranchOneInitial") .State("BranchOneInitial", StateMachineBuilder.SucceedState()), StateMachineBuilder.SubStateMachine() .Comment("Branch two") .StartAt("BranchTwoInitial") .State("BranchTwoInitial", StateMachineBuilder.SucceedState()) )) .State("NextState", StateMachineBuilder.SucceedState()) .Build(); AssertStateMachine(stateMachine, "SimpleParallelState.json"); }
public void ParallelStateWithNoBranches_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End())) .Build()); }
public void ParallelStateInvalidBranchState_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Branch(StateMachineBuilder.SubStateMachine() .StartAt("InitialBranchState") .State("InitialBranchState", StateMachineBuilder.FailState())) .Transition(StateMachineBuilder.End())) .Build()); }
public void ParallelStateWithInvalidTransition_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Branch(StateMachineBuilder.SubStateMachine() .StartAt("InitialBranchState") .State("InitialBranchState", StateMachineBuilder.SucceedState())) .Transition(StateMachineBuilder.Next("NoSuchState"))) .Build()); }
public void ParallelStateInvalidRetrier_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Branch(StateMachineBuilder.SubStateMachine() .StartAt("InitialBranchState") .State("InitialBranchState", StateMachineBuilder.SucceedState())) .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .IntervalSeconds(-1))) .Build()); }
public void ParallelState_NoCycles() { AssertNoCycle(StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Branch(StateMachineBuilder.SubStateMachine() .StartAt("BranchOneStart") .State("BranchOneStart", StateMachineBuilder.SucceedState())) .Branch(StateMachineBuilder.SubStateMachine() .StartAt("BranchTwoStart") .State("BranchTwoStart", StateMachineBuilder.PassState() .Transition(StateMachineBuilder .Next("NextState"))) .State("NextState", StateMachineBuilder.SucceedState())) .Transition(StateMachineBuilder.End()))); }
public void ParallelState_WithCycles_IsNotValid() { Assert.Throws <ValidationException>(() => AssertCycle(StateMachineBuilder.StateMachine() .StartAt("Parallel") .State("Parallel", StateMachineBuilder.ParallelState() .Branch(StateMachineBuilder.SubStateMachine() .StartAt("BranchOneInitial") .State("BranchOneInitial", StateMachineBuilder .PassState() .Transition(StateMachineBuilder .Next("CyclicState"))) .State("CyclicState", StateMachineBuilder .PassState() .Transition(StateMachineBuilder .Next("BranchOneInitial")))) .Transition(StateMachineBuilder.End())))); }
public void SimpleParallelStateWithTasks() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("para") .State("para", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End()) .Branches( StateMachineBuilder.SubStateMachine() .StartAt("t") .State("t", StateMachineBuilder.TaskState().Resource("t").Transition(StateMachineBuilder.End())), StateMachineBuilder.SubStateMachine() .StartAt("u") .State("u", StateMachineBuilder.TaskState().Resource("u").Transition(StateMachineBuilder.End())) )) .Build(); AssertStateMachine(stateMachine, "SimpleParallelStateWithTasks.json"); }
public void ParallelState_WithChoiceThatHasNoTerminalPath_IsNotValid() { Assert.Throws <ValidationException>(() => AssertDoesNotHaveTerminalPath( StateMachineBuilder.StateMachine() .StartAt("Parallel") .State("Parallel", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End()) .Branch(StateMachineBuilder.SubStateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder .PassState() .Transition(StateMachineBuilder .Next("Choice"))) .State("Choice", StateMachineBuilder .ChoiceState() .DefaultStateName("Default") .Choice(StateMachineBuilder .Choice() .Transition(StateMachineBuilder .Next("Initial")) .Condition(StateMachineBuilder .StringEquals("$.foo", "bar"))) .Choice(StateMachineBuilder .Choice() .Transition(StateMachineBuilder .Next("Default")) .Condition(StateMachineBuilder .StringEquals("$.foo", "bar")))) .State("Default", StateMachineBuilder .PassState() .Transition(StateMachineBuilder .Next("Choice"))))))); }