@Test
fun produceVisualizationTurnstileFSM() {
println("== TurnStile")
val visualization = visualize(TurnstileFSM.definition) // (1)
File("generated", "turnstile.plantuml").writeText(plantUml(visualization)) // (2)
}
The simple visualization uses the resulting definition and can render states and transitions. You will typically add a method to a unit test class as follows:
@Test
fun produceVisualizationTurnstileFSM() {
println("== TurnStile")
val visualization = visualize(TurnstileFSM.definition) // (1)
File("generated", "turnstile.plantuml").writeText(plantUml(visualization)) // (2)
}
TurnstileFSM.definition
is the definition that will be rendered.
The plantuml
method accepts the output of visualize
and produces a state diagram in the plantuml format.
You may invoke the parser from a unit test similar to the simple case.
dependencies {
testImplementation 'io.jumpco.open:kfsm-viz:1.5.2.4'
}
dependencies {
testImplementation("io.jumpco.open:kfsm-viz:1.5.2.4")
}
@Test
fun produceVisualizationTurnstileFSM() {
println("== Simple TurnStile")
val visualization = parseStateMachine("SimpleTurnstileFSM", File("src/test/kotlin/SimpleTurnstile.kt")) // (1)
println(visualization)
File("generated-parsed", "simple-turnstile.plantuml").writeText(plantUml(visualization)) // (2)
File("generated-parsed", "simple-turnstile.adoc").writeText(asciiDoc(visualization)) // (3)
}
Provide classname for the class holding the definition DSL and the sourcefile where the class may be found.
Use the plantuml
method to generate the text for a plantuml state diagram.
Use the asciidoc
method to generate an Asciidoc formatted state table.
Start | Event[Guard] | Target | Action |
---|---|---|---|
LOCKED |
COIN |
UNLOCKED |
|
UNLOCKED |
PASS |
LOCKED |
|
UNLOCKED |
COIN |
UNLOCKED |
|
More examples can be found at: kfsm-viz
Use the kfsm-viz-plugin for Gradle to make the visualization part of your build without writing code.
Source kfsm-viz