diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/ShowcaseUmlTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/ShowcaseUmlTests.java deleted file mode 100644 index b435afaa..00000000 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/ShowcaseUmlTests.java +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright 2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.statemachine.buildtests; - -import java.util.Map; - -import org.junit.Test; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.statemachine.StateContext; -import org.springframework.statemachine.StateMachine; -import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.EnableStateMachine; -import org.springframework.statemachine.config.StateMachineConfigurerAdapter; -import org.springframework.statemachine.config.builders.StateMachineModelConfigurer; -import org.springframework.statemachine.config.model.StateMachineModelFactory; -import org.springframework.statemachine.guard.Guard; -import org.springframework.statemachine.test.StateMachineTestPlan; -import org.springframework.statemachine.test.StateMachineTestPlanBuilder; -import org.springframework.statemachine.uml.UmlStateMachineModelFactory; - -@SuppressWarnings("unchecked") -public class ShowcaseUmlTests extends AbstractBuildTests { - - @Test - public void testInitialState() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testA() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("A") - .expectStateChanged(0) - .expectStateEntered(0) - .expectStateExited(0) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testB() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("B") - .expectStateChanged(2) - .expectStateEntered(2) - .expectStateExited(2) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testCHKA() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("H") - .expectVariable("foo", 1) - .expectTransition(1) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("K") - .expectStateEntered(2) - .expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("A") - .expectStateChanged(2) - .expectStateEntered(2) - .expectStateExited(2) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testC() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testCK() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("K") - .expectStateEntered(2) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testD() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("D") - .expectStateEntered(3) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testCD() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("D") - .expectStateEntered(2) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testI() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("I") - .expectStateEntered(1) - .expectStates("S0", "S1", "S12").and() - .build(); - plan.test(); - } - - @Test - public void testII() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("I") - .expectStateEntered(1) - .expectStateEntered(1) - .expectStateExited(1) - .expectStates("S0", "S1", "S12").and() - .step() - .sendEvent("I") - .expectStateChanged(2) - .expectStateEntered(3) - .expectStateExited(2) - .expectStates("S0", "S2", "S21", "S212").and() - .build(); - plan.test(); - } - - @Test - public void testH() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step() - .expectStates("S0", "S1", "S11") - .expectVariable("foo", 0).and() - .step() - .sendEvent("H") - .expectTransition(1) - .expectVariable("foo", 0) - .expectStates("S0", "S1", "S11").and() - .build(); - plan.test(); - } - - @Test - public void testCH() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step() - .expectStates("S0", "S1", "S11") - .expectVariable("foo", 0).and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("H") - .expectVariable("foo", 1) - .expectTransition(1) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testACH() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("A") - .expectStateChanged(0) - .expectStateEntered(0) - .expectStateExited(0) - .expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("C") - .expectStateEntered(3) - .expectStates("S0", "S2", "S21", "S211").and() - .step() - .sendEvent("H") - .expectVariable("foo", 1) - .expectTransition(1) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testE() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("E") - .expectStateChanged(3) - .expectStateEntered(4) - .expectStateExited(3) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testF() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("F") - .expectStateChanged(2) - .expectStateEntered(3) - .expectStateExited(2) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Test - public void testG() throws Exception { - context.register(Config1.class); - context.refresh(); - StateMachine stateMachine = context.getBean(StateMachine.class); - - StateMachineTestPlan plan = - StateMachineTestPlanBuilder.builder() - .stateMachine(stateMachine) - .step().expectStates("S0", "S1", "S11").and() - .step() - .sendEvent("G") - .expectStateChanged(2) - .expectStateEntered(3) - .expectStateExited(2) - .expectStates("S0", "S2", "S21", "S211").and() - .build(); - plan.test(); - } - - @Configuration - @EnableStateMachine - public static class Config1 extends StateMachineConfigurerAdapter { - - @Override - public void configure(StateMachineModelConfigurer model) throws Exception { - model - .withModel() - .factory(modelFactory()); - } - - @Bean - public StateMachineModelFactory modelFactory() { - return new UmlStateMachineModelFactory("classpath:org/springframework/statemachine/buildtests/showcase.uml"); - } - - @Bean - public Guard exitGuard() { - return (context) -> { - return true; - }; - } - - @Bean - public FooGuard foo0Guard() { - return new FooGuard(0); - } - - @Bean - public FooGuard foo1Guard() { - return new FooGuard(1); - } - - @Bean - public FooAction fooAction() { - return new FooAction(); - } - } - - private static class FooAction implements Action { - - @Override - public void execute(StateContext context) { - Map variables = context.getExtendedState().getVariables(); - Integer foo = context.getExtendedState().get("foo", Integer.class); - if (foo == null) { - variables.put("foo", 0); - } else if (foo == 0) { - variables.put("foo", 1); - } else if (foo == 1) { - variables.put("foo", 0); - } - } - } - - private static class FooGuard implements Guard { - - private final int match; - - public FooGuard(int match) { - this.match = match; - } - - @Override - public boolean evaluate(StateContext context) { - Object foo = context.getExtendedState().getVariables().get("foo"); - return !(foo == null || !foo.equals(match)); - } - } - - @Override - protected AnnotationConfigApplicationContext buildContext() { - return new AnnotationConfigApplicationContext(); - } -} diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/AbstractTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/AbstractTckTests.java index 95258b51..46e37d0a 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/AbstractTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/AbstractTckTests.java @@ -15,12 +15,19 @@ */ package org.springframework.statemachine.buildtests.tck; +import java.util.Map; + import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.statemachine.StateContext; import org.springframework.statemachine.StateMachine; +import org.springframework.statemachine.action.Action; import org.springframework.statemachine.config.StateMachineFactory; +import org.springframework.statemachine.guard.Guard; import org.springframework.statemachine.test.StateMachineTestPlan; import org.springframework.statemachine.test.StateMachineTestPlanBuilder; @@ -107,4 +114,362 @@ public abstract class AbstractTckTests { * @return StateMachine for SimpleSubMachine */ protected abstract StateMachine getSimpleSubMachine() throws Exception; + + @Test + public void testShowcaseMachineInitialState() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineA() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("A") + .expectStateChanged(0) + .expectStateEntered(0) + .expectStateExited(0) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineB() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("B") + .expectStateChanged(2) + .expectStateEntered(2) + .expectStateExited(2) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineCHKA() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("H") + .expectVariable("foo", 1) + .expectTransition(1) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("K") + .expectStateEntered(2) + .expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("A") + .expectStateChanged(2) + .expectStateEntered(2) + .expectStateExited(2) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineC() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineCK() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("K") + .expectStateEntered(2) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineD() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("D") + .expectStateEntered(3) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineCD() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("D") + .expectStateEntered(2) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineI() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("I") + .expectStateEntered(1) + .expectStates("S0", "S1", "S12").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineII() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("I") + .expectStateEntered(1) + .expectStateEntered(1) + .expectStateExited(1) + .expectStates("S0", "S1", "S12").and() + .step() + .sendEvent("I") + .expectStateChanged(2) + .expectStateEntered(3) + .expectStateExited(2) + .expectStates("S0", "S2", "S21", "S212").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineH() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step() + .expectStates("S0", "S1", "S11") + .expectVariable("foo", 0).and() + .step() + .sendEvent("H") + .expectTransition(1) + .expectVariable("foo", 0) + .expectStates("S0", "S1", "S11").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineCH() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step() + .expectStates("S0", "S1", "S11") + .expectVariable("foo", 0).and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("H") + .expectVariable("foo", 1) + .expectTransition(1) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineACH() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("A") + .expectStateChanged(0) + .expectStateEntered(0) + .expectStateExited(0) + .expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("C") + .expectStateEntered(3) + .expectStates("S0", "S2", "S21", "S211").and() + .step() + .sendEvent("H") + .expectVariable("foo", 1) + .expectTransition(1) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineE() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("E") + .expectStateChanged(3) + .expectStateEntered(4) + .expectStateExited(3) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineF() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("F") + .expectStateChanged(2) + .expectStateEntered(3) + .expectStateExited(2) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + @Test + public void testShowcaseMachineG() throws Exception { + StateMachine stateMachine = getShowcaseMachine(); + StateMachineTestPlan plan = + StateMachineTestPlanBuilder.builder() + .stateMachine(stateMachine) + .step().expectStates("S0", "S1", "S11").and() + .step() + .sendEvent("G") + .expectStateChanged(2) + .expectStateEntered(3) + .expectStateExited(2) + .expectStates("S0", "S2", "S21", "S211").and() + .build(); + plan.test(); + } + + /** + * Return state machine for showcase tests. + * + * @return StateMachine for ShowcaseMachine + */ + protected abstract StateMachine getShowcaseMachine() throws Exception; + + @Configuration + protected static class ShowcaseMachineBeansConfig { + + @Bean + public FooGuard foo0Guard() { + return new FooGuard(0); + } + + @Bean + public FooGuard foo1Guard() { + return new FooGuard(1); + } + + @Bean + public FooAction fooAction() { + return new FooAction(); + } + } + + protected static class FooAction implements Action { + + public FooAction() { + } + + @Override + public void execute(StateContext context) { + Map variables = context.getExtendedState().getVariables(); + Integer foo = context.getExtendedState().get("foo", Integer.class); + if (foo == null) { + variables.put("foo", 0); + } else if (foo == 0) { + variables.put("foo", 1); + } else if (foo == 1) { + variables.put("foo", 0); + } + } + } + + protected static class FooGuard implements Guard { + + private final int match; + + public FooGuard(int match) { + this.match = match; + } + + @Override + public boolean evaluate(StateContext context) { + Object foo = context.getExtendedState().getVariables().get("foo"); + return !(foo == null || !foo.equals(match)); + } + } } diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationFactoryTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationFactoryTckTests.java index 9eea6db1..dce507f5 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationFactoryTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationFactoryTckTests.java @@ -16,6 +16,7 @@ package org.springframework.statemachine.buildtests.tck.javaconfig; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.buildtests.tck.AbstractTckTests; @@ -51,6 +52,13 @@ public class AnnotationFactoryTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineConfig.class); + context.refresh(); + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration @EnableStateMachineFactory static class SimpleMachineConfig extends StateMachineConfigurerAdapter { @@ -111,4 +119,125 @@ public class AnnotationFactoryTckTests extends AbstractTckTests { .event("E3"); } } + + @Configuration + @EnableStateMachineFactory + static class ShowcaseMachineConfig extends StateMachineConfigurerAdapter { + @Override + public void configure(StateMachineStateConfigurer states) + throws Exception { + states + .withStates() + .initial("S0", fooAction()) + .state("S0") + .and() + .withStates() + .parent("S0") + .initial("S1") + .state("S1") + .and() + .withStates() + .parent("S1") + .initial("S11") + .state("S11") + .state("S12") + .and() + .withStates() + .parent("S0") + .state("S2") + .and() + .withStates() + .parent("S2") + .initial("S21") + .state("S21") + .and() + .withStates() + .parent("S21") + .initial("S211") + .state("S211") + .state("S212"); + } + + @Override + public void configure(StateMachineTransitionConfigurer transitions) + throws Exception { + transitions + .withExternal() + .source("S1").target("S1").event("A") + .guard(foo1Guard()) + .and() + .withExternal() + .source("S1").target("S11").event("B") + .and() + .withExternal() + .source("S21").target("S211").event("B") + .and() + .withExternal() + .source("S1").target("S2").event("C") + .and() + .withExternal() + .source("S2").target("S1").event("K") + .and() + .withExternal() + .source("S1").target("S0").event("D") + .and() + .withExternal() + .source("S211").target("S21").event("D") + .and() + .withExternal() + .source("S0").target("S211").event("E") + .and() + .withExternal() + .source("S1").target("S211").event("F") + .and() + .withExternal() + .source("S2").target("S11").event("F") + .and() + .withExternal() + .source("S11").target("S211").event("G") + .and() + .withExternal() + .source("S211").target("S0").event("G") + .and() + .withInternal() + .source("S0").event("H") + .guard(foo0Guard()) + .action(fooAction()) + .and() + .withInternal() + .source("S2").event("H") + .guard(foo1Guard()) + .action(fooAction()) + .and() + .withInternal() + .source("S1").event("H") + .and() + .withExternal() + .source("S11").target("S12").event("I") + .and() + .withExternal() + .source("S211").target("S212").event("I") + .and() + .withExternal() + .source("S12").target("S212").event("I") + .and() + .withInternal() + .source("S11").event("J"); + } + + @Bean + public FooGuard foo0Guard() { + return new FooGuard(0); + } + + @Bean + public FooGuard foo1Guard() { + return new FooGuard(1); + } + + @Bean + public FooAction fooAction() { + return new FooAction(); + } + } } diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationTckTests.java index 302948ed..7862656c 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/AnnotationTckTests.java @@ -16,6 +16,7 @@ package org.springframework.statemachine.buildtests.tck.javaconfig; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.statemachine.StateMachine; import org.springframework.statemachine.buildtests.tck.AbstractTckTests; @@ -51,6 +52,13 @@ public class AnnotationTckTests extends AbstractTckTests { return getStateMachineFromContext(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineConfig.class); + context.refresh(); + return getStateMachineFromContext(); + } + @Configuration @EnableStateMachine static class SimpleMachineConfig extends StateMachineConfigurerAdapter { @@ -111,4 +119,125 @@ public class AnnotationTckTests extends AbstractTckTests { .event("E3"); } } + + @Configuration + @EnableStateMachine + static class ShowcaseMachineConfig extends StateMachineConfigurerAdapter { + @Override + public void configure(StateMachineStateConfigurer states) + throws Exception { + states + .withStates() + .initial("S0", fooAction()) + .state("S0") + .and() + .withStates() + .parent("S0") + .initial("S1") + .state("S1") + .and() + .withStates() + .parent("S1") + .initial("S11") + .state("S11") + .state("S12") + .and() + .withStates() + .parent("S0") + .state("S2") + .and() + .withStates() + .parent("S2") + .initial("S21") + .state("S21") + .and() + .withStates() + .parent("S21") + .initial("S211") + .state("S211") + .state("S212"); + } + + @Override + public void configure(StateMachineTransitionConfigurer transitions) + throws Exception { + transitions + .withExternal() + .source("S1").target("S1").event("A") + .guard(foo1Guard()) + .and() + .withExternal() + .source("S1").target("S11").event("B") + .and() + .withExternal() + .source("S21").target("S211").event("B") + .and() + .withExternal() + .source("S1").target("S2").event("C") + .and() + .withExternal() + .source("S2").target("S1").event("K") + .and() + .withExternal() + .source("S1").target("S0").event("D") + .and() + .withExternal() + .source("S211").target("S21").event("D") + .and() + .withExternal() + .source("S0").target("S211").event("E") + .and() + .withExternal() + .source("S1").target("S211").event("F") + .and() + .withExternal() + .source("S2").target("S11").event("F") + .and() + .withExternal() + .source("S11").target("S211").event("G") + .and() + .withExternal() + .source("S211").target("S0").event("G") + .and() + .withInternal() + .source("S0").event("H") + .guard(foo0Guard()) + .action(fooAction()) + .and() + .withInternal() + .source("S2").event("H") + .guard(foo1Guard()) + .action(fooAction()) + .and() + .withInternal() + .source("S1").event("H") + .and() + .withExternal() + .source("S11").target("S12").event("I") + .and() + .withExternal() + .source("S211").target("S212").event("I") + .and() + .withExternal() + .source("S12").target("S212").event("I") + .and() + .withInternal() + .source("S11").event("J"); + } + + @Bean + public FooGuard foo0Guard() { + return new FooGuard(0); + } + + @Bean + public FooGuard foo1Guard() { + return new FooGuard(1); + } + + @Bean + public FooAction fooAction() { + return new FooAction(); + } + } } diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/BuilderTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/BuilderTckTests.java index e01c9084..e519d950 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/BuilderTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/javaconfig/BuilderTckTests.java @@ -74,4 +74,105 @@ public class BuilderTckTests extends AbstractTckTests { .event("E3"); return builder.build(); } + + @Override + protected StateMachine getShowcaseMachine() throws Exception { + Builder builder = StateMachineBuilder.builder(); + + builder.configureStates() + .withStates() + .initial("S0", new FooAction()) + .state("S0") + .and() + .withStates() + .parent("S0") + .initial("S1") + .state("S1") + .and() + .withStates() + .parent("S1") + .initial("S11") + .state("S11") + .state("S12") + .and() + .withStates() + .parent("S0") + .state("S2") + .and() + .withStates() + .parent("S2") + .initial("S21") + .state("S21") + .and() + .withStates() + .parent("S21") + .initial("S211") + .state("S211") + .state("S212"); + + builder.configureTransitions() + .withExternal() + .source("S1").target("S1").event("A") + .guard(new FooGuard(1)) + .and() + .withExternal() + .source("S1").target("S11").event("B") + .and() + .withExternal() + .source("S21").target("S211").event("B") + .and() + .withExternal() + .source("S1").target("S2").event("C") + .and() + .withExternal() + .source("S2").target("S1").event("K") + .and() + .withExternal() + .source("S1").target("S0").event("D") + .and() + .withExternal() + .source("S211").target("S21").event("D") + .and() + .withExternal() + .source("S0").target("S211").event("E") + .and() + .withExternal() + .source("S1").target("S211").event("F") + .and() + .withExternal() + .source("S2").target("S11").event("F") + .and() + .withExternal() + .source("S11").target("S211").event("G") + .and() + .withExternal() + .source("S211").target("S0").event("G") + .and() + .withInternal() + .source("S0").event("H") + .guard(new FooGuard(0)) + .action(new FooAction()) + .and() + .withInternal() + .source("S2").event("H") + .guard(new FooGuard(1)) + .action(new FooAction()) + .and() + .withInternal() + .source("S1").event("H") + .and() + .withExternal() + .source("S11").target("S12").event("I") + .and() + .withExternal() + .source("S211").target("S212").event("I") + .and() + .withExternal() + .source("S12").target("S212").event("I") + .and() + .withInternal() + .source("S11").event("J"); + + return builder.build(); + } } diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaJsonTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaJsonTckTests.java index e91f88d6..3617219c 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaJsonTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaJsonTckTests.java @@ -64,6 +64,13 @@ public class JpaJsonTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(TestConfig.class, ShowcaseMachineBeansConfig.class, ShowcaseMachineConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration public static class SimpleMachineConfig { @@ -86,6 +93,17 @@ public class JpaJsonTckTests extends AbstractTckTests { } } + @Configuration + public static class ShowcaseMachineConfig { + + @Bean + public StateMachineJackson2RepositoryPopulatorFactoryBean jackson2RepositoryPopulatorFactoryBean() { + StateMachineJackson2RepositoryPopulatorFactoryBean factoryBean = new StateMachineJackson2RepositoryPopulatorFactoryBean(); + factoryBean.setResources(new Resource[]{new ClassPathResource("org/springframework/statemachine/buildtests/tck/jpa/ShowcaseMachine.json")}); + return factoryBean; + } + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaManualTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaManualTckTests.java index 871471e3..9dd72020 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaManualTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/jpa/JpaManualTckTests.java @@ -15,6 +15,9 @@ */ package org.springframework.statemachine.buildtests.tck.jpa; +import java.util.Arrays; +import java.util.HashSet; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -33,10 +36,15 @@ import org.springframework.statemachine.data.RepositoryStateMachineModelFactory; import org.springframework.statemachine.data.RepositoryTransition; import org.springframework.statemachine.data.StateRepository; import org.springframework.statemachine.data.TransitionRepository; +import org.springframework.statemachine.data.jpa.JpaActionRepository; +import org.springframework.statemachine.data.jpa.JpaGuardRepository; +import org.springframework.statemachine.data.jpa.JpaRepositoryAction; +import org.springframework.statemachine.data.jpa.JpaRepositoryGuard; import org.springframework.statemachine.data.jpa.JpaRepositoryState; import org.springframework.statemachine.data.jpa.JpaRepositoryTransition; import org.springframework.statemachine.data.jpa.JpaStateRepository; import org.springframework.statemachine.data.jpa.JpaTransitionRepository; +import org.springframework.statemachine.transition.TransitionKind; /** * Tck tests for machine configs build manually agains repository interfaces. @@ -110,6 +118,110 @@ public class JpaManualTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineBeansConfig.class, TestConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + + JpaStateRepository stateRepository = context.getBean(JpaStateRepository.class); + JpaTransitionRepository transitionRepository = context.getBean(JpaTransitionRepository.class); + JpaActionRepository actionRepository = context.getBean(JpaActionRepository.class); + JpaGuardRepository guardRepository = context.getBean(JpaGuardRepository.class); + + JpaRepositoryGuard foo0Guard = new JpaRepositoryGuard(); + foo0Guard.setName("foo0Guard"); + + JpaRepositoryGuard foo1Guard = new JpaRepositoryGuard(); + foo1Guard.setName("foo1Guard"); + + JpaRepositoryAction fooAction = new JpaRepositoryAction(); + fooAction.setName("fooAction"); + + guardRepository.save(foo0Guard); + guardRepository.save(foo1Guard); + actionRepository.save(fooAction); + + JpaRepositoryState stateS0 = new JpaRepositoryState("S0", true); + stateS0.setInitialAction(fooAction); + JpaRepositoryState stateS1 = new JpaRepositoryState("S1", true); + stateS1.setParentState(stateS0); + JpaRepositoryState stateS11 = new JpaRepositoryState("S11", true); + stateS11.setParentState(stateS1); + JpaRepositoryState stateS12 = new JpaRepositoryState("S12"); + stateS12.setParentState(stateS1); + JpaRepositoryState stateS2 = new JpaRepositoryState("S2"); + stateS2.setParentState(stateS0); + JpaRepositoryState stateS21 = new JpaRepositoryState("S21", true); + stateS21.setParentState(stateS2); + JpaRepositoryState stateS211 = new JpaRepositoryState("S211", true); + stateS211.setParentState(stateS21); + JpaRepositoryState stateS212 = new JpaRepositoryState("S212"); + stateS212.setParentState(stateS21); + + stateRepository.save(stateS0); + stateRepository.save(stateS1); + stateRepository.save(stateS11); + stateRepository.save(stateS12); + stateRepository.save(stateS2); + stateRepository.save(stateS21); + stateRepository.save(stateS211); + stateRepository.save(stateS212); + + JpaRepositoryTransition transitionS1ToS1 = new JpaRepositoryTransition(stateS1, stateS1, "A"); + transitionS1ToS1.setGuard(foo1Guard); + + JpaRepositoryTransition transitionS1ToS11 = new JpaRepositoryTransition(stateS1, stateS11, "B"); + JpaRepositoryTransition transitionS21ToS211 = new JpaRepositoryTransition(stateS21, stateS211, "B"); + JpaRepositoryTransition transitionS1ToS2 = new JpaRepositoryTransition(stateS1, stateS2, "C"); + JpaRepositoryTransition transitionS1ToS0 = new JpaRepositoryTransition(stateS1, stateS0, "D"); + JpaRepositoryTransition transitionS211ToS21 = new JpaRepositoryTransition(stateS211, stateS21, "D"); + JpaRepositoryTransition transitionS0ToS211 = new JpaRepositoryTransition(stateS0, stateS211, "E"); + JpaRepositoryTransition transitionS1ToS211 = new JpaRepositoryTransition(stateS1, stateS211, "F"); + JpaRepositoryTransition transitionS2ToS21 = new JpaRepositoryTransition(stateS2, stateS21, "F"); + JpaRepositoryTransition transitionS11ToS211 = new JpaRepositoryTransition(stateS11, stateS211, "G"); + + JpaRepositoryTransition transitionS0 = new JpaRepositoryTransition(stateS0, stateS0, "H"); + transitionS0.setKind(TransitionKind.INTERNAL); + transitionS0.setGuard(foo0Guard); + transitionS0.setActions(new HashSet<>(Arrays.asList(fooAction))); + + JpaRepositoryTransition transitionS1 = new JpaRepositoryTransition(stateS1, stateS1, "H"); + transitionS1.setKind(TransitionKind.INTERNAL); + + JpaRepositoryTransition transitionS2 = new JpaRepositoryTransition(stateS2, stateS2, "H"); + transitionS2.setKind(TransitionKind.INTERNAL); + transitionS2.setGuard(foo1Guard); + transitionS2.setActions(new HashSet<>(Arrays.asList(fooAction))); + + JpaRepositoryTransition transitionS11ToS12 = new JpaRepositoryTransition(stateS11, stateS12, "I"); + JpaRepositoryTransition transitionS12ToS212 = new JpaRepositoryTransition(stateS12, stateS212, "I"); + JpaRepositoryTransition transitionS211ToS12 = new JpaRepositoryTransition(stateS211, stateS12, "I"); + + JpaRepositoryTransition transitionS11 = new JpaRepositoryTransition(stateS11, stateS11, "J"); + JpaRepositoryTransition transitionS2ToS1 = new JpaRepositoryTransition(stateS2, stateS1, "K"); + + transitionRepository.save(transitionS1ToS1); + transitionRepository.save(transitionS1ToS11); + transitionRepository.save(transitionS21ToS211); + transitionRepository.save(transitionS1ToS2); + transitionRepository.save(transitionS1ToS0); + transitionRepository.save(transitionS211ToS21); + transitionRepository.save(transitionS0ToS211); + transitionRepository.save(transitionS1ToS211); + transitionRepository.save(transitionS2ToS21); + transitionRepository.save(transitionS11ToS211); + transitionRepository.save(transitionS0); + transitionRepository.save(transitionS1); + transitionRepository.save(transitionS2); + transitionRepository.save(transitionS11ToS12); + transitionRepository.save(transitionS12ToS212); + transitionRepository.save(transitionS211ToS12); + transitionRepository.save(transitionS11); + transitionRepository.save(transitionS2ToS1); + + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbJsonTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbJsonTckTests.java index bee7c44d..26eebb89 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbJsonTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbJsonTckTests.java @@ -86,6 +86,13 @@ public class MongoDbJsonTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(TestConfig.class, ShowcaseMachineBeansConfig.class, ShowcaseMachineConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration public static class SimpleMachineConfig { @@ -108,6 +115,17 @@ public class MongoDbJsonTckTests extends AbstractTckTests { } } + @Configuration + public static class ShowcaseMachineConfig { + + @Bean + public StateMachineJackson2RepositoryPopulatorFactoryBean jackson2RepositoryPopulatorFactoryBean() { + StateMachineJackson2RepositoryPopulatorFactoryBean factoryBean = new StateMachineJackson2RepositoryPopulatorFactoryBean(); + factoryBean.setResources(new Resource[]{new ClassPathResource("org/springframework/statemachine/buildtests/tck/mongodb/ShowcaseMachine.json")}); + return factoryBean; + } + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbManualTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbManualTckTests.java index d4b7ee5e..dfde3010 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbManualTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/mongodb/MongoDbManualTckTests.java @@ -15,6 +15,9 @@ */ package org.springframework.statemachine.buildtests.tck.mongodb; +import java.util.Arrays; +import java.util.HashSet; + import org.junit.Rule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,12 +38,15 @@ import org.springframework.statemachine.data.RepositoryStateMachineModelFactory; import org.springframework.statemachine.data.RepositoryTransition; import org.springframework.statemachine.data.StateRepository; import org.springframework.statemachine.data.TransitionRepository; +import org.springframework.statemachine.data.mongodb.MongoDbActionRepository; +import org.springframework.statemachine.data.mongodb.MongoDbGuardRepository; import org.springframework.statemachine.data.mongodb.MongoDbRepositoryAction; import org.springframework.statemachine.data.mongodb.MongoDbRepositoryGuard; import org.springframework.statemachine.data.mongodb.MongoDbRepositoryState; import org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition; import org.springframework.statemachine.data.mongodb.MongoDbStateRepository; import org.springframework.statemachine.data.mongodb.MongoDbTransitionRepository; +import org.springframework.statemachine.transition.TransitionKind; /** * Tck tests for machine configs build manually agains repository interfaces. @@ -130,6 +136,110 @@ public class MongoDbManualTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineBeansConfig.class, TestConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + + MongoDbStateRepository stateRepository = context.getBean(MongoDbStateRepository.class); + MongoDbTransitionRepository transitionRepository = context.getBean(MongoDbTransitionRepository.class); + MongoDbActionRepository actionRepository = context.getBean(MongoDbActionRepository.class); + MongoDbGuardRepository guardRepository = context.getBean(MongoDbGuardRepository.class); + + MongoDbRepositoryGuard foo0Guard = new MongoDbRepositoryGuard(); + foo0Guard.setName("foo0Guard"); + + MongoDbRepositoryGuard foo1Guard = new MongoDbRepositoryGuard(); + foo1Guard.setName("foo1Guard"); + + MongoDbRepositoryAction fooAction = new MongoDbRepositoryAction(); + fooAction.setName("fooAction"); + + guardRepository.save(foo0Guard); + guardRepository.save(foo1Guard); + actionRepository.save(fooAction); + + MongoDbRepositoryState stateS0 = new MongoDbRepositoryState("S0", true); + stateS0.setInitialAction(fooAction); + MongoDbRepositoryState stateS1 = new MongoDbRepositoryState("S1", true); + stateS1.setParentState(stateS0); + MongoDbRepositoryState stateS11 = new MongoDbRepositoryState("S11", true); + stateS11.setParentState(stateS1); + MongoDbRepositoryState stateS12 = new MongoDbRepositoryState("S12"); + stateS12.setParentState(stateS1); + MongoDbRepositoryState stateS2 = new MongoDbRepositoryState("S2"); + stateS2.setParentState(stateS0); + MongoDbRepositoryState stateS21 = new MongoDbRepositoryState("S21", true); + stateS21.setParentState(stateS2); + MongoDbRepositoryState stateS211 = new MongoDbRepositoryState("S211", true); + stateS211.setParentState(stateS21); + MongoDbRepositoryState stateS212 = new MongoDbRepositoryState("S212"); + stateS212.setParentState(stateS21); + + stateRepository.save(stateS0); + stateRepository.save(stateS1); + stateRepository.save(stateS11); + stateRepository.save(stateS12); + stateRepository.save(stateS2); + stateRepository.save(stateS21); + stateRepository.save(stateS211); + stateRepository.save(stateS212); + + MongoDbRepositoryTransition transitionS1ToS1 = new MongoDbRepositoryTransition(stateS1, stateS1, "A"); + transitionS1ToS1.setGuard(foo1Guard); + + MongoDbRepositoryTransition transitionS1ToS11 = new MongoDbRepositoryTransition(stateS1, stateS11, "B"); + MongoDbRepositoryTransition transitionS21ToS211 = new MongoDbRepositoryTransition(stateS21, stateS211, "B"); + MongoDbRepositoryTransition transitionS1ToS2 = new MongoDbRepositoryTransition(stateS1, stateS2, "C"); + MongoDbRepositoryTransition transitionS1ToS0 = new MongoDbRepositoryTransition(stateS1, stateS0, "D"); + MongoDbRepositoryTransition transitionS211ToS21 = new MongoDbRepositoryTransition(stateS211, stateS21, "D"); + MongoDbRepositoryTransition transitionS0ToS211 = new MongoDbRepositoryTransition(stateS0, stateS211, "E"); + MongoDbRepositoryTransition transitionS1ToS211 = new MongoDbRepositoryTransition(stateS1, stateS211, "F"); + MongoDbRepositoryTransition transitionS2ToS21 = new MongoDbRepositoryTransition(stateS2, stateS21, "F"); + MongoDbRepositoryTransition transitionS11ToS211 = new MongoDbRepositoryTransition(stateS11, stateS211, "G"); + + MongoDbRepositoryTransition transitionS0 = new MongoDbRepositoryTransition(stateS0, stateS0, "H"); + transitionS0.setKind(TransitionKind.INTERNAL); + transitionS0.setGuard(foo0Guard); + transitionS0.setActions(new HashSet<>(Arrays.asList(fooAction))); + + MongoDbRepositoryTransition transitionS1 = new MongoDbRepositoryTransition(stateS1, stateS1, "H"); + transitionS1.setKind(TransitionKind.INTERNAL); + + MongoDbRepositoryTransition transitionS2 = new MongoDbRepositoryTransition(stateS2, stateS2, "H"); + transitionS2.setKind(TransitionKind.INTERNAL); + transitionS2.setGuard(foo1Guard); + transitionS2.setActions(new HashSet<>(Arrays.asList(fooAction))); + + MongoDbRepositoryTransition transitionS11ToS12 = new MongoDbRepositoryTransition(stateS11, stateS12, "I"); + MongoDbRepositoryTransition transitionS12ToS212 = new MongoDbRepositoryTransition(stateS12, stateS212, "I"); + MongoDbRepositoryTransition transitionS211ToS12 = new MongoDbRepositoryTransition(stateS211, stateS12, "I"); + + MongoDbRepositoryTransition transitionS11 = new MongoDbRepositoryTransition(stateS11, stateS11, "J"); + MongoDbRepositoryTransition transitionS2ToS1 = new MongoDbRepositoryTransition(stateS2, stateS1, "K"); + + transitionRepository.save(transitionS1ToS1); + transitionRepository.save(transitionS1ToS11); + transitionRepository.save(transitionS21ToS211); + transitionRepository.save(transitionS1ToS2); + transitionRepository.save(transitionS1ToS0); + transitionRepository.save(transitionS211ToS21); + transitionRepository.save(transitionS0ToS211); + transitionRepository.save(transitionS1ToS211); + transitionRepository.save(transitionS2ToS21); + transitionRepository.save(transitionS11ToS211); + transitionRepository.save(transitionS0); + transitionRepository.save(transitionS1); + transitionRepository.save(transitionS2); + transitionRepository.save(transitionS11ToS12); + transitionRepository.save(transitionS12ToS212); + transitionRepository.save(transitionS211ToS12); + transitionRepository.save(transitionS11); + transitionRepository.save(transitionS2ToS1); + + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisJsonTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisJsonTckTests.java index 01726e20..79025a14 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisJsonTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisJsonTckTests.java @@ -86,6 +86,13 @@ public class RedisJsonTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(TestConfig.class, ShowcaseMachineBeansConfig.class, ShowcaseMachineConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration public static class SimpleMachineConfig { @@ -108,6 +115,17 @@ public class RedisJsonTckTests extends AbstractTckTests { } } + @Configuration + public static class ShowcaseMachineConfig { + + @Bean + public StateMachineJackson2RepositoryPopulatorFactoryBean jackson2RepositoryPopulatorFactoryBean() { + StateMachineJackson2RepositoryPopulatorFactoryBean factoryBean = new StateMachineJackson2RepositoryPopulatorFactoryBean(); + factoryBean.setResources(new Resource[]{new ClassPathResource("org/springframework/statemachine/buildtests/tck/redis/ShowcaseMachine.json")}); + return factoryBean; + } + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisManualTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisManualTckTests.java index 3289931c..46266583 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisManualTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/redis/RedisManualTckTests.java @@ -15,6 +15,9 @@ */ package org.springframework.statemachine.buildtests.tck.redis; +import java.util.Arrays; +import java.util.HashSet; + import org.junit.Rule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,12 +38,15 @@ import org.springframework.statemachine.data.RepositoryStateMachineModelFactory; import org.springframework.statemachine.data.RepositoryTransition; import org.springframework.statemachine.data.StateRepository; import org.springframework.statemachine.data.TransitionRepository; +import org.springframework.statemachine.data.redis.RedisActionRepository; +import org.springframework.statemachine.data.redis.RedisGuardRepository; import org.springframework.statemachine.data.redis.RedisRepositoryAction; import org.springframework.statemachine.data.redis.RedisRepositoryGuard; import org.springframework.statemachine.data.redis.RedisRepositoryState; import org.springframework.statemachine.data.redis.RedisRepositoryTransition; import org.springframework.statemachine.data.redis.RedisStateRepository; import org.springframework.statemachine.data.redis.RedisTransitionRepository; +import org.springframework.statemachine.transition.TransitionKind; /** * Tck tests for machine configs build manually agains repository interfaces. @@ -131,6 +137,110 @@ public class RedisManualTckTests extends AbstractTckTests { return getStateMachineFactoryFromContext().getStateMachine(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineBeansConfig.class, TestConfig.class, StateMachineFactoryConfig.class); + context.refresh(); + + RedisStateRepository stateRepository = context.getBean(RedisStateRepository.class); + RedisTransitionRepository transitionRepository = context.getBean(RedisTransitionRepository.class); + RedisActionRepository actionRepository = context.getBean(RedisActionRepository.class); + RedisGuardRepository guardRepository = context.getBean(RedisGuardRepository.class); + + RedisRepositoryGuard foo0Guard = new RedisRepositoryGuard(); + foo0Guard.setName("foo0Guard"); + + RedisRepositoryGuard foo1Guard = new RedisRepositoryGuard(); + foo1Guard.setName("foo1Guard"); + + RedisRepositoryAction fooAction = new RedisRepositoryAction(); + fooAction.setName("fooAction"); + + guardRepository.save(foo0Guard); + guardRepository.save(foo1Guard); + actionRepository.save(fooAction); + + RedisRepositoryState stateS0 = new RedisRepositoryState("S0", true); + stateS0.setInitialAction(fooAction); + RedisRepositoryState stateS1 = new RedisRepositoryState("S1", true); + stateS1.setParentState(stateS0); + RedisRepositoryState stateS11 = new RedisRepositoryState("S11", true); + stateS11.setParentState(stateS1); + RedisRepositoryState stateS12 = new RedisRepositoryState("S12"); + stateS12.setParentState(stateS1); + RedisRepositoryState stateS2 = new RedisRepositoryState("S2"); + stateS2.setParentState(stateS0); + RedisRepositoryState stateS21 = new RedisRepositoryState("S21", true); + stateS21.setParentState(stateS2); + RedisRepositoryState stateS211 = new RedisRepositoryState("S211", true); + stateS211.setParentState(stateS21); + RedisRepositoryState stateS212 = new RedisRepositoryState("S212"); + stateS212.setParentState(stateS21); + + stateRepository.save(stateS0); + stateRepository.save(stateS1); + stateRepository.save(stateS11); + stateRepository.save(stateS12); + stateRepository.save(stateS2); + stateRepository.save(stateS21); + stateRepository.save(stateS211); + stateRepository.save(stateS212); + + RedisRepositoryTransition transitionS1ToS1 = new RedisRepositoryTransition(stateS1, stateS1, "A"); + transitionS1ToS1.setGuard(foo1Guard); + + RedisRepositoryTransition transitionS1ToS11 = new RedisRepositoryTransition(stateS1, stateS11, "B"); + RedisRepositoryTransition transitionS21ToS211 = new RedisRepositoryTransition(stateS21, stateS211, "B"); + RedisRepositoryTransition transitionS1ToS2 = new RedisRepositoryTransition(stateS1, stateS2, "C"); + RedisRepositoryTransition transitionS1ToS0 = new RedisRepositoryTransition(stateS1, stateS0, "D"); + RedisRepositoryTransition transitionS211ToS21 = new RedisRepositoryTransition(stateS211, stateS21, "D"); + RedisRepositoryTransition transitionS0ToS211 = new RedisRepositoryTransition(stateS0, stateS211, "E"); + RedisRepositoryTransition transitionS1ToS211 = new RedisRepositoryTransition(stateS1, stateS211, "F"); + RedisRepositoryTransition transitionS2ToS21 = new RedisRepositoryTransition(stateS2, stateS21, "F"); + RedisRepositoryTransition transitionS11ToS211 = new RedisRepositoryTransition(stateS11, stateS211, "G"); + + RedisRepositoryTransition transitionS0 = new RedisRepositoryTransition(stateS0, stateS0, "H"); + transitionS0.setKind(TransitionKind.INTERNAL); + transitionS0.setGuard(foo0Guard); + transitionS0.setActions(new HashSet<>(Arrays.asList(fooAction))); + + RedisRepositoryTransition transitionS1 = new RedisRepositoryTransition(stateS1, stateS1, "H"); + transitionS1.setKind(TransitionKind.INTERNAL); + + RedisRepositoryTransition transitionS2 = new RedisRepositoryTransition(stateS2, stateS2, "H"); + transitionS2.setKind(TransitionKind.INTERNAL); + transitionS2.setGuard(foo1Guard); + transitionS2.setActions(new HashSet<>(Arrays.asList(fooAction))); + + RedisRepositoryTransition transitionS11ToS12 = new RedisRepositoryTransition(stateS11, stateS12, "I"); + RedisRepositoryTransition transitionS12ToS212 = new RedisRepositoryTransition(stateS12, stateS212, "I"); + RedisRepositoryTransition transitionS211ToS12 = new RedisRepositoryTransition(stateS211, stateS12, "I"); + + RedisRepositoryTransition transitionS11 = new RedisRepositoryTransition(stateS11, stateS11, "J"); + RedisRepositoryTransition transitionS2ToS1 = new RedisRepositoryTransition(stateS2, stateS1, "K"); + + transitionRepository.save(transitionS1ToS1); + transitionRepository.save(transitionS1ToS11); + transitionRepository.save(transitionS21ToS211); + transitionRepository.save(transitionS1ToS2); + transitionRepository.save(transitionS1ToS0); + transitionRepository.save(transitionS211ToS21); + transitionRepository.save(transitionS0ToS211); + transitionRepository.save(transitionS1ToS211); + transitionRepository.save(transitionS2ToS21); + transitionRepository.save(transitionS11ToS211); + transitionRepository.save(transitionS0); + transitionRepository.save(transitionS1); + transitionRepository.save(transitionS2); + transitionRepository.save(transitionS11ToS12); + transitionRepository.save(transitionS12ToS212); + transitionRepository.save(transitionS211ToS12); + transitionRepository.save(transitionS11); + transitionRepository.save(transitionS2ToS1); + + return getStateMachineFactoryFromContext().getStateMachine(); + } + @Configuration @EnableStateMachineFactory public static class StateMachineFactoryConfig extends StateMachineConfigurerAdapter { diff --git a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/uml/UmlTckTests.java b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/uml/UmlTckTests.java index 4673e303..21b382ca 100644 --- a/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/uml/UmlTckTests.java +++ b/spring-statemachine-build-tests/src/test/java/org/springframework/statemachine/buildtests/tck/uml/UmlTckTests.java @@ -53,6 +53,13 @@ public class UmlTckTests extends AbstractTckTests { return getStateMachineFromContext(); } + @Override + protected StateMachine getShowcaseMachine() throws Exception { + context.register(ShowcaseMachineConfig.class); + context.refresh(); + return getStateMachineFromContext(); + } + @Configuration @EnableStateMachine public static class SimpleMachineConfig extends StateMachineConfigurerAdapter { @@ -86,4 +93,36 @@ public class UmlTckTests extends AbstractTckTests { return new UmlStateMachineModelFactory("classpath:org/springframework/statemachine/buildtests/tck/uml/SimpleSubMachine.uml"); } } + + @Configuration + @EnableStateMachine + public static class ShowcaseMachineConfig extends StateMachineConfigurerAdapter { + + @Override + public void configure(StateMachineModelConfigurer model) throws Exception { + model + .withModel() + .factory(modelFactory()); + } + + @Bean + public StateMachineModelFactory modelFactory() { + return new UmlStateMachineModelFactory("classpath:org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.uml"); + } + + @Bean + public FooGuard foo0Guard() { + return new FooGuard(0); + } + + @Bean + public FooGuard foo1Guard() { + return new FooGuard(1); + } + + @Bean + public FooAction fooAction() { + return new FooAction(); + } + } } diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/jpa/ShowcaseMachine.json b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/jpa/ShowcaseMachine.json new file mode 100644 index 00000000..43b437b1 --- /dev/null +++ b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/jpa/ShowcaseMachine.json @@ -0,0 +1,186 @@ +[ + { + "@id": "1", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryAction", + "name": "fooAction" + }, + { + "@id": "2", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryGuard", + "name": "foo0Guard" + }, + { + "@id": "3", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryGuard", + "name": "foo1Guard" + }, + { + "@id": "4", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "initial": true, + "initialAction": "1", + "state": "S0" + }, + { + "@id": "5", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "4", + "initial": true, + "state": "S1" + }, + { + "@id": "6", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "5", + "initial": true, + "state": "S11" + }, + { + "@id": "7", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "5", + "state": "S12" + }, + { + "@id": "8", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "4", + "state": "S2" + }, + { + "@id": "9", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "8", + "initial": true, + "state": "S21" + }, + { + "@id": "10", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "9", + "initial": true, + "state": "S211" + }, + { + "@id": "11", + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryState", + "parentState": "9", + "state": "S212" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "5", + "event": "A", + "guard": "3" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "6", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "9", + "target": "10", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "8", + "event": "C" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "4", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "10", + "target": "9", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "4", + "target": "10", + "event": "E" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "10", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "8", + "target": "9", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "6", + "target": "10", + "event": "G" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "4", + "target": "4", + "kind": "INTERNAL", + "guard": "2", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "5", + "target": "5", + "kind": "INTERNAL", + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "8", + "target": "8", + "kind": "INTERNAL", + "guard": "3", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "6", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "7", + "target": "11", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "10", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "6", + "target": "6", + "event": "J" + }, + { + "_class": "org.springframework.statemachine.data.jpa.JpaRepositoryTransition", + "source": "8", + "target": "5", + "event": "K" + } +] diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/mongodb/ShowcaseMachine.json b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/mongodb/ShowcaseMachine.json new file mode 100644 index 00000000..e2700734 --- /dev/null +++ b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/mongodb/ShowcaseMachine.json @@ -0,0 +1,186 @@ +[ + { + "@id": "1", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryAction", + "name": "fooAction" + }, + { + "@id": "2", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryGuard", + "name": "foo0Guard" + }, + { + "@id": "3", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryGuard", + "name": "foo1Guard" + }, + { + "@id": "4", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "initial": true, + "initialAction": "1", + "state": "S0" + }, + { + "@id": "5", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "4", + "initial": true, + "state": "S1" + }, + { + "@id": "6", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "5", + "initial": true, + "state": "S11" + }, + { + "@id": "7", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "5", + "state": "S12" + }, + { + "@id": "8", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "4", + "state": "S2" + }, + { + "@id": "9", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "8", + "initial": true, + "state": "S21" + }, + { + "@id": "10", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "9", + "initial": true, + "state": "S211" + }, + { + "@id": "11", + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryState", + "parentState": "9", + "state": "S212" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "5", + "event": "A", + "guard": "3" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "6", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "9", + "target": "10", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "8", + "event": "C" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "4", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "10", + "target": "9", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "4", + "target": "10", + "event": "E" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "10", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "8", + "target": "9", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "6", + "target": "10", + "event": "G" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "4", + "target": "4", + "kind": "INTERNAL", + "guard": "2", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "5", + "target": "5", + "kind": "INTERNAL", + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "8", + "target": "8", + "kind": "INTERNAL", + "guard": "3", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "6", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "7", + "target": "11", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "10", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "6", + "target": "6", + "event": "J" + }, + { + "_class": "org.springframework.statemachine.data.mongodb.MongoDbRepositoryTransition", + "source": "8", + "target": "5", + "event": "K" + } +] diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/redis/ShowcaseMachine.json b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/redis/ShowcaseMachine.json new file mode 100644 index 00000000..804abc4d --- /dev/null +++ b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/redis/ShowcaseMachine.json @@ -0,0 +1,186 @@ +[ + { + "@id": "1", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryAction", + "name": "fooAction" + }, + { + "@id": "2", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryGuard", + "name": "foo0Guard" + }, + { + "@id": "3", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryGuard", + "name": "foo1Guard" + }, + { + "@id": "4", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "initial": true, + "initialAction": "1", + "state": "S0" + }, + { + "@id": "5", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "4", + "initial": true, + "state": "S1" + }, + { + "@id": "6", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "5", + "initial": true, + "state": "S11" + }, + { + "@id": "7", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "5", + "state": "S12" + }, + { + "@id": "8", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "4", + "state": "S2" + }, + { + "@id": "9", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "8", + "initial": true, + "state": "S21" + }, + { + "@id": "10", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "9", + "initial": true, + "state": "S211" + }, + { + "@id": "11", + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryState", + "parentState": "9", + "state": "S212" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "5", + "event": "A", + "guard": "3" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "6", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "9", + "target": "10", + "event": "B" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "8", + "event": "C" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "4", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "10", + "target": "9", + "event": "D" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "4", + "target": "10", + "event": "E" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "10", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "8", + "target": "9", + "event": "F" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "6", + "target": "10", + "event": "G" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "4", + "target": "4", + "kind": "INTERNAL", + "guard": "2", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "5", + "target": "5", + "kind": "INTERNAL", + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "8", + "target": "8", + "kind": "INTERNAL", + "guard": "3", + "actions": ["1"], + "event": "H" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "6", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "7", + "target": "11", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "10", + "target": "7", + "event": "I" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "6", + "target": "6", + "event": "J" + }, + { + "_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition", + "source": "8", + "target": "5", + "event": "K" + } +] diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.di b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.di similarity index 100% rename from spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.di rename to spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.di diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.notation b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.notation similarity index 67% rename from spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.notation rename to spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.notation index 8ab04b3c..3731a63d 100644 --- a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.notation +++ b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.notation @@ -1,97 +1,88 @@ - - - + + + - - + +
- - - + + + - + - - -
- - + +
- - - + + + - + - - -
- - + +
- - - + + + - + - - -
- + - - + + - + - - + + - + - + - + - - + + - + - - + + - + @@ -100,104 +91,98 @@ - - + + - + - - + + - + - - -
- - + +
- - - + + + - + - - -
- - + +
- - - + + + - + - + - + - - + + - + - + - + - - + + - + - + - + - + - - + + - + - + - + @@ -206,26 +191,26 @@ - - + + - + - - + + - + - - + + - + @@ -234,355 +219,367 @@ - - + + - + - - + + - + - - + + - - + + - + - - + + - + - + - - - + + + + - + + - - + + + - + - - + + - - + + + - + + - - + + + - + - + - - + + + - + + - - + + + - + - + - - + + - + - + - + - - + + - + - + - + - - - + + + - + - + - - + + - + - - - + + + + - - + + + - - + + + - - - - + + + + - - - + + + - + - + - - - + + + - - + + - + - + - + - - - + + + - + - + - - - + + + - - - + + + - + - + - - + + - - - + + + - + - + - - + + - + - - - + + + - + - + - - - + + + - - - + + + - + - + - - - + + + - - - + + + - + - + - - - + + + - - - + + + - - + + - + - + - - - + + + - + - + - - + + - - - + + + - + - + - - + + - + - - - + + + - + - + - - + + - + - - - + + + - - + + - + - + diff --git a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.uml b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.uml similarity index 89% rename from spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.uml rename to spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.uml index b8cb4231..d4992e9d 100644 --- a/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/showcase.uml +++ b/spring-statemachine-build-tests/src/test/resources/org/springframework/statemachine/buildtests/tck/uml/ShowcaseMachine.uml @@ -8,7 +8,7 @@ fooAction - + bean @@ -17,7 +17,7 @@ - + @@ -36,22 +36,22 @@ - + - + - + - + - + - + @@ -79,10 +79,10 @@ - + - + @@ -93,19 +93,19 @@ - + - + - + - +