Search in sources :

Example 11 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class TransitionsWithNoTriggerTest method setup.

@Override
@Before
public void setup() {
    super.setup();
    StextFactory stextFactory = StextFactory.eINSTANCE;
    Region region = factory.createRegion();
    entry = factory.createEntry();
    stateA = factory.createState();
    stateA.setName("A");
    stateB = factory.createState();
    stateB.setName("B");
    stateC = factory.createState();
    stateC.setName("C");
    stateD = factory.createState();
    stateD.setName("D");
    choice = factory.createChoice();
    stateE = factory.createState();
    stateE.setName("E");
    entryToStateA = createTransition(entry, stateA);
    stateAToStateB = createTransition(stateA, stateB);
    stateBToStateC = createTransition(stateB, stateC);
    stateCToStateD = createTransition(stateC, stateD);
    stateCToStateD.setSpecification("always");
    ReactionTrigger triggerCToD = stextFactory.createReactionTrigger();
    triggerCToD.getTriggers().add(stextFactory.createAlwaysEvent());
    stateCToStateD.setTrigger(triggerCToD);
    choiceToStateE = createTransition(choice, stateE);
    stateBB = factory.createState();
    stateBB.setName("BB");
    entryB = factory.createEntry();
    exitB = factory.createExit();
    regionB = factory.createRegion();
    regionB.getVertices().add(entryB);
    regionB.getVertices().add(stateBB);
    regionB.getVertices().add(exitB);
    stateB.getRegions().add(regionB);
    entryBToStateBB = createTransition(entryB, stateBB);
    stateBBToExitB = createTransition(stateBB, exitB);
    region.getVertices().add(entry);
    region.getVertices().add(stateA);
    region.getVertices().add(stateB);
    region.getVertices().add(stateC);
    region.getVertices().add(stateD);
    statechart.getRegions().add(region);
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) StextFactory(org.yakindu.sct.model.stext.stext.StextFactory) Region(org.yakindu.sct.model.sgraph.Region) Before(org.junit.Before)

Example 12 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class LocalReactionTest method testSCLocalReaction.

/**
 * The transition sequence must contain all exit actions for parent states
 * that will be left by a transition.
 */
@Test
public void testSCLocalReaction() {
    Statechart sc = _createStatechart("sc");
    {
        LocalReaction lr0 = _createLocalReaction(sc, _createAlwaysEventSpec(null));
        VariableDefinition v = _createVariableDefinition("v", TYPE_INTEGER, getOrCreateInternalScope(sc));
        _createVariableAssignment(v, AssignmentOperator.ADD_ASSIGN, _createValue(1), (ReactionEffect) lr0.getEffect());
        Region r = _createRegion("r", sc);
        {
            State s1 = _createState("s1", r);
            {
                LocalReaction lr1 = _createLocalReaction(s1, _createAlwaysEventSpec(null));
                _createVariableAssignment(v, AssignmentOperator.ADD_ASSIGN, _createValue(2), (ReactionEffect) lr1.getEffect());
                _createEntryAssignment(v, s1, 1);
                Region r_s1 = _createRegion("r", s1);
                {
                    _createState("s3", r_s1);
                }
            }
            State s2 = _createState("s2", r);
            {
                _createEntryAssignment(v, s2, 1);
                Region r_s2 = _createRegion("r", s2);
                {
                    _createState("s6", r_s2);
                }
            }
        }
    }
    Transition t = _createTransition(findState(sc, "s3"), findState(sc, "s6"));
    ReactionTrigger tr = _createReactionTrigger(t);
    tr.setGuard(createGuardExpression(_createValue(true)));
    ExecutionFlow flow = sequencer.transform(sc);
    assertEquals(1, flow.getReactions().size());
    ExecutionState _s1 = flow.getStates().get(0);
    assertEquals("sc.r.s1", _s1.getName());
    // assertEquals(1, _s1.getReactions().size());
    ExecutionState _s3 = flow.getStates().get(1);
    assertEquals("sc.r.s1.r.s3", _s3.getName());
    ExecutionState _s2 = flow.getStates().get(2);
    assertEquals("sc.r.s2", _s2.getName());
    // assertEquals(1, _s2.getReactions().size());
    ExecutionState _s6 = flow.getStates().get(3);
    assertEquals("sc.r.s2.r.s6", _s6.getName());
    Reaction _t = _s3.getReactions().get(0);
    assertTrue(_t.isTransition());
    // Check Stateswitch in flow
    StateSwitch sSwitch = assertedSwitch(flow.getReactSequence().getSteps().get(0));
    assertStateSwitch(sSwitch, _s3, _s6);
    assertCall(assertedStateCase(sSwitch, _s3).getStep(), _s3.getReactSequence());
    // Check reactSequence of leaf state
    Sequence _effect = (Sequence) _t.getEffect();
    assertCall(_effect, 0, _s1.getExitSequence());
    assertCall(_effect, 1, _s2.getEntryAction());
    assertCall(_effect, 2, _s6.getEnterSequences().get(0));
    assertEquals(3, _effect.getSteps().size());
    List<Step> steps = flattenSequenceStepsAsList(_s3.getReactSequence());
    If _if = assertClass(If.class, steps.get(0));
    assertEquals(flow.getReactions().get(0).getCheck(), assertClass(CheckRef.class, _if.getCheck()).getCheck());
    _if = assertClass(If.class, steps.get(1));
    assertEquals(_s1.getReactions().get(0).getCheck(), assertClass(CheckRef.class, _if.getCheck()).getCheck());
    _if = assertClass(If.class, steps.get(2));
    assertNotNull(assertClass(CheckRef.class, _if.getCheck()).getCheck());
    assertCall(_if.getThenStep(), _effect);
}
Also used : StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Sequence(org.yakindu.sct.model.sexec.Sequence) Step(org.yakindu.sct.model.sexec.Step) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Reaction(org.yakindu.sct.model.sexec.Reaction) StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) SGraphTestFactory._createState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) SCTTestUtil.findState(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) SGraphTestFactory._createTransition(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition) Statechart(org.yakindu.sct.model.sgraph.Statechart) SGraphTestFactory._createStatechart(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart) Region(org.yakindu.sct.model.sgraph.Region) SGraphTestFactory._createRegion(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion) StateSwitch(org.yakindu.sct.model.sexec.StateSwitch) If(org.yakindu.sct.model.sexec.If) Test(org.junit.Test)

Example 13 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class ModelSequencerStateTest method testStateCycle_WithLocalReactionsOnly.

/**
 * The cycle sequence of a state that only consists of local reactions
 * includes sequential processing of the local reactions.
 */
@SuppressWarnings("unused")
@Test
public void testStateCycle_WithLocalReactionsOnly() {
    MinimalTSC tsc = new MinimalTSC();
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, tsc.s_scope);
    // the first local reaction conforms to "e1 / x=42;"
    LocalReaction lr1 = _createLocalReaction(tsc.s1, null);
    _createRegularEventSpec(tsc.e1, (ReactionTrigger) lr1.getTrigger());
    ReactionEffect lr1_eff = _createReactionEffect(lr1);
    AssignmentExpression assign1 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), lr1_eff);
    // the secont local reaction conforms to "e1 [x==42] / x=0;"
    LocalReaction lr2 = _createLocalReaction(tsc.s1, null);
    _createRegularEventSpec(tsc.e1, (ReactionTrigger) lr2.getTrigger());
    LogicalRelationExpression lr2_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
    lr2_equals.setOperator(RelationalOperator.EQUALS);
    ElementReferenceExpression lr2_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
    lr2_varRef.setReference(v1);
    PrimitiveValueExpression lr2_value = _createValue(42);
    lr2_equals.setLeftOperand(lr2_varRef);
    lr2_equals.setRightOperand(lr2_value);
    ((ReactionTrigger) lr2.getTrigger()).setGuard(createGuardExpression(lr2_equals));
    ReactionEffect lr2_eff = _createReactionEffect(lr2);
    AssignmentExpression assign2 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(0), lr2_eff);
    // the third local reaction conforms to: "[x==0] / x=1;"
    LocalReaction lr3 = _createLocalReaction(tsc.s1, null);
    LogicalRelationExpression lr3_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
    lr3_equals.setOperator(RelationalOperator.EQUALS);
    ElementReferenceExpression lr3_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
    lr3_varRef.setReference(v1);
    PrimitiveValueExpression lr3_value = _createValue(0);
    lr3_equals.setLeftOperand(lr3_varRef);
    lr3_equals.setRightOperand(lr3_value);
    ((ReactionTrigger) lr3.getTrigger()).setGuard(createGuardExpression(lr3_equals));
    ReactionEffect lr3_eff = _createReactionEffect(lr3);
    AssignmentExpression assign3 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(1), lr3_eff);
    ExecutionFlow flow = sequencer.transform(tsc.sc);
    // test state with one outgoing transition
    ExecutionState s1 = flow.getStates().get(0);
    assertEquals(tsc.s1.getName(), s1.getSimpleName());
    assertEquals(3, s1.getReactions().size());
    assertNotNull(s1.getReactSequence());
    Step step = s1.getReactSequence().getSteps().get(0);
    Sequence _seq = assertedSequence(assertedSequence(assertedSequence(assertedSequence(assertedSequence(step).getSteps().get(0)).getSteps().get(0)).getSteps().get(0)).getSteps().get(0));
    assertEquals(3, _seq.getSteps().size());
    // check first local reaction
    If _lr1 = (If) _seq.getSteps().get(0);
    assertClass(ElementReferenceExpression.class, _lr1.getCheck().getCondition());
    assertSame(s1.getReactions().get(0).getCheck().getCondition(), _lr1.getCheck().getCondition());
    Call _lr1_eff_call = (Call) _lr1.getThenStep();
    assertSame(s1.getReactions().get(0).getEffect(), _lr1_eff_call.getStep());
    // check second local reaction
    If _lr2 = (If) _seq.getSteps().get(1);
    assertClass(LogicalAndExpression.class, _lr2.getCheck().getCondition());
    assertSame(s1.getReactions().get(1).getCheck().getCondition(), _lr2.getCheck().getCondition());
    Call _lr2_eff_call = (Call) _lr2.getThenStep();
    assertSame(s1.getReactions().get(1).getEffect(), _lr2_eff_call.getStep());
    // check the third local reaction
    If _lr3 = (If) _seq.getSteps().get(2);
    assertClass(LogicalRelationExpression.class, _lr3.getCheck().getCondition());
    assertSame(s1.getReactions().get(2).getCheck().getCondition(), _lr3.getCheck().getCondition());
    Call _lr3_eff_call = (Call) _lr3.getThenStep();
    assertSame(s1.getReactions().get(2).getEffect(), _lr3_eff_call.getStep());
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) Call(org.yakindu.sct.model.sexec.Call) MinimalTSC(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.MinimalTSC) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) StextTestFactory._createReactionEffect(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionEffect) Step(org.yakindu.sct.model.sexec.Step) Sequence(org.yakindu.sct.model.sexec.Sequence) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) LogicalRelationExpression(org.yakindu.base.expressions.expressions.LogicalRelationExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) If(org.yakindu.sct.model.sexec.If) Test(org.junit.Test)

Example 14 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class ModelSequencerStateTest method testStateCycle_WithLocalReactions.

@SuppressWarnings("unused")
@Test
public void testStateCycle_WithLocalReactions() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, tsc.s_scope);
    // the first local reaction conforms to "e1 / x=42;"
    LocalReaction lr1 = _createLocalReaction(tsc.s1, null);
    _createRegularEventSpec(tsc.e1, (ReactionTrigger) lr1.getTrigger());
    ReactionEffect lr1_eff = _createReactionEffect(lr1);
    AssignmentExpression assign1 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), lr1_eff);
    // the secont local reaction conforms to "e1 [x==42] / x=0;"
    LocalReaction lr2 = _createLocalReaction(tsc.s1, null);
    _createRegularEventSpec(tsc.e1, (ReactionTrigger) lr2.getTrigger());
    LogicalRelationExpression lr2_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
    lr2_equals.setOperator(RelationalOperator.EQUALS);
    ElementReferenceExpression lr2_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
    lr2_varRef.setReference(v1);
    PrimitiveValueExpression lr2_value = _createValue(42);
    lr2_equals.setLeftOperand(lr2_varRef);
    lr2_equals.setRightOperand(lr2_value);
    ((ReactionTrigger) lr2.getTrigger()).setGuard(createGuardExpression(lr2_equals));
    ReactionEffect lr2_eff = _createReactionEffect(lr2);
    AssignmentExpression assign2 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(0), lr2_eff);
    // the third local reaction conforms to: "[x==0] / x=1;"
    LocalReaction lr3 = _createLocalReaction(tsc.s1, null);
    LogicalRelationExpression lr3_equals = ExpressionsFactory.eINSTANCE.createLogicalRelationExpression();
    lr3_equals.setOperator(RelationalOperator.EQUALS);
    ElementReferenceExpression lr3_varRef = ExpressionsFactory.eINSTANCE.createElementReferenceExpression();
    lr3_varRef.setReference(v1);
    PrimitiveValueExpression lr3_value = _createValue(0);
    lr3_equals.setLeftOperand(lr3_varRef);
    lr3_equals.setRightOperand(lr3_value);
    ((ReactionTrigger) lr3.getTrigger()).setGuard(createGuardExpression(lr3_equals));
    ReactionEffect lr3_eff = _createReactionEffect(lr3);
    AssignmentExpression assign3 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(1), lr3_eff);
    ExecutionFlow flow = sequencer.transform(tsc.sc);
    // test state with one outgoing transition
    ExecutionState s1 = flow.getStates().get(0);
    ExecutionState s2 = flow.getStates().get(1);
    assertEquals(tsc.s1.getName(), s1.getSimpleName());
    assertEquals(tsc.s2.getName(), s2.getSimpleName());
    assertEquals(4, s1.getReactions().size());
    assertNotNull(s1.getReactSequence());
    Step step = s1.getReactSequence().getSteps().get(0);
    If _if = (If) assertedSequence(assertedSequence(assertedSequence(step).getSteps().get(0)).getSteps().get(0)).getSteps().get(0);
    assertNotNull(_if.getThenStep());
    assertClass(Call.class, _if.getThenStep());
    assertNotNull(_if.getElseStep());
    Sequence _seq = assertedSequence(assertedSequence(_if.getElseStep()).getSteps().get(0));
    assertEquals(3, _seq.getSteps().size());
    // check first local reaction
    If _lr1 = (If) _seq.getSteps().get(0);
    assertClass(ElementReferenceExpression.class, _lr1.getCheck().getCondition());
    assertSame(s1.getReactions().get(0).getCheck().getCondition(), _lr1.getCheck().getCondition());
    Call _lr1_eff_call = (Call) _lr1.getThenStep();
    assertSame(s1.getReactions().get(0).getEffect(), _lr1_eff_call.getStep());
    // check second local reaction
    If _lr2 = (If) _seq.getSteps().get(1);
    assertClass(LogicalAndExpression.class, _lr2.getCheck().getCondition());
    assertSame(s1.getReactions().get(1).getCheck().getCondition(), _lr2.getCheck().getCondition());
    Call _lr2_eff_call = (Call) _lr2.getThenStep();
    assertSame(s1.getReactions().get(1).getEffect(), _lr2_eff_call.getStep());
    // check the third local reaction
    If _lr3 = (If) _seq.getSteps().get(2);
    assertClass(LogicalRelationExpression.class, _lr3.getCheck().getCondition());
    assertSame(s1.getReactions().get(2).getCheck().getCondition(), _lr3.getCheck().getCondition());
    Call _lr3_eff_call = (Call) _lr3.getThenStep();
    assertSame(s1.getReactions().get(2).getEffect(), _lr3_eff_call.getStep());
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) Call(org.yakindu.sct.model.sexec.Call) SimpleFlatTSC(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) StextTestFactory._createReactionEffect(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionEffect) Step(org.yakindu.sct.model.sexec.Step) Sequence(org.yakindu.sct.model.sexec.Sequence) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) LogicalRelationExpression(org.yakindu.base.expressions.expressions.LogicalRelationExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) If(org.yakindu.sct.model.sexec.If) Test(org.junit.Test)

Example 15 with ReactionTrigger

use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.

the class ModelSequencerStateTest method testFinalState.

/**
 * A final state must be transformed into a execution state with name
 * '_final_'. and must include parent reactions.
 */
@SuppressWarnings("unused")
@Test
public void testFinalState() {
    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);
            {
                // a local reaction: "e1 / x=42;"
                LocalReaction lr1 = _createLocalReaction(s1, null);
                _createRegularEventSpec(e1, (ReactionTrigger) lr1.getTrigger());
                ReactionEffect lr1_eff = _createReactionEffect(lr1);
                AssignmentExpression assign1 = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), lr1_eff);
                Region r_s1 = _createRegion("r", s1);
                {
                    State s3 = _createState("s3", r_s1);
                    {
                        _createEntryAssignment(v1, s3, 2);
                        Region r_s3 = _createRegion("r", s3);
                        {
                            State s4 = _createState("s4", r_s3);
                            // _createEntryAssignment(v1, s4, 3);
                            FinalState fs = _createFinalState(r_s3);
                            Transition t_s4_fs = _createTransition(findState(sc, "s4"), fs);
                            _createReactionTrigger(t_s4_fs);
                            _createRegularEventSpec(e1, (ReactionTrigger) t_s4_fs.getTrigger());
                        }
                    }
                }
            }
            State s2 = _createState("s2", r);
            {
                Region r_s1 = _createRegion("r", s2);
                {
                    _createState("s6", r_s1);
                }
            }
        }
        Transition t_s3_s6 = _createTransition(findState(sc, "s3"), findState(sc, "s6"));
        _createReactionTrigger(t_s3_s6);
        _createRegularEventSpec(e1, (ReactionTrigger) t_s3_s6.getTrigger());
    }
    ExecutionFlow flow = sequencer.transform(sc);
    ExecutionState _s1 = flow.getStates().get(0);
    assertEquals("sc.r.s1", _s1.getName());
    ExecutionState _s3 = flow.getStates().get(1);
    assertEquals("sc.r.s1.r.s3", _s3.getName());
    ExecutionState _s4 = flow.getStates().get(2);
    assertEquals("sc.r.s1.r.s3.r.s4", _s4.getName());
    ExecutionState _fs = flow.getStates().get(3);
    assertEquals("sc.r.s1.r.s3.r._final_", _fs.getName());
    ExecutionState _s6 = flow.getStates().get(5);
    assertEquals("sc.r.s2.r.s6", _s6.getName());
    assertNull(_fs.getEntryAction());
    assertNull(_fs.getExitAction());
    Sequence cycle = _fs.getReactSequence();
    Sequence _seq = (Sequence) cycle.getSteps().get(0);
    // first entry is the s1 local reaction
    List<Step> steps = SCTTestUtil.flattenSequenceStepsAsList(_seq);
    If _if = (If) steps.get(0);
    assertCall(_if.getThenStep(), _s1.getReactions().get(0).getEffect());
    // second entry is the s3 cycle with the transition reaction
    _if = (If) steps.get(1);
    assertCall(_if.getThenStep(), _s3.getReactions().get(0).getEffect());
    assertTrue(_s3.getReactions().get(0).isTransition());
    assertNotNull(_if.getElseStep());
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) StextTestFactory._createInterfaceScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) StextTestFactory._createReactionEffect(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionEffect) Sequence(org.yakindu.sct.model.sexec.Sequence) Step(org.yakindu.sct.model.sexec.Step) StextTestFactory._createEventDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createEventDefinition) EventDefinition(org.yakindu.sct.model.stext.stext.EventDefinition) FinalState(org.yakindu.sct.model.sgraph.FinalState) SGraphTestFactory._createFinalState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createFinalState) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) FinalState(org.yakindu.sct.model.sgraph.FinalState) SGraphTestFactory._createFinalState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createFinalState) ExitState(org.yakindu.sct.model.sexec.ExitState) SCTTestUtil.findState(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState) SGraphTestFactory._createState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) EnterState(org.yakindu.sct.model.sexec.EnterState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) SGraphTestFactory._createTransition(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition) Statechart(org.yakindu.sct.model.sgraph.Statechart) SGraphTestFactory._createStatechart(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart) Region(org.yakindu.sct.model.sgraph.Region) SGraphTestFactory._createRegion(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion) If(org.yakindu.sct.model.sexec.If) Test(org.junit.Test)

Aggregations

ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)26 Test (org.junit.Test)20 StextTestFactory._createReactionTrigger (org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger)16 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)14 Statechart (org.yakindu.sct.model.sgraph.Statechart)13 Region (org.yakindu.sct.model.sgraph.Region)12 Transition (org.yakindu.sct.model.sgraph.Transition)12 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)11 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)11 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)11 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)10 If (org.yakindu.sct.model.sexec.If)10 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)10 StextTestFactory._createLocalReaction (org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction)10 State (org.yakindu.sct.model.sgraph.State)9 SGraphTestFactory._createTransition (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition)9 EventDefinition (org.yakindu.sct.model.stext.stext.EventDefinition)9 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)8 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)8 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)8