Port samples tests to assertj
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 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.
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package demo.washer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
@@ -57,11 +55,11 @@ public class WasherTests {
|
||||
public void testInitialState() throws Exception {
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.WASHING));
|
||||
assertThat(listener.statesEntered.size(), is(2));
|
||||
assertThat(listener.statesEntered.get(0).getId(), is(States.RUNNING));
|
||||
assertThat(listener.statesEntered.get(1).getId(), is(States.WASHING));
|
||||
assertThat(listener.statesExited.size(), is(0));
|
||||
assertThat(machine.getState().getIds()).containsExactly(States.RUNNING, States.WASHING);
|
||||
assertThat(listener.statesEntered).hasSize(2);
|
||||
assertThat(listener.statesEntered.get(0).getId()).isEqualTo(States.RUNNING);
|
||||
assertThat(listener.statesEntered.get(1).getId()).isEqualTo(States.WASHING);
|
||||
assertThat(listener.statesExited).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +67,7 @@ public class WasherTests {
|
||||
listener.reset(1, 0, 0);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
assertThat(machine.getState().getIds()).containsExactly(States.RUNNING, States.RINSING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +79,7 @@ public class WasherTests {
|
||||
listener.reset(1, 0, 0);
|
||||
doSendEventAndConsumeAll(machine, Events.CUTPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.POWEROFF));
|
||||
assertThat(machine.getState().getIds()).containsExactly(States.POWEROFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,7 +95,7 @@ public class WasherTests {
|
||||
listener.reset(1, 0, 0);
|
||||
doSendEventAndConsumeAll(machine, Events.RESTOREPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
assertThat(machine.getState().getIds()).containsExactly(States.RUNNING, States.RINSING);
|
||||
}
|
||||
|
||||
static class Config {
|
||||
|
||||
Reference in New Issue
Block a user