diff --git a/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java b/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java index 408dd6fd..76ed4c6a 100644 --- a/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java +++ b/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 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. @@ -500,7 +500,7 @@ public class UmlModelParser { new SpelParserConfiguration(SpelCompilerMode.MIXED, null)); ArrayList> stateActions = new ArrayList>(); stateActions.add(new SpelExpressionAction(parser.parseExpression(expression))); - stateData.setExitActions(stateActions); + stateData.setStateActions(stateActions); } } } diff --git a/spring-statemachine-uml/src/test/java/org/springframework/statemachine/uml/UmlStateMachineModelFactoryTests.java b/spring-statemachine-uml/src/test/java/org/springframework/statemachine/uml/UmlStateMachineModelFactoryTests.java index 68bb153b..8ce4321d 100644 --- a/spring-statemachine-uml/src/test/java/org/springframework/statemachine/uml/UmlStateMachineModelFactoryTests.java +++ b/spring-statemachine-uml/src/test/java/org/springframework/statemachine/uml/UmlStateMachineModelFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 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. @@ -459,6 +459,8 @@ public class UmlStateMachineModelFactoryTests extends AbstractUmlTests { context.register(Config11.class); context.refresh(); StateMachine stateMachine = context.getBean(StateMachine.class); + TestExtendedStateListener listener = new TestExtendedStateListener(); + stateMachine.addStateListener(listener); LatchAction e1Action = context.getBean("e1Action", LatchAction.class); LatchAction s1Exit = context.getBean("s1Exit", LatchAction.class); LatchAction s2Entry = context.getBean("s2Entry", LatchAction.class); @@ -469,6 +471,8 @@ public class UmlStateMachineModelFactoryTests extends AbstractUmlTests { assertThat(e1Action.latch.await(1, TimeUnit.SECONDS), is(true)); assertThat(s1Exit.latch.await(1, TimeUnit.SECONDS), is(true)); assertThat(s2Entry.latch.await(1, TimeUnit.SECONDS), is(true)); + assertThat(listener.latch.await(1, TimeUnit.SECONDS), is(true)); + assertThat(stateMachine.getExtendedState().getVariables().get("hellos2do"), is("hellos2dovalue")); } @Test @@ -1744,4 +1748,16 @@ public class UmlStateMachineModelFactoryTests extends AbstractUmlTests { exited.clear(); } } + + private static class TestExtendedStateListener extends StateMachineListenerAdapter { + + CountDownLatch latch = new CountDownLatch(1); + + @Override + public void extendedStateChanged(Object key, Object value) { + if (ObjectUtils.nullSafeEquals(key, "hellos2do")) { + latch.countDown(); + } + } + } } diff --git a/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.notation b/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.notation index cb1fedae..d09bd7d4 100644 --- a/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.notation +++ b/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.notation @@ -49,6 +49,10 @@ + + + + diff --git a/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.uml b/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.uml index 24c35e40..f674ce3f 100644 --- a/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.uml +++ b/spring-statemachine-uml/src/test/resources/org/springframework/statemachine/uml/simple-actions.uml @@ -17,6 +17,10 @@ + + spel + extendedState.variables.put('hellos2do','hellos2dovalue') + bean s2Entry