Revert "Spring State Machine" (#1485)
* Revert "Merge modules (#1471)" This reverts commit11cdf67fad. * Revert "(BAEL-746) How to Copy an Array in Java (#1474)" This reverts commit44f5742f16. * Revert "Bs santosh spring mybatis (#1479)" This reverts commit3140ea166d. * Revert "Spring State Machine (#1424)" This reverts commit319dd2653a.
This commit is contained in:
committed by
GitHub
parent
11cdf67fad
commit
092d883dde
-45
@@ -1,45 +0,0 @@
|
||||
package com.baeldung.spring.stateMachine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
|
||||
import com.baeldung.spring.stateMachine.config.ForkJoinStateMachineConfiguration;
|
||||
|
||||
public class ForkJoinStateMachineTest {
|
||||
|
||||
@Test
|
||||
public void whenForkStateEntered_thenMultipleSubStatesEntered() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ForkJoinStateMachineConfiguration.class);
|
||||
StateMachine stateMachine = ctx.getBean(StateMachine.class);
|
||||
stateMachine.start();
|
||||
|
||||
boolean success = stateMachine.sendEvent("E1");
|
||||
|
||||
assertTrue(success);
|
||||
|
||||
assertTrue(Arrays.asList("SFork", "Sub1-1", "Sub2-1").containsAll(stateMachine.getState().getIds()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAllConfiguredJoinEntryStatesAreEntered_thenTransitionToJoinState() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ForkJoinStateMachineConfiguration.class);
|
||||
StateMachine stateMachine = ctx.getBean(StateMachine.class);
|
||||
stateMachine.start();
|
||||
|
||||
boolean success = stateMachine.sendEvent("E1");
|
||||
|
||||
assertTrue(success);
|
||||
|
||||
assertTrue(Arrays.asList("SFork", "Sub1-1", "Sub2-1").containsAll(stateMachine.getState().getIds()));
|
||||
|
||||
assertTrue(stateMachine.sendEvent("sub1"));
|
||||
assertTrue(stateMachine.sendEvent("sub2"));
|
||||
assertEquals("SJoin", stateMachine.getState().getId());
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.baeldung.spring.stateMachine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
|
||||
import com.baeldung.spring.stateMachine.config.HierarchicalStateMachineConfiguration;
|
||||
|
||||
public class HierarchicalStateMachineTest {
|
||||
|
||||
@Test
|
||||
public void whenTransitionToSubMachine_thenSubStateIsEntered() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(HierarchicalStateMachineConfiguration.class);
|
||||
StateMachine stateMachine = ctx.getBean(StateMachine.class);
|
||||
stateMachine.start();
|
||||
|
||||
|
||||
assertEquals(Arrays.asList("SI", "SUB1"), stateMachine.getState().getIds());
|
||||
|
||||
stateMachine.sendEvent("se1");
|
||||
|
||||
assertEquals(Arrays.asList("SI", "SUB2"), stateMachine.getState().getIds());
|
||||
|
||||
stateMachine.sendEvent("s-end");
|
||||
|
||||
assertEquals(Arrays.asList("SI", "SUBEND"), stateMachine.getState().getIds());
|
||||
|
||||
stateMachine.sendEvent("end");
|
||||
|
||||
assertEquals(1, stateMachine.getState().getIds().size());
|
||||
assertEquals("SF", stateMachine.getState().getId());
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.baeldung.spring.stateMachine;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
|
||||
import com.baeldung.spring.stateMachine.config.JunctionStateMachineConfiguration;
|
||||
|
||||
public class JunctionStateMachineTest {
|
||||
|
||||
@Test
|
||||
public void whenTransitioningToJunction_thenArriveAtSubJunctionNode() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(JunctionStateMachineConfiguration.class);
|
||||
StateMachine stateMachine = ctx.getBean(StateMachine.class);
|
||||
stateMachine.start();
|
||||
|
||||
stateMachine.sendEvent("E1");
|
||||
Assert.assertEquals("low", stateMachine.getState().getId());
|
||||
|
||||
stateMachine.sendEvent("end");
|
||||
Assert.assertEquals("SF", stateMachine.getState().getId());
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.baeldung.spring.stateMachine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.config.StateMachineBuilder;
|
||||
|
||||
public class StateMachineBuilderTest {
|
||||
|
||||
@Test
|
||||
public void whenUseStateMachineBuilder_thenBuildSuccessAndMachineWorks() throws Exception {
|
||||
StateMachineBuilder.Builder<String, String> builder = StateMachineBuilder.builder();
|
||||
builder.configureStates().withStates()
|
||||
.initial("SI")
|
||||
.state("S1")
|
||||
.end("SF");
|
||||
|
||||
builder.configureTransitions()
|
||||
.withExternal()
|
||||
.source("SI").target("S1").event("E1")
|
||||
.and().withExternal()
|
||||
.source("S1").target("SF").event("E2");
|
||||
|
||||
StateMachine machine = builder.build();
|
||||
|
||||
machine.start();
|
||||
|
||||
machine.sendEvent("E1");
|
||||
assertEquals("S1", machine.getState().getId());
|
||||
|
||||
machine.sendEvent("E2");
|
||||
assertEquals("SF", machine.getState().getId());
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.baeldung.spring.stateMachine;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
|
||||
import com.baeldung.spring.stateMachine.config.SimpleStateMachineConfiguration;
|
||||
|
||||
public class StateMachineTest {
|
||||
|
||||
private StateMachine stateMachine;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SimpleStateMachineConfiguration.class);
|
||||
stateMachine = ctx.getBean(StateMachine.class);
|
||||
stateMachine.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSimpleStringStateMachineEvents_thenEndState() {
|
||||
assertEquals("SI", stateMachine.getState().getId());
|
||||
|
||||
stateMachine.sendEvent("E1");
|
||||
assertEquals("S1", stateMachine.getState().getId());
|
||||
|
||||
stateMachine.sendEvent("E2");
|
||||
assertEquals("S2", stateMachine.getState().getId());
|
||||
|
||||
stateMachine.sendEvent("end");
|
||||
assertEquals("SF", stateMachine.getState().getId());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSimpleStringMachineActionState_thenActionExecuted() {
|
||||
stateMachine.sendEvent("E3");
|
||||
assertEquals("S3", stateMachine.getState().getId());
|
||||
|
||||
stateMachine.sendEvent("E4");
|
||||
assertEquals("S4", stateMachine.getState().getId());
|
||||
assertEquals(2, stateMachine.getExtendedState().getVariables().get("approvalCount"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user