Reactive test changes for data

- Relates #744
This commit is contained in:
Janne Valkealahti
2019-05-10 17:38:02 +01:00
parent cd37ab871a
commit 5b04d39e41
5 changed files with 41 additions and 34 deletions

View File

@@ -18,6 +18,9 @@ package org.springframework.statemachine.data.jpa;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
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.resolveMachine;
import java.util.Arrays;
import java.util.HashSet;
@@ -288,32 +291,30 @@ public class JpaRepositoryTests extends AbstractRepositoryTests {
}
@Test
@SuppressWarnings("unchecked")
public void testStateMachinePersistWithStrings() {
context.register(TestConfig.class, ConfigWithStrings.class);
context.refresh();
StateMachine<String, String> stateMachine = context.getBean(StateMachine.class);
stateMachine.start();
StateMachine<String, String> stateMachine = resolveMachine(context);
doStartAndAssert(stateMachine);
assertThat(stateMachine.getState().getId(), is("S1"));
stateMachine.sendEvent("E1");
doSendEventAndConsumeAll(stateMachine, "E1");
assertThat(stateMachine.getState().getId(), is("S2"));
stateMachine.sendEvent("E2");
doSendEventAndConsumeAll(stateMachine, "E2");
assertThat(stateMachine.getState().getId(), is("S1"));
}
@Test
@SuppressWarnings("unchecked")
public void testStateMachinePersistWithEnums() {
context.register(TestConfig.class, ConfigWithEnums.class);
context.refresh();
StateMachine<PersistTestStates, PersistTestEvents> stateMachine = context.getBean(StateMachine.class);
stateMachine.start();
StateMachine<PersistTestStates, PersistTestEvents> stateMachine = resolveMachine(context);
doStartAndAssert(stateMachine);
assertThat(stateMachine.getState().getId(), is(PersistTestStates.S1));
stateMachine.sendEvent(PersistTestEvents.E1);
doSendEventAndConsumeAll(stateMachine, PersistTestEvents.E1);
assertThat(stateMachine.getState().getId(), is(PersistTestStates.S2));
stateMachine.sendEvent(PersistTestEvents.E2);
doSendEventAndConsumeAll(stateMachine, PersistTestEvents.E2);
assertThat(stateMachine.getState().getId(), is(PersistTestStates.S1));
}
@@ -325,9 +326,9 @@ public class JpaRepositoryTests extends AbstractRepositoryTests {
JpaStateMachineRepository stateMachineRepository = context.getBean(JpaStateMachineRepository.class);
StateMachine<String, String> stateMachine = context.getBean(StateMachine.class);
stateMachine.start();
doStartAndAssert(stateMachine);
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S10", "S20"));
stateMachine.sendEvent("E1");
doSendEventAndConsumeAll(stateMachine, "E1");
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S11", "S21"));
assertThat(stateMachineRepository.count(), is(3l));