Files
spring-boot-rest/spring-state-machine/src/test/java/com/baeldung/spring/statemachine/StateEnumMachineTest.java
Danil Kornishev 1c1c557a39 Spring State Machine (#1493)
* 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

* fix attempt for S3 -> S4

* Remove awaitility.  add teardown

* fix attempt for S3 -> S4

* fix attempt for S3 -> S4 Final
2017-03-27 21:21:03 +02:00

34 lines
1.3 KiB
Java

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());
}
}