Search in sources :

Example 1 with SimpleFlatTSC

use of org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC in project statecharts by Yakindu.

the class ModelSequencerStateVectorTest method testSCStateVectorFlatNonOrthopgonal.

/**
 * The state vector descriptor of the ExecutionFlow must have an offset of 0
 * and a size that is the maximum orthogonality of the statechart.
 */
@Test
public void testSCStateVectorFlatNonOrthopgonal() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    ExecutionFlow flow = sequencer.transform(tsc.sc);
    assertNotNull(flow.getStateVector());
    assertEquals(1, flow.getStateVector().getSize());
    assertEquals(0, flow.getStateVector().getOffset());
}
Also used : SimpleFlatTSC(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Test(org.junit.Test)

Example 2 with SimpleFlatTSC

use of org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC in project statecharts by Yakindu.

the class ModelSequencerSCTest method testSCEnterSequence_SimpleFlatTSC.

/**
 * In the simplest case the a state without an actions will be entered.
 */
@Test
public void testSCEnterSequence_SimpleFlatTSC() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    ExecutionFlow flow = sequencer.transform(tsc.sc);
    assertNotNull(flow.getEnterSequences().get(0));
    assertEquals(2, flow.getEnterSequences().get(0).getSteps().size());
    assertCall(flow.getEnterSequences().get(0), 1, flow.getStates().get(0).getSuperScope().getEnterSequences().get(0));
    Sequence entryReactSequence = flow.getNodes().get(0).getReactSequence();
    assertCall(flow.getStates().get(0).getSuperScope().getEnterSequences().get(0), 0, entryReactSequence);
    assertCall(((Sequence) firstStep(firstStep(entryReactSequence))), 0, flow.getStates().get(0).getEnterSequences().get(0));
}
Also used : SimpleFlatTSC(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Sequence(org.yakindu.sct.model.sexec.Sequence) Test(org.junit.Test)

Example 3 with SimpleFlatTSC

use of org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC in project statecharts by Yakindu.

the class ModelSequencerStateTest method testStateReaction_WithExitAction.

/**
 * The exit action must be part of the reaction effect sequence
 */
@SuppressWarnings("unused")
@Test
public void testStateReaction_WithExitAction() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, tsc.s_scope);
    LocalReaction exitAction = _createExitAction(tsc.s1);
    AssignmentExpression assign = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(21), (ReactionEffect) exitAction.getEffect());
    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(1, _s1.getReactions().size());
    Reaction reaction = _s1.getReactions().get(0);
    assertNotNull(reaction.getCheck());
    assertNotNull(reaction.getEffect());
    Sequence seq = (Sequence) reaction.getEffect();
    assertCall(seq, 0, _s1.getExitSequence());
    assertCall(_s1.getExitSequence(), 1, _s1.getExitAction());
}
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) 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) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Sequence(org.yakindu.sct.model.sexec.Sequence) LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) Reaction(org.yakindu.sct.model.sexec.Reaction) Test(org.junit.Test)

Example 4 with SimpleFlatTSC

use of org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC in project statecharts by Yakindu.

the class ModelSequencerStateTest method testStateReaction_SimpleFlatTSC.

@Test
public void testStateReaction_SimpleFlatTSC() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    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(1, s1.getReactions().size());
    Reaction reaction = s1.getReactions().get(0);
    assertNotNull(reaction.getCheck());
    assertNotNull(reaction.getEffect());
    Sequence seq = (Sequence) reaction.getEffect();
    assertCall(seq, 0, s1.getExitSequence());
    assertCall(seq, 1, s2.getEnterSequences().get(0));
}
Also used : ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) SimpleFlatTSC(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Sequence(org.yakindu.sct.model.sexec.Sequence) LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) Reaction(org.yakindu.sct.model.sexec.Reaction) Test(org.junit.Test)

Example 5 with SimpleFlatTSC

use of org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC in project statecharts by Yakindu.

the class ModelSequencerStateTest method testStateReaction_WithEntryAction.

/**
 * The exit action must be part of the reaction effect sequence
 */
@SuppressWarnings("unused")
@Test
public void testStateReaction_WithEntryAction() {
    SimpleFlatTSC tsc = new SimpleFlatTSC();
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, tsc.s_scope);
    LocalReaction entryAction = _createEntryAction(tsc.s2);
    AssignmentExpression assign = _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(21), (ReactionEffect) entryAction.getEffect());
    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(1, _s1.getReactions().size());
    Reaction reaction = _s1.getReactions().get(0);
    assertNotNull(reaction.getCheck());
    assertNotNull(reaction.getEffect());
    Sequence seq = (Sequence) reaction.getEffect();
    assertEquals(2, seq.getSteps().size());
    assertCall(seq, 0, _s1.getExitSequence());
    assertCall(seq, 1, _s2.getEnterSequences().get(0));
    assertCall(_s2.getEnterSequences().get(0), 0, _s2.getEntryAction());
}
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) 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) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Sequence(org.yakindu.sct.model.sexec.Sequence) LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) Reaction(org.yakindu.sct.model.sexec.Reaction) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)8 SimpleFlatTSC (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.SimpleFlatTSC)8 Sequence (org.yakindu.sct.model.sexec.Sequence)6 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)5 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)5 StextTestFactory._createLocalReaction (org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction)5 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)4 Reaction (org.yakindu.sct.model.sexec.Reaction)4 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)4 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)4 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)2 StextTestFactory._createReactionEffect (org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionEffect)2 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 LogicalRelationExpression (org.yakindu.base.expressions.expressions.LogicalRelationExpression)1 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)1 Call (org.yakindu.sct.model.sexec.Call)1 Execution (org.yakindu.sct.model.sexec.Execution)1 If (org.yakindu.sct.model.sexec.If)1 Step (org.yakindu.sct.model.sexec.Step)1