if startingAt beforeHandler must not be called

This commit is contained in:
Vyacheslav Boyko 2022-07-14 13:57:22 +03:00
parent 8ab3306142
commit 99babc5b5a
2 changed files with 4 additions and 5 deletions

View File

@ -252,7 +252,6 @@ public class Fsm<T extends Fsm, E> {
throw new NotInitializedException(format("Unable to find state '%s'", name), e);
}
this.done = currentState.isFinish();
this.currentState.beforeEvent();
}
private void switchToNextState(E event) {

View File

@ -149,7 +149,7 @@ public class FsmTest {
.withAfterHandler(fsm -> initAfter.set(true))
.withProcessor((fsm, event) -> initProcess.set(true))
.end()
.state("intermediate-1")
.state("intermediate")
.withBeforeHandler(fsm -> intermediateBefore.set(true))
.withAfterHandler(fsm -> intermediateAfter.set(true))
.withProcessor((fsm, event) -> intermediateProcess.set(true))
@ -161,11 +161,11 @@ public class FsmTest {
.end()
.withTransition()
.from("init")
.to("intermediate-1")
.to("intermediate")
.checking((fsm, event) -> true)
.end()
.withTransition()
.from("intermediate-1")
.from("intermediate")
.to("finish")
.checking((fsm, event) -> true)
.end()
@ -180,7 +180,7 @@ public class FsmTest {
Assert.assertFalse(initBefore.get());
Assert.assertFalse(initProcess.get());
Assert.assertFalse(initAfter.get());
Assert.assertTrue(intermediateBefore.get());
Assert.assertFalse(intermediateBefore.get());
Assert.assertTrue(intermediateAfter.get());
Assert.assertTrue(intermediateProcess.get());
Assert.assertTrue(finishBefore.get());