|
@@ -6,8 +6,12 @@ import static org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.*;
|
|
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
+import org.yakindu.sct.model.sexec.EnterState;
|
|
import org.yakindu.sct.model.sexec.ExecutionFlow;
|
|
import org.yakindu.sct.model.sexec.ExecutionFlow;
|
|
|
|
+import org.yakindu.sct.model.sexec.ExecutionState;
|
|
|
|
+import org.yakindu.sct.model.sexec.ExitState;
|
|
import org.yakindu.sct.model.sexec.If;
|
|
import org.yakindu.sct.model.sexec.If;
|
|
|
|
+import org.yakindu.sct.model.sexec.Sequence;
|
|
import org.yakindu.sct.model.sexec.transformation.ModelSequencer;
|
|
import org.yakindu.sct.model.sexec.transformation.ModelSequencer;
|
|
import org.yakindu.sct.model.sexec.transformation.SequencerModule;
|
|
import org.yakindu.sct.model.sexec.transformation.SequencerModule;
|
|
import org.yakindu.sct.model.sgraph.Declaration;
|
|
import org.yakindu.sct.model.sgraph.Declaration;
|
|
@@ -47,8 +51,7 @@ public class ModelSequencerTest {
|
|
injector.injectMembers(this);
|
|
injector.injectMembers(this);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The name of the execution flow must be equal to the statechart name.
|
|
* The name of the execution flow must be equal to the statechart name.
|
|
*/
|
|
*/
|
|
@@ -88,6 +91,127 @@ public class ModelSequencerTest {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * the scope name must be mapped.
|
|
|
|
+ */
|
|
|
|
+ @Test public void testScopeName() {
|
|
|
|
+ InterfaceScope scope = _createInterfaceScope("abc", null);
|
|
|
|
+ assertEquals(scope.getName(), ((InterfaceScope) sequencer.map(scope)).getName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * An InternalScope must be mapped to an InternalScope.
|
|
|
|
+ */
|
|
|
|
+ @Test public void testMapEmptyInternalScope() {
|
|
|
|
+ InternalScope scope = _createInternalScope(null);
|
|
|
|
+ Scope _scope = sequencer.map(scope);
|
|
|
|
+
|
|
|
|
+ assertTrue(_scope instanceof InternalScope);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testMapScope() {
|
|
|
|
+
|
|
|
|
+ InterfaceScope scope = _createInterfaceScope(null, null);
|
|
|
|
+ EventDefinition e1 = _createEventDefinition("e1", scope);
|
|
|
|
+ EventDefinition e2 = _createEventDefinition("e2", scope);
|
|
|
|
+ VariableDefinition v1 = _createVariableDefinition("v1", Type.INTEGER, scope);
|
|
|
|
+
|
|
|
|
+ Scope _scope = sequencer.map(scope);
|
|
|
|
+
|
|
|
|
+ assertTrue(_scope instanceof InterfaceScope);
|
|
|
|
+ assertEquals(3, _scope.getDeclarations().size());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for ( int i =0; i<_scope.getDeclarations().size(); i++) {
|
|
|
|
+ Declaration s_decl = scope.getDeclarations().get(i);
|
|
|
|
+ Declaration r_decl = _scope.getDeclarations().get(i);
|
|
|
|
+
|
|
|
|
+ assertNotSame(s_decl, r_decl);
|
|
|
|
+ assertEquals(s_decl.getName(), r_decl.getName());
|
|
|
|
+ assertEquals(s_decl.getClass(), r_decl.getClass());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * In the simplest case the a stet without an actions will be entered.
|
|
|
|
+ */
|
|
|
|
+ @Test public void testSCEnterSequence_SimpleFlatTSC() {
|
|
|
|
+ SimpleFlatTSC tsc = new SimpleFlatTSC();
|
|
|
|
+
|
|
|
|
+ ExecutionFlow flow = sequencer.transform(tsc.sc);
|
|
|
|
+
|
|
|
|
+ assertNotNull(flow.getEnterSequence());
|
|
|
|
+ assertEquals(1, flow.getEnterSequence().getSteps().size());
|
|
|
|
+
|
|
|
|
+ EnterState enterState = (EnterState) flow.getEnterSequence().getSteps().get(0);
|
|
|
|
+ assertEquals(tsc.s1.getName(), enterState.getState().getSimpleName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * For each top level region a EnterState step must be performed.
|
|
|
|
+ */
|
|
|
|
+ @Test public void testSCEnterSequence_OrthogonalFlatTSC() {
|
|
|
|
+ OrthogonalFlatTSC tsc = new OrthogonalFlatTSC();
|
|
|
|
+
|
|
|
|
+ ExecutionFlow flow = sequencer.transform(tsc.sc);
|
|
|
|
+
|
|
|
|
+ assertNotNull(flow.getEnterSequence());
|
|
|
|
+ assertEquals(2, flow.getEnterSequence().getSteps().size());
|
|
|
|
+
|
|
|
|
+ EnterState enterState = (EnterState) flow.getEnterSequence().getSteps().get(0);
|
|
|
|
+ assertEquals(tsc.s1.getName(), enterState.getState().getSimpleName());
|
|
|
|
+
|
|
|
|
+ enterState = (EnterState) flow.getEnterSequence().getSteps().get(1);
|
|
|
|
+ assertEquals(tsc.s3.getName(), enterState.getState().getSimpleName());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Test public void testStateCycle_SimpleFlatTSC() {
|
|
|
|
+ OrthogonalFlatTSC tsc = new OrthogonalFlatTSC();
|
|
|
|
+
|
|
|
|
+ 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());
|
|
|
|
+ assertNotNull(s1.getCycle());
|
|
|
|
+
|
|
|
|
+ If _if = (If) s1.getCycle().getSteps().get(0);
|
|
|
|
+ assertNotNull(_if.getThenStep());
|
|
|
|
+ assertTrue(_if.getThenStep() instanceof Sequence);
|
|
|
|
+ assertNull(_if.getElseStep());
|
|
|
|
+
|
|
|
|
+ Sequence seq = (Sequence) _if.getThenStep();
|
|
|
|
+ assertTrue(seq.getSteps().get(0) instanceof ExitState);
|
|
|
|
+ assertEquals(s1, ((ExitState)seq.getSteps().get(0)).getState());
|
|
|
|
+ assertTrue(seq.getSteps().get(1) instanceof EnterState);
|
|
|
|
+ assertEquals(s2, ((EnterState)seq.getSteps().get(1)).getState());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // test state with two outgoing transitions
|
|
|
|
+ ExecutionState s3 = flow.getStates().get(2);
|
|
|
|
+ assertEquals(tsc.s3.getName(), s3.getSimpleName());
|
|
|
|
+ assertNotNull(s3.getCycle());
|
|
|
|
+
|
|
|
|
+ _if = (If) s3.getCycle().getSteps().get(0);
|
|
|
|
+ assertNotNull(_if.getThenStep());
|
|
|
|
+ assertTrue(_if.getThenStep() instanceof Sequence);
|
|
|
|
+ assertNotNull(_if.getElseStep());
|
|
|
|
+ assertTrue(_if.getElseStep() instanceof If);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Single trigger events of a Reaction Trigger will be converted into a single condition
|
|
* Single trigger events of a Reaction Trigger will be converted into a single condition
|
|
* that consists of a ElementReferenceExpression to the corresponding event definition.
|
|
* that consists of a ElementReferenceExpression to the corresponding event definition.
|
|
@@ -129,7 +253,7 @@ public class ModelSequencerTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testTransitionSequence() {
|
|
|
|
|
|
+ public void testTransitionTriggerSequence() {
|
|
|
|
|
|
EventDefinition e1 = _createEventDefinition("e1", null);
|
|
EventDefinition e1 = _createEventDefinition("e1", null);
|
|
EventDefinition e2 = _createEventDefinition("e2", null);
|
|
EventDefinition e2 = _createEventDefinition("e2", null);
|
|
@@ -154,48 +278,6 @@ public class ModelSequencerTest {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * the scope name must be mapped.
|
|
|
|
- */
|
|
|
|
- @Test public void testScopeName() {
|
|
|
|
- InterfaceScope scope = _createInterfaceScope("abc", null);
|
|
|
|
- assertEquals(scope.getName(), ((InterfaceScope) sequencer.map(scope)).getName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * An InternalScope must be mapped to an InternalScope.
|
|
|
|
- */
|
|
|
|
- @Test public void testMapEmptyInternalScope() {
|
|
|
|
- InternalScope scope = _createInternalScope(null);
|
|
|
|
- Scope _scope = sequencer.map(scope);
|
|
|
|
-
|
|
|
|
- assertTrue(_scope instanceof InternalScope);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testMapScope() {
|
|
|
|
-
|
|
|
|
- InterfaceScope scope = _createInterfaceScope(null, null);
|
|
|
|
- EventDefinition e1 = _createEventDefinition("e1", scope);
|
|
|
|
- EventDefinition e2 = _createEventDefinition("e2", scope);
|
|
|
|
- VariableDefinition v1 = _createVariableDefinition("v1", Type.INTEGER, scope);
|
|
|
|
-
|
|
|
|
- Scope _scope = sequencer.map(scope);
|
|
|
|
|
|
|
|
- assertTrue(_scope instanceof InterfaceScope);
|
|
|
|
- assertEquals(3, _scope.getDeclarations().size());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for ( int i =0; i<_scope.getDeclarations().size(); i++) {
|
|
|
|
- Declaration s_decl = scope.getDeclarations().get(i);
|
|
|
|
- Declaration r_decl = _scope.getDeclarations().get(i);
|
|
|
|
-
|
|
|
|
- assertNotSame(s_decl, r_decl);
|
|
|
|
- assertEquals(s_decl.getName(), r_decl.getName());
|
|
|
|
- assertEquals(s_decl.getClass(), r_decl.getClass());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|