@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,9 @@ package demo.washer;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -64,7 +67,7 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinse() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
}
|
||||
@@ -72,11 +75,11 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinseCutPower() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.CUTPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.CUTPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.POWEROFF));
|
||||
}
|
||||
@@ -84,15 +87,15 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinseCutRestorePower() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.CUTPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.CUTPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RESTOREPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.RESTOREPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
}
|
||||
@@ -170,12 +173,12 @@ public class WasherTests {
|
||||
context.refresh();
|
||||
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
|
||||
listener = context.getBean(TestListener.class);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
Reference in New Issue
Block a user