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 NoWaitForSupplied_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.WaitState() .Transition(StateMachineBuilder.End())) .Build()); }
public void MissingResourceInTaskState_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End())) .Build()); }
public void MapStateWithoutIterator_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.MapState() .Transition(StateMachineBuilder.End())) .Build()); }
public void ParallelStateWithNoBranches_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.ParallelState() .Transition(StateMachineBuilder.End())) .Build()); }
public void WaitForSecondsPath_MissingPath_IsNotValid() { Assert.ThrowsAny <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.SecondsPath(null)) .Transition(StateMachineBuilder.End())) .Build()); }
public void WaitForSecondsPath_InvalidReferencePath_IsNotValid() { Assert.ThrowsAny <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.SecondsPath("$.Foo[*]")) .Transition(StateMachineBuilder.End())) .Build()); }
public void InputPath_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.PassState() .InputPath("['invalidPath") .Transition(StateMachineBuilder.End())) .Build()); }
public void WaitForTimestampPath_InvalidJsonPath_IsNotValid() { Assert.ThrowsAny <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.TimestampPath("$.")) .Transition(StateMachineBuilder.End())) .Build()); }
public void WaitForSeconds_ZeroSeconds_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.Seconds(0)) .Transition(StateMachineBuilder.End())) .Build()); }
public void SingleWaitState_WaitUntilTimestamp() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.Timestamp(DateTime.Parse("2016-03-14T01:59:00Z").ToUniversalTime())) .Transition(StateMachineBuilder.End())) .Build(); AssertStateMachine(stateMachine, "SingleWaitStateWithTimestamp.json"); }
[Fact] // public void RetrierInTaskState_OnlyErrorEqualsSet_IsValid() { StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .RetryOnAllErrors()) .Resource("arn")) .Build(); }
public void SingleWaitState_WaitUntilSecondsPath() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.SecondsPath("$.seconds")) .Transition(StateMachineBuilder.End())) .Build(); AssertStateMachine(stateMachine, "SingleWaitStateWithSecondsPath.json"); }
public void SingleWaitState_WaitUntilTimestampWithPath() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.WaitState() .WaitFor(StateMachineBuilder.TimestampPath("$.timestamp")) .Transition(StateMachineBuilder.End())) .Build(); AssertStateMachine(stateMachine, "SingleWaitStateWithTimestampWithPath.json"); }
public void SinglePassStateWithObjectResult() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.PassState() .Transition(StateMachineBuilder.End()) .Result(new SimplePojo("value"))) .Build(); AssertStateMachine(stateMachine, "SinglePassStateWithObjectResult.json"); }
public void TaskStateWithEnd() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.TaskState() .Resource("resource-arn") .Transition(StateMachineBuilder.End())) .Build(); AssertStateMachine(stateMachine, "TaskStateWithEnd.json"); }
public void NegativeTimeoutSecondsInTaskState_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .TimeoutSeconds(-1) .Resource("arn")) .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 TaskStateWithParametersAndEnd() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("InitialState") .State("InitialState", StateMachineBuilder.TaskState() .Resource("resource-arn") .Parameters(JObject.FromObject(new { value = "param" })) .Transition(StateMachineBuilder.End())) .Build(); AssertStateMachine(stateMachine, "TaskStateWithParametersAndEnd.json"); }
[Fact] // public void RetrierInTaskState_MaxAttemptsZero_IsValid() { StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .MaxAttempts(0) .RetryOnAllErrors()) .Resource("arn")) .Build(); }
[Fact] // public void RetrierInTaskState_BackoffRateGreaterThanOne_IsValid() { StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .BackoffRate(1.5) .RetryOnAllErrors()) .Resource("arn")) .Build(); }
[Fact] // public void RetrierInTaskState_IntervalSecondsPositive_IsValid() { StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .IntervalSeconds(10) .RetryOnAllErrors()) .Resource("arn")) .Build(); }
public void RetrierInTaskState_RetryAllHasOtherErrorCodes_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .ErrorEquals("Foo", "Bar", ErrorCodes.ALL)) .Resource("arn")) .Build()); }
public void OutputPAthIsNull() { var stateMachine = StateMachineBuilder.StateMachine() .StartAt("helloPass") .State("helloPass", StateMachineBuilder.PassState() .Result(JArray.Parse("[1,2,3]")) .InputPath("$.a") .OutputPath(null) .Transition(StateMachineBuilder.End())).Build(); AssertStateMachine(stateMachine, "PassStateNullOutputPath.json"); }
public void HeartbeatSecondsGreaterThanTimeoutSecondsInTaskState_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .HeartbeatSeconds(60) .TimeoutSeconds(30) .Resource("arn")) .Build()); }
[Fact] // public void CatcherInTaskState_ValidTransition_IsValid() { StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Catcher(StateMachineBuilder.Catcher() .Transition(StateMachineBuilder.Next("Terminal")) .CatchAll()) .Resource("arn")) .State("Terminal", StateMachineBuilder.SucceedState()) .Build(); }
public void RetrierInTaskState_BackoffRateLessThanOne_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Retrier(StateMachineBuilder.Retrier() .BackoffRate(0.5) .RetryOnAllErrors()) .Resource("arn")) .Build()); }
public void CatcherInTaskState_InvalidTransition_IsNotValid() { Assert.Throws <ValidationException>(() => StateMachineBuilder.StateMachine() .StartAt("Initial") .State("Initial", StateMachineBuilder.TaskState() .Transition(StateMachineBuilder.End()) .Catcher(StateMachineBuilder.Catcher() .Transition(StateMachineBuilder.Next("NoSuchState")) .CatchAll()) .Resource("arn")) .Build()); }