JAVA-9808 Fix integration test in spring-state-machine

This commit is contained in:
anuragkumawat 2022-05-24 22:11:03 +05:30
parent 59314162f0
commit d24c84be8e
3 changed files with 18 additions and 13 deletions

View File

@ -39,7 +39,7 @@
<properties>
<spring-statemachine-core.version>3.2.0</spring-statemachine-core.version>
<spring-context.version>5.3.19</spring-context.version>
<spring-test.version>4.3.7.RELEASE</spring-test.version>
<spring-test.version>5.3.19</spring-test.version>
<jayway.awaitility.version>1.7.0</jayway.awaitility.version>
</properties>

View File

@ -38,7 +38,7 @@ public class SimpleStateMachineConfiguration extends StateMachineConfigurerAdapt
.stateEntry("S3", entryAction())
.stateExit("S3", exitAction())
.state("S4", executeAction(), errorAction())
.stateDo("S5", executeAction());
.stateDo("S5", executeAction(), errorAction());
}

View File

@ -1,32 +1,37 @@
package com.baeldung.spring.statemachine;
import com.baeldung.spring.statemachine.config.SimpleStateMachineConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.StateMachine;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import com.baeldung.spring.statemachine.config.SimpleStateMachineConfiguration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = SimpleStateMachineConfiguration.class)
@TestMethodOrder(OrderAnnotation.class)
public class StateMachineIntegrationTest {
@Autowired
private StateMachine<String, String> stateMachine;
@Before
@BeforeEach
public void setUp() {
stateMachine.start();
}
@Test
@Order(1)
public void whenSimpleStringStateMachineEvents_thenEndState() {
assertEquals("SI", stateMachine.getState().getId());
@ -37,8 +42,8 @@ public class StateMachineIntegrationTest {
assertEquals("S2", stateMachine.getState().getId());
}
@Ignore("Fixing in JAVA-9808")
@Test
@Order(2)
public void whenSimpleStringMachineActionState_thenActionExecuted() {
stateMachine.sendEvent("E3");
@ -58,7 +63,7 @@ public class StateMachineIntegrationTest {
assertEquals(2, stateMachine.getExtendedState().getVariables().get("approvalCount"));
}
@After
@AfterEach
public void tearDown() {
stateMachine.stop();
}