use of org.yakindu.sct.model.sgraph.FinalState in project statecharts by Yakindu.
the class ModelSequencerStateTest method testFinalStateEnterSequence.
/**
* A leaf state must have a enter sequence. This enter sequence consists of
* an entry action call and a state enter step.
*/
@SuppressWarnings("unused")
@Test
public void testFinalStateEnterSequence() {
Statechart sc = _createStatechart("cs");
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("r", sc);
FinalState fs = _createFinalState(r);
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _fs = flow.getStates().get(0);
assertEquals("_final_0", _fs.getSimpleName());
assertSame(fs, _fs.getSourceElement());
assertNull(_fs.getEntryAction());
assertNotNull(_fs.getEnterSequences().get(0));
assertEquals(1, _fs.getEnterSequences().get(0).getSteps().size());
assertClass(EnterState.class, _fs.getEnterSequences().get(0).getSteps().get(0));
}
use of org.yakindu.sct.model.sgraph.FinalState in project statecharts by Yakindu.
the class ModelSequencerStateTest method testFinalStateExitSequence.
/**
* A final state must have a exit sequence. This exit sequence consists of a
* state exit step.
*/
@SuppressWarnings("unused")
@Test
public void testFinalStateExitSequence() {
Statechart sc = _createStatechart("cs");
Scope scope = _createInterfaceScope("interface", sc);
Region r = _createRegion("r", sc);
FinalState fs = _createFinalState(r);
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _fs = flow.getStates().get(0);
assertEquals("_final_0", _fs.getSimpleName());
assertNull(_fs.getExitAction());
assertNotNull(_fs.getExitSequence());
assertEquals(1, _fs.getExitSequence().getSteps().size());
assertClass(ExitState.class, _fs.getExitSequence().getSteps().get(0));
}
use of org.yakindu.sct.model.sgraph.FinalState in project statecharts by Yakindu.
the class ModelSequencerStateTest method testFinalStateEnterSequenceCall.
/**
* The enter sequence must be called withnin incoming transitions.
*/
@SuppressWarnings("unused")
@Test
public void testFinalStateEnterSequenceCall() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
EventDefinition e1 = _createEventDefinition("e1", s_scope);
Region r = _createRegion("r", sc);
{
State s1 = _createState("s1", r);
FinalState fs = _createFinalState(r);
Transition t_s1_fs = _createTransition(s1, fs);
_createReactionTrigger(t_s1_fs);
_createRegularEventSpec(e1, (ReactionTrigger) t_s1_fs.getTrigger());
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals("sc.r.s1", _s1.getName());
ExecutionState _fs = flow.getStates().get(1);
assertEquals("sc.r._final_", _fs.getName());
assertNull(_fs.getEntryAction());
assertNull(_fs.getExitAction());
// the transition s1 -> fs must includes the fs exit sequence call
Sequence cycle = _s1.getReactSequence();
If _if = (If) SCTTestUtil.flattenSequenceStepsAsList(cycle).get(0);
assertCall(_if.getThenStep(), _s1.getReactions().get(0).getEffect());
Sequence _seq = (Sequence) _s1.getReactions().get(0).getEffect();
assertCall(_seq, 1, _fs.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.sgraph.FinalState in project statecharts by Yakindu.
the class SGraphJavaValidationTest method finalStateIsolated.
/**
* A final state should have at least one incoming transition.
*/
@Test
public void finalStateIsolated() {
statechart = factory.createStatechart();
Region region = factory.createRegion();
statechart.getRegions().add(region);
FinalState finalState = factory.createFinalState();
region.getVertices().add(finalState);
assertFalse(validate(finalState));
assertIssueCount(diagnostics, 1);
assertError(diagnostics, ISSUE_NODE_NOT_REACHABLE);
}
use of org.yakindu.sct.model.sgraph.FinalState in project statecharts by Yakindu.
the class SGraphJavaValidationTest method finalStateValid.
/**
* A positive case for a valid final state.
*/
@Test
public void finalStateValid() {
statechart = factory.createStatechart();
Region region = factory.createRegion();
statechart.getRegions().add(region);
FinalState finalState = factory.createFinalState();
region.getVertices().add(finalState);
State state = factory.createState();
region.getVertices().add(state);
createTransition(state, finalState);
assertTrue(validate(finalState));
assertIssueCount(diagnostics, 0);
}
Aggregations