Spring State Machine (#1424)

* Neo4j cleanup

* Neo4j cleanup

* Neo4j cleanup x2

* State Machine Init

* cleanup

* White background, Java Util Logging

* Change to Logging

* Static import of asserts.
rename test methods
This commit is contained in:
Danil Kornishev
2017-03-24 11:55:27 -04:00
committed by Zeger Hendrikse
parent f673acbb47
commit 319dd2653a
20 changed files with 813 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
package com.baeldung.spring.stateMachine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import com.baeldung.spring.stateMachine.applicationReview.ApplicationReviewEvents;
import com.baeldung.spring.stateMachine.applicationReview.ApplicationReviewStates;
import com.baeldung.spring.stateMachine.config.SimpleEnumStateMachineConfiguration;
public class StateEnumMachineTest {
private StateMachine stateMachine;
@Before
public void setUp() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SimpleEnumStateMachineConfiguration.class);
stateMachine = ctx.getBean(StateMachine.class);
stateMachine.start();
}
@Test
public void whenStateMachineConfiguredWithEnums_thenStateMachineAcceptsEnumEvents() {
assertTrue(stateMachine.sendEvent(ApplicationReviewEvents.APPROVE));
assertEquals(ApplicationReviewStates.PRINCIPAL_REVIEW, stateMachine.getState().getId());
assertTrue(stateMachine.sendEvent(ApplicationReviewEvents.REJECT));
assertEquals(ApplicationReviewStates.REJECTED, stateMachine.getState().getId());
}
}