use of org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSiblingRegionEntryOnComposite.
/**
* For all and-states that a on the entry path of a transition the enter
* sequences for all orthogonal parts must be called.
*/
@Test
public void testSiblingRegionEntryOnComposite() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
{
Region r3a = _createRegion("r3a", s3);
{
Entry r3a_entry = _createEntry(EntryKind.INITIAL, null, r3a);
State s3a = _createState("s3a", r3a);
_createTransition(r3a_entry, s3a);
}
Region r3b = _createRegion("r3b", s3);
{
Entry r3b_entry = _createEntry(EntryKind.INITIAL, null, r3b);
State s3b = _createState("s3b", r3b);
_createTransition(r3b_entry, s3b);
}
Region r3c = _createRegion("r3c", s3);
{
Entry r3c_entry = _createEntry(EntryKind.INITIAL, null, r3c);
State s3c = _createState("s3c", r3c);
_createTransition(r3c_entry, s3c);
}
}
_createEntryAssignment(v1, s3, 42);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(s5, findState(sc, "s3b"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s3a = flow.getStates().get(3);
assertEquals("sc.r.s1.r3.s3.r3a.s3a", _s3a.getName());
ExecutionState _s3b = flow.getStates().get(4);
assertEquals("sc.r.s1.r3.s3.r3b.s3b", _s3b.getName());
ExecutionState _s3c = flow.getStates().get(5);
assertEquals("sc.r.s1.r3.s3.r3c.s3c", _s3c.getName());
ExecutionState _s4 = flow.getStates().get(6);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(7);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s5.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong sequence: " + stepListAsString(_effect), 7, _effect.getSteps().size());
assertCall(_effect, 0, _s5.getExitSequence());
assertCall(_effect, 1, _s2.getSuperScope().getEnterSequences().get(0));
assertCall(_s2.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(1).getReactSequence());
assertCall(_effect, 2, _s3.getEntryAction());
assertCall(_effect, 3, _s3a.getSuperScope().getEnterSequences().get(0));
assertCall(_s3a.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(3).getReactSequence());
assertCall(_effect, 4, _s3b.getEnterSequences().get(0));
assertCall(_effect, 5, _s3c.getSuperScope().getEnterSequences().get(0));
assertCall(_s3c.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(5).getReactSequence());
assertCall(_effect, 6, _s4.getSuperScope().getEnterSequences().get(0));
assertCall(_s4.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(6).getReactSequence());
}
use of org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testBottomUpTransitionExitSequence_C.
/**
* A transition that exits from a deep orthogonal state structure should not
* contain multiple calls to exit actions
*/
@Test
public void testBottomUpTransitionExitSequence_C() {
Statechart sc = setUpDeepExitSC();
_createTransition(findStateFullyQualified(sc, "sc.r.s.1.a.2.a"), findStateFullyQualified(sc, "sc.r.b"));
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s = assertedState(flow, 0, "sc.r.s");
ExecutionState _s1a = assertedState(flow, 1, "sc.r.s._1.a");
ExecutionState _s1a1a = assertedState(flow, 2, "sc.r.s._1.a._1.a");
ExecutionState _s1a1a1a = assertedState(flow, 3, "sc.r.s._1.a._1.a._1.a");
ExecutionState _s1a1a2a = assertedState(flow, 4, "sc.r.s._1.a._1.a._2.a");
ExecutionState _s1a2a = assertedState(flow, 5, "sc.r.s._1.a._2.a");
ExecutionState _s1a2a1a = assertedState(flow, 6, "sc.r.s._1.a._2.a._1.a");
ExecutionState _s1a2a2a = assertedState(flow, 7, "sc.r.s._1.a._2.a._2.a");
ExecutionState _s2a = assertedState(flow, 8, "sc.r.s._2.a");
ExecutionState _s2a1a = assertedState(flow, 9, "sc.r.s._2.a._1.a");
ExecutionState _s2a1a1a = assertedState(flow, 10, "sc.r.s._2.a._1.a._1.a");
ExecutionState _s2a1a2a = assertedState(flow, 11, "sc.r.s._2.a._1.a._2.a");
ExecutionState _s2a2a = assertedState(flow, 12, "sc.r.s._2.a._2.a");
ExecutionState _s2a2a1a = assertedState(flow, 13, "sc.r.s._2.a._2.a._1.a");
ExecutionState _s2a2a2a = assertedState(flow, 14, "sc.r.s._2.a._2.a._2.a");
ExecutionState _b = assertedState(flow, 15, "sc.r.b");
// check the transition reaction ...
Reaction _t = _s1a2a.getReactions().get(0);
assertTrue(_t.isTransition());
// check the exit sequence of _s
Sequence _exit = assertedSequence(_t.getEffect());
assertEquals("wrong steps: " + stepListAsString(_exit), 2, _exit.getSteps().size());
assertedOrder(_exit, Lists.newArrayList(_s1a1a1a, _s1a1a2a, _s1a2a1a, _s1a2a2a, _s2a1a1a, _s2a1a2a, _s2a2a1a, _s2a2a2a), Lists.newArrayList(new StepLeaf(_s1a1a1a.getExitSequence()), //
new StepLeaf(_s1a1a2a.getExitSequence()), //
new StepLeaf(_s1a1a.getExitAction()), //
new StepLeaf(_s1a2a1a.getExitSequence()), //
new StepLeaf(_s1a2a2a.getExitSequence()), //
new StepLeaf(_s1a2a.getExitAction()), //
new StepLeaf(_s1a.getExitAction()), //
new StepLeaf(_s2a1a1a.getExitSequence()), //
new StepLeaf(_s2a1a2a.getExitSequence()), //
new StepLeaf(_s2a1a.getExitAction()), //
new StepLeaf(_s2a2a1a.getExitSequence()), //
new StepLeaf(_s2a2a2a.getExitSequence()), //
new StepLeaf(_s2a2a.getExitAction()), //
new StepLeaf(_s2a.getExitAction()), //
new StepLeaf(_s.getExitAction()), new StepLeaf(_b.getEnterSequences().get(0))));
assertCall(_exit, 1, _b.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSourceSiblingExitExclusion.
/**
* A transition to a state with orthogonal siblings that comes out of a non
* orthogonal sibling state must exclude the source state sibling exit or
* enter behavior.
*/
@SuppressWarnings("unused")
@Test
public void testSourceSiblingExitExclusion() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
{
Region r3a = _createRegion("r3a", s3);
{
Entry r3a_entry = _createEntry(EntryKind.INITIAL, null, r3a);
State s3a = _createState("s3a", r3a);
_createTransition(r3a_entry, s3a);
}
Region r3b = _createRegion("r3b", s3);
{
Entry r3b_entry = _createEntry(EntryKind.INITIAL, null, r3b);
State s3b = _createState("s3b", r3b);
State s3b2 = _createState("s3b2", r3b);
_createTransition(r3b_entry, s3b);
}
Region r3c = _createRegion("r3c", s3);
{
Entry r3c_entry = _createEntry(EntryKind.INITIAL, null, r3c);
State s3c = _createState("s3c", r3c);
_createTransition(r3c_entry, s3c);
}
}
State s3z = _createState("s3z", r3);
_createEntryAssignment(v1, s3, 42);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(findState(sc, "s3b2"), findState(sc, "s3z"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s3a = flow.getStates().get(3);
assertEquals("sc.r.s1.r3.s3.r3a.s3a", _s3a.getName());
ExecutionState _s3b = flow.getStates().get(4);
assertEquals("sc.r.s1.r3.s3.r3b.s3b", _s3b.getName());
ExecutionState _s3b2 = flow.getStates().get(5);
assertEquals("sc.r.s1.r3.s3.r3b.s3b2", _s3b2.getName());
ExecutionState _s3c = flow.getStates().get(6);
assertEquals("sc.r.s1.r3.s3.r3c.s3c", _s3c.getName());
ExecutionState _s3z = flow.getStates().get(7);
assertEquals("sc.r.s1.r3.s3z", _s3z.getName());
ExecutionState _s4 = flow.getStates().get(8);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(9);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s3b2.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong steps: " + stepListAsString(_effect), 2, _effect.getSteps().size());
assertedOrder(_effect, Lists.newArrayList(_s3a, _s3b2, _s3c), Lists.newArrayList(new StepLeaf(_s3a.getExitSequence()), new StepLeaf(_s3b2.getExitSequence()), new StepLeaf(_s3c.getExitSequence()), new StepLeaf(_s3z.getEnterSequences().get(0))));
assertCall(_effect, 1, _s3z.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSiblingRegionEntryOnTargetState.
/**
* The transition to a leaf state with orthogonal siblings must invoke the
* entry sequence of the orthogonal sibling regions.
*/
@SuppressWarnings("unused")
@Test
public void testSiblingRegionEntryOnTargetState() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(s5, findState(sc, "s3"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s4 = flow.getStates().get(3);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(4);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s5.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong sequence: " + stepListAsString(_effect), 4, _effect.getSteps().size());
assertCall(_effect, 0, _s5.getExitSequence());
assertCall(_effect, 1, _s2.getSuperScope().getEnterSequences().get(0));
assertCall(_s2.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(1).getReactSequence());
assertCall(_effect, 2, _s3.getEnterSequences().get(0));
assertCall(_effect, 3, _s4.getSuperScope().getEnterSequences().get(0));
assertCall(_s4.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(3).getReactSequence());
}
use of org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testBottomUpTransitionExitSequence_A.
/**
* A transition that exits from a deep orthogonal state structure should not
* contain multiple calls to exit actions
*/
@Test
public void testBottomUpTransitionExitSequence_A() {
Statechart sc = setUpDeepExitSC();
_createTransition(findStateFullyQualified(sc, "sc.r.s.1.a.1.a.2.a"), findStateFullyQualified(sc, "sc.r.b"));
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s = assertedState(flow, 0, "sc.r.s");
ExecutionState _s1a = assertedState(flow, 1, "sc.r.s._1.a");
ExecutionState _s1a1a = assertedState(flow, 2, "sc.r.s._1.a._1.a");
ExecutionState _s1a1a1a = assertedState(flow, 3, "sc.r.s._1.a._1.a._1.a");
ExecutionState _s1a1a2a = assertedState(flow, 4, "sc.r.s._1.a._1.a._2.a");
ExecutionState _s1a2a = assertedState(flow, 5, "sc.r.s._1.a._2.a");
ExecutionState _s1a2a1a = assertedState(flow, 6, "sc.r.s._1.a._2.a._1.a");
ExecutionState _s1a2a2a = assertedState(flow, 7, "sc.r.s._1.a._2.a._2.a");
ExecutionState _s2a = assertedState(flow, 8, "sc.r.s._2.a");
ExecutionState _s2a1a = assertedState(flow, 9, "sc.r.s._2.a._1.a");
ExecutionState _s2a1a1a = assertedState(flow, 10, "sc.r.s._2.a._1.a._1.a");
ExecutionState _s2a1a2a = assertedState(flow, 11, "sc.r.s._2.a._1.a._2.a");
ExecutionState _s2a2a = assertedState(flow, 12, "sc.r.s._2.a._2.a");
ExecutionState _s2a2a1a = assertedState(flow, 13, "sc.r.s._2.a._2.a._1.a");
ExecutionState _s2a2a2a = assertedState(flow, 14, "sc.r.s._2.a._2.a._2.a");
ExecutionState _b = assertedState(flow, 15, "sc.r.b");
// check the transition reaction ...
Reaction _t = _s1a1a2a.getReactions().get(0);
assertTrue(_t.isTransition());
// check the exit sequence of _s
Sequence _exit = assertedSequence(_t.getEffect());
assertEquals("wrong steps: " + stepListAsString(_exit), 2, _exit.getSteps().size());
assertedOrder(_exit, Sets.newHashSet(_s1a1a1a, _s1a1a2a, _s1a2a1a, _s1a2a2a, _s2a1a1a, _s2a1a2a, _s2a2a1a, _s2a2a2a), Lists.newArrayList(new StepLeaf(_s1a1a1a.getExitSequence()), //
new StepLeaf(_s1a1a2a.getExitSequence()), //
new StepLeaf(_s1a1a.getExitAction()), //
new StepLeaf(_s1a2a1a.getExitSequence()), //
new StepLeaf(_s1a2a2a.getExitSequence()), //
new StepLeaf(_s1a2a.getExitAction()), //
new StepLeaf(_s1a.getExitAction()), //
new StepLeaf(_s2a1a1a.getExitSequence()), //
new StepLeaf(_s2a1a2a.getExitSequence()), //
new StepLeaf(_s2a1a.getExitAction()), //
new StepLeaf(_s2a2a1a.getExitSequence()), //
new StepLeaf(_s2a2a2a.getExitSequence()), //
new StepLeaf(_s2a2a.getExitAction()), //
new StepLeaf(_s2a.getExitAction()), //
new StepLeaf(_s.getExitAction()), new StepLeaf(_b.getEnterSequences().get(0))));
assertCall(_exit, 1, _b.getEnterSequences().get(0));
}
Aggregations