Compare commits
2 Commits
ee4e214f8e
...
9fb2276ac1
Author | SHA1 | Date | |
---|---|---|---|
|
9fb2276ac1 | ||
|
35285b61bf |
@ -7,6 +7,6 @@ package me.bvn13.fsm;
|
||||
@FunctionalInterface
|
||||
public interface StateHandler<T extends Fsm> {
|
||||
|
||||
void handle(T fms);
|
||||
void handle(T fsm);
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ package me.bvn13.fsm;
|
||||
@FunctionalInterface
|
||||
public interface StateProcessor<T extends Fsm, E> {
|
||||
|
||||
void process(T fms, E event);
|
||||
void process(T fsm, E event);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import me.bvn13.fsm.StateHandler;
|
||||
|
||||
public class DummyHandler<T extends Fsm> implements StateHandler<T> {
|
||||
@Override
|
||||
public void handle(T fms) {
|
||||
public void handle(T fsm) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import me.bvn13.fsm.StateProcessor;
|
||||
|
||||
public class DummyProcessor<T extends Fsm,E> implements StateProcessor<T,E> {
|
||||
@Override
|
||||
public void process(T fms, E event) {
|
||||
public void process(T fsm, E event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ public class FsmTest {
|
||||
.withAfterHandler(fsm -> initAfter.set(true))
|
||||
.withProcessor((fsm, event) -> initProcess.set(true))
|
||||
.end()
|
||||
.state("intermediate")
|
||||
.end()
|
||||
.finish("finish")
|
||||
.withBeforeHandler(fsm -> finishBefore.set(true))
|
||||
.withAfterHandler(fsm -> finishAfter.set(true))
|
||||
@ -99,6 +101,11 @@ public class FsmTest {
|
||||
.end()
|
||||
.withTransition()
|
||||
.from("init")
|
||||
.to("intermediate")
|
||||
.checking((fsm, event) -> true)
|
||||
.end()
|
||||
.withTransition()
|
||||
.from("intermediate")
|
||||
.to("finish")
|
||||
.checking((fsm, event) -> true)
|
||||
.end()
|
||||
@ -107,9 +114,10 @@ public class FsmTest {
|
||||
|
||||
// @formatter:on
|
||||
|
||||
simpleFsm.process("");
|
||||
simpleFsm.process("");
|
||||
|
||||
//Assert.assertEquals("finish", simpleFsm.getCurrentState().getName());
|
||||
Assert.assertEquals("finish", simpleFsm.getCurrentState().getName());
|
||||
Assert.assertTrue(initBefore.get());
|
||||
Assert.assertTrue(initProcess.get());
|
||||
Assert.assertTrue(initAfter.get());
|
||||
|
Loading…
Reference in New Issue
Block a user