use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ModelSequencerStateTest method testStateEntryAction.
/**
* if a state defines a entry action then the execution state must have a
* entryAction.
*/
@Test
public void testStateEntryAction() {
Statechart sc = _createStatechart("test");
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("main", sc);
Entry e = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
State s2 = _createState("s2", r);
_createTransition(e, s1);
_createTransition(s1, s2);
LocalReaction entryAction = _createEntryAction(s2);
_createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) entryAction.getEffect());
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals(s1.getName(), _s1.getSimpleName());
assertEquals(s2.getName(), _s2.getSimpleName());
assertNotNull(_s2.getEntryAction());
assertNull(_s1.getEntryAction());
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ModelSequencerStateTest method testCompositeStateExitSequence.
/**
* A composite state must have a exit sequence. This exit sequence consists
* of an exit action call and a state switch for all leaf states.
*/
@SuppressWarnings("unused")
@Test
public void testCompositeStateExitSequence() {
Statechart sc = _createStatechart("cs");
{
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("r", sc);
{
State s1 = _createState("s1", r);
{
_createExitAssignment(v1, s1, 1);
Region r1_s1 = _createRegion("r1", s1);
{
Entry e = _createEntry(EntryKind.INITIAL, null, r1_s1);
State s2 = _createState("s2", r1_s1);
State s3 = _createState("s3", r1_s1);
_createTransition(e, s2);
_createTransition(s2, s3);
}
Region r2_s1 = _createRegion("r2", s1);
{
Entry e = _createEntry(EntryKind.INITIAL, null, r2_s1);
State s4 = _createState("s4", r2_s1);
State s5 = _createState("s5", r2_s1);
State s6 = _createState("s6", r2_s1);
_createTransition(e, s4);
}
}
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals("s1", _s1.getSimpleName());
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("s2", _s2.getSimpleName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("s3", _s3.getSimpleName());
ExecutionState _s4 = flow.getStates().get(3);
assertEquals("s4", _s4.getSimpleName());
ExecutionState _s5 = flow.getStates().get(4);
assertEquals("s5", _s5.getSimpleName());
ExecutionState _s6 = flow.getStates().get(5);
assertEquals("s6", _s6.getSimpleName());
assertNotNull(_s1.getExitAction());
assertNotNull(_s1.getExitSequence());
assertEquals(3, _s1.getExitSequence().getSteps().size());
Sequence _r1_s1 = _s2.getSuperScope().getExitSequence();
assertCall(_s1.getExitSequence(), 0, _r1_s1);
Sequence _r2_s1 = _s4.getSuperScope().getExitSequence();
assertCall(_s1.getExitSequence(), 1, _r2_s1);
Step _switch = _r1_s1.getSteps().get(0);
assertStateSwitch(_switch, _s2, _s3);
assertCall(assertedSequence(assertedStateCase(_switch, _s2).getStep()), 0, _s2.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_switch, _s3).getStep()), 0, _s3.getExitSequence());
_switch = _r2_s1.getSteps().get(0);
assertStateSwitch(_switch, _s4, _s5, _s6);
assertCall(assertedSequence(assertedStateCase(_switch, _s4).getStep()), 0, _s4.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_switch, _s5).getStep()), 0, _s5.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_switch, _s6).getStep()), 0, _s6.getExitSequence());
assertCall(_s1.getExitSequence(), 2, _s1.getExitAction());
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class ModelSequencerStateTest method testStateExitAction.
/**
* if a state defines a exit action then the execution state must have a
* exitAction.
*/
@Test
public void testStateExitAction() {
Statechart sc = _createStatechart("test");
Scope scope = _createInterfaceScope("interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
Region r = _createRegion("main", sc);
Entry e = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
State s2 = _createState("s2", r);
_createTransition(e, s1);
_createTransition(s1, s2);
LocalReaction exitAction = _createExitAction(s1);
_createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(21), (ReactionEffect) exitAction.getEffect());
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals(s1.getName(), _s1.getSimpleName());
assertEquals(s2.getName(), _s2.getSimpleName());
assertNotNull(_s1.getExitAction());
assertNull(_s2.getExitAction());
}
use of org.yakindu.sct.model.sgraph.Region 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);
}
use of org.yakindu.sct.model.sgraph.Region in project statecharts by Yakindu.
the class TransitionsWithNoTriggerTest method noTriggerOnSyncOutgoing.
/**
* The outgoing transitions of a sync (fork / join) node must not have any
* trigger part. Thus empty transitions must not have any warning. This test
* case addresses a bug #75 (
* https://code.google.com/a/eclipselabs.org/p/yakindu/issues/detail?id=75 )
* .
*/
@Test
public void noTriggerOnSyncOutgoing() {
statechart = loadStatechart("ValidEmptyTransitionFromSync.sct");
Region validRegion = firstNamed(eAllOfType(statechart, Region.class), "valid");
Synchronization sync = eAllOfType(validRegion, Synchronization.class).get(0);
for (Transition t : sync.getOutgoingTransitions()) {
assertTrue(validate(t));
assertIssueCount(diagnostics, 0);
}
}
Aggregations