use of org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope 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.stext.test.util.StextTestFactory._createInterfaceScope 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.stext.test.util.StextTestFactory._createInterfaceScope 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.stext.test.util.StextTestFactory._createInterfaceScope in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSiblingRegionExitFromSourceState.
/*
* --------------------------------------------------------------------------
* ----------------- Exit behavior tests
* ------------------------------------
* -------------------------------------------------------
*/
/**
* The transition from a leaf state with orthogonal siblings must invoke the
* exit sequence of the orthogonal sibling regions.
*/
@SuppressWarnings("unused")
@Test
public void testSiblingRegionExitFromSourceState() {
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);
State s2b = _createState("s2b", r2);
}
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);
State s4b = _createState("s4b", r4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(findState(sc, "s3"), s5);
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals("sc.r.s1", _s1.getName());
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s2b = flow.getStates().get(2);
assertEquals("sc.r.s1.r2.s2b", _s2b.getName());
ExecutionState _s3 = flow.getStates().get(3);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s4 = flow.getStates().get(4);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s4b = flow.getStates().get(5);
assertEquals("sc.r.s1.r4.s4b", _s4b.getName());
ExecutionState _s5 = flow.getStates().get(6);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s3.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals(2, _effect.getSteps().size());
assertedOrder(_effect, Lists.newArrayList(_s2b, _s3, _s4b), Lists.newArrayList(new StepLeaf(_s2b.getExitSequence()), new StepLeaf(_s3.getExitSequence()), new StepLeaf(_s4b.getExitSequence())));
assertCall(_effect, 1, _s5.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope in project statecharts by Yakindu.
the class ModelSequencerStateReactionTest method testAlwaysLocalReaction.
/**
* Local reactions must be created for behavior with 'always' trigger
*/
@SuppressWarnings("unused")
@Test
public void testAlwaysLocalReaction() {
Statechart sc = _createStatechart("test");
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("main", sc);
State s = _createState("s", r);
LocalReaction timeTriggeredReaction = _createLocalReaction(s, StextFactory.eINSTANCE.createAlwaysEvent());
AssignmentExpression assign = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) timeTriggeredReaction.getEffect());
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s = flow.getStates().get(0);
// assert that a local reaction is created
Reaction reaction = _s.getReactions().get(0);
PrimitiveValueExpression pve = (PrimitiveValueExpression) reaction.getCheck().getCondition();
assertBoolLiteral(true, pve.getValue());
}
Aggregations