@Test public void testRunTwice() throws InterruptedException { listener.reset(9, 0, 0); tasks.run(); assertThat(listener.stateChangedLatch.await(6, TimeUnit.SECONDS), is(true)); assertThat(machine.getState().getIds(), contains(States.READY)); Map<Object, Object> variables = machine.getExtendedState().getVariables(); assertThat(variables.size(), is(3)); listener.reset(9, 0, 0); tasks.run(); assertThat(listener.stateChangedLatch.await(6, TimeUnit.SECONDS), is(true)); assertThat(machine.getState().getIds(), contains(States.READY)); variables = machine.getExtendedState().getVariables(); assertThat(variables.size(), is(3)); }
@Test public void testFailAutomaticFix() throws InterruptedException { listener.reset(11, 0, 0); tasks.fail("T1"); tasks.run(); assertThat(listener.stateChangedLatch.await(6, TimeUnit.SECONDS), is(true)); assertThat(listener.stateChangedCount, is(11)); assertThat(machine.getState().getIds(), contains(States.READY)); }
@Test public void testFailManualFix() throws InterruptedException { listener.reset(11, 0, 0); tasks.fail("T2"); tasks.run(); assertThat(listener.stateChangedLatch.await(6, TimeUnit.SECONDS), is(true)); Map<Object, Object> variables = machine.getExtendedState().getVariables(); assertThat(variables.size(), is(3)); assertThat(machine.getState().getIds(), contains(States.ERROR, States.MANUAL)); listener.reset(1, 0, 0); tasks.fix(); assertThat(listener.stateChangedLatch.await(6, TimeUnit.SECONDS), is(true)); assertThat(machine.getState().getIds(), contains(States.READY)); }