@@ -301,6 +301,7 @@ project('spring-statemachine-data-common') {
|
||||
compile "com.fasterxml.jackson.core:jackson-core"
|
||||
compile "com.fasterxml.jackson.core:jackson-databind"
|
||||
testCompile project(":spring-statemachine-test")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-web"
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ project('spring-statemachine-data-jpa') {
|
||||
compile "org.springframework:spring-orm"
|
||||
testCompile project(":spring-statemachine-test")
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile "org.hsqldb:hsqldb"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
@@ -23,6 +24,7 @@ project('spring-statemachine-data-redis') {
|
||||
testCompile project(":spring-statemachine-test")
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.apache.commons:commons-pool2"
|
||||
testRuntime "redis.clients:jedis"
|
||||
@@ -39,6 +41,7 @@ project('spring-statemachine-data-mongodb') {
|
||||
testCompile project(":spring-statemachine-test")
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-data-mongodb"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-web"
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-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 org.springframework.statemachine.data.mongodb;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -121,32 +124,30 @@ public class MongoDbRepositoryTests 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));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-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 org.springframework.statemachine.data.redis;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -119,32 +122,30 @@ public class RedisRepositoryTests 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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user