Просмотр исходного кода

- name property execution flow
- extended flow transformation
- added and refactored tests

terfloth@itemis.de 14 лет назад
Родитель
Сommit
40d8f6165c
13 измененных файлов с 473 добавлено и 186 удалено
  1. 32 1
      plugins/org.yakindu.sct.model.sexec.edit/src/org/yakindu/sct/model/sexec/provider/ExecutionFlowItemProvider.java
  2. 1 1
      plugins/org.yakindu.sct.model.sexec/model/sexec.ecore
  3. 1 1
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/ExecutionFlow.java
  4. 12 3
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/SexecPackage.java
  5. 103 0
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/ExecutionFlowImpl.java
  6. 1 0
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/SexecPackageImpl.java
  7. 6 0
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/FactoryExtension.xtend
  8. 6 2
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend
  9. 1 0
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/util/SexecSwitch.java
  10. 0 177
      test-plugins/org.yakindu.sct.generator.cpp.test/src/org/yakindu/sct/generator/cpp/test/generator/CPPGeneratorTest.java
  11. 12 1
      test-plugins/org.yakindu.sct.model.sexec.test/META-INF/MANIFEST.MF
  12. 201 0
      test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/ModelSequencerTest.java
  13. 97 0
      test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/SCTTestUtil.java

+ 32 - 1
plugins/org.yakindu.sct.model.sexec.edit/src/org/yakindu/sct/model/sexec/provider/ExecutionFlowItemProvider.java

@@ -17,12 +17,14 @@ import org.eclipse.emf.common.util.ResourceLocator;
 
 import org.eclipse.emf.ecore.EStructuralFeature;
 
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
 import org.eclipse.emf.edit.provider.IItemLabelProvider;
 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
 import org.eclipse.emf.edit.provider.IItemPropertySource;
 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
 import org.eclipse.emf.edit.provider.ItemProviderAdapter;
 import org.eclipse.emf.edit.provider.ViewerNotification;
 
@@ -66,10 +68,33 @@ public class ExecutionFlowItemProvider
 		if (itemPropertyDescriptors == null) {
 			super.getPropertyDescriptors(object);
 
+			addNamePropertyDescriptor(object);
 		}
 		return itemPropertyDescriptors;
 	}
 
+	/**
+	 * This adds a property descriptor for the Name feature.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected void addNamePropertyDescriptor(Object object) {
+		itemPropertyDescriptors.add
+			(createItemPropertyDescriptor
+				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+				 getResourceLocator(),
+				 getString("_UI_NamedElement_name_feature"),
+				 getString("_UI_PropertyDescriptor_description", "_UI_NamedElement_name_feature", "_UI_NamedElement_type"),
+				 SexecPackage.Literals.NAMED_ELEMENT__NAME,
+				 true,
+				 false,
+				 false,
+				 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+				 null,
+				 null));
+	}
+
 	/**
 	 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
 	 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
@@ -120,7 +145,10 @@ public class ExecutionFlowItemProvider
 	 */
 	@Override
 	public String getText(Object object) {
-		return getString("_UI_ExecutionFlow_type");
+		String label = ((ExecutionFlow)object).getName();
+		return label == null || label.length() == 0 ?
+			getString("_UI_ExecutionFlow_type") :
+			getString("_UI_ExecutionFlow_type") + " " + label;
 	}
 
 	/**
@@ -135,6 +163,9 @@ public class ExecutionFlowItemProvider
 		updateChildren(notification);
 
 		switch (notification.getFeatureID(ExecutionFlow.class)) {
+			case SexecPackage.EXECUTION_FLOW__NAME:
+				fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
+				return;
 			case SexecPackage.EXECUTION_FLOW__STATES:
 			case SexecPackage.EXECUTION_FLOW__SEQUENCES:
 				fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));

+ 1 - 1
plugins/org.yakindu.sct.model.sexec/model/sexec.ecore

@@ -3,7 +3,7 @@
     xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="sexec"
     nsURI="http://www.yakindu.org/sct/sexec/1.0.0" nsPrefix="sexec">
-  <eClassifiers xsi:type="ecore:EClass" name="ExecutionFlow" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement">
+  <eClassifiers xsi:type="ecore:EClass" name="ExecutionFlow" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement #//NamedElement">
     <eStructuralFeatures xsi:type="ecore:EReference" name="states" upperBound="-1"
         eType="#//ExecutionState" containment="true"/>
     <eStructuralFeatures xsi:type="ecore:EReference" name="sequences" upperBound="-1"

+ 1 - 1
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/ExecutionFlow.java

@@ -28,7 +28,7 @@ import org.eclipse.emf.ecore.EObject;
  * @model
  * @generated
  */
-public interface ExecutionFlow extends ScopedElement {
+public interface ExecutionFlow extends ScopedElement, NamedElement {
 	/**
 	 * Returns the value of the '<em><b>States</b></em>' containment reference list.
 	 * The list contents are of type {@link org.yakindu.sct.model.sexec.ExecutionState}.

+ 12 - 3
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/SexecPackage.java

@@ -79,6 +79,15 @@ public interface SexecPackage extends EPackage {
 	 */
 	int EXECUTION_FLOW__SCOPES = SGraphPackage.SCOPED_ELEMENT__SCOPES;
 
+	/**
+	 * The feature id for the '<em><b>Name</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int EXECUTION_FLOW__NAME = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 0;
+
 	/**
 	 * The feature id for the '<em><b>States</b></em>' containment reference list.
 	 * <!-- begin-user-doc -->
@@ -86,7 +95,7 @@ public interface SexecPackage extends EPackage {
 	 * @generated
 	 * @ordered
 	 */
-	int EXECUTION_FLOW__STATES = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 0;
+	int EXECUTION_FLOW__STATES = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 1;
 
 	/**
 	 * The feature id for the '<em><b>Sequences</b></em>' containment reference list.
@@ -95,7 +104,7 @@ public interface SexecPackage extends EPackage {
 	 * @generated
 	 * @ordered
 	 */
-	int EXECUTION_FLOW__SEQUENCES = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 1;
+	int EXECUTION_FLOW__SEQUENCES = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 2;
 
 	/**
 	 * The number of structural features of the '<em>Execution Flow</em>' class.
@@ -104,7 +113,7 @@ public interface SexecPackage extends EPackage {
 	 * @generated
 	 * @ordered
 	 */
-	int EXECUTION_FLOW_FEATURE_COUNT = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 2;
+	int EXECUTION_FLOW_FEATURE_COUNT = SGraphPackage.SCOPED_ELEMENT_FEATURE_COUNT + 3;
 
 	/**
 	 * The meta object id for the '{@link org.yakindu.sct.model.sexec.impl.NamedElementImpl <em>Named Element</em>}' class.

+ 103 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/ExecutionFlowImpl.java

@@ -8,6 +8,7 @@ package org.yakindu.sct.model.sexec.impl;
 
 import java.util.Collection;
 
+import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.common.notify.NotificationChain;
 
 import org.eclipse.emf.common.util.EList;
@@ -15,6 +16,7 @@ import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.InternalEObject;
 
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
 import org.eclipse.emf.ecore.impl.EObjectImpl;
 
 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
@@ -22,6 +24,7 @@ import org.eclipse.emf.ecore.util.InternalEList;
 
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.NamedElement;
 import org.yakindu.sct.model.sexec.Sequence;
 import org.yakindu.sct.model.sexec.SexecPackage;
 import org.yakindu.sct.model.sgraph.impl.ScopedElementImpl;
@@ -33,6 +36,7 @@ import org.yakindu.sct.model.sgraph.impl.ScopedElementImpl;
  * <p>
  * The following features are implemented:
  * <ul>
+ *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getName <em>Name</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getStates <em>States</em>}</li>
  *   <li>{@link org.yakindu.sct.model.sexec.impl.ExecutionFlowImpl#getSequences <em>Sequences</em>}</li>
  * </ul>
@@ -41,6 +45,26 @@ import org.yakindu.sct.model.sgraph.impl.ScopedElementImpl;
  * @generated
  */
 public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlow {
+	/**
+	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getName()
+	 * @generated
+	 * @ordered
+	 */
+	protected static final String NAME_EDEFAULT = null;
+
+	/**
+	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getName()
+	 * @generated
+	 * @ordered
+	 */
+	protected String name = NAME_EDEFAULT;
+
 	/**
 	 * The cached value of the '{@link #getStates() <em>States</em>}' containment reference list.
 	 * <!-- begin-user-doc -->
@@ -80,6 +104,27 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 		return SexecPackage.Literals.EXECUTION_FLOW;
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public void setName(String newName) {
+		String oldName = name;
+		name = newName;
+		if (eNotificationRequired())
+			eNotify(new ENotificationImpl(this, Notification.SET, SexecPackage.EXECUTION_FLOW__NAME, oldName, name));
+	}
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -128,6 +173,8 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 	@Override
 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
 		switch (featureID) {
+			case SexecPackage.EXECUTION_FLOW__NAME:
+				return getName();
 			case SexecPackage.EXECUTION_FLOW__STATES:
 				return getStates();
 			case SexecPackage.EXECUTION_FLOW__SEQUENCES:
@@ -145,6 +192,9 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 	@Override
 	public void eSet(int featureID, Object newValue) {
 		switch (featureID) {
+			case SexecPackage.EXECUTION_FLOW__NAME:
+				setName((String)newValue);
+				return;
 			case SexecPackage.EXECUTION_FLOW__STATES:
 				getStates().clear();
 				getStates().addAll((Collection<? extends ExecutionState>)newValue);
@@ -165,6 +215,9 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 	@Override
 	public void eUnset(int featureID) {
 		switch (featureID) {
+			case SexecPackage.EXECUTION_FLOW__NAME:
+				setName(NAME_EDEFAULT);
+				return;
 			case SexecPackage.EXECUTION_FLOW__STATES:
 				getStates().clear();
 				return;
@@ -183,6 +236,8 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 	@Override
 	public boolean eIsSet(int featureID) {
 		switch (featureID) {
+			case SexecPackage.EXECUTION_FLOW__NAME:
+				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
 			case SexecPackage.EXECUTION_FLOW__STATES:
 				return states != null && !states.isEmpty();
 			case SexecPackage.EXECUTION_FLOW__SEQUENCES:
@@ -191,4 +246,52 @@ public class ExecutionFlowImpl extends ScopedElementImpl implements ExecutionFlo
 		return super.eIsSet(featureID);
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
+		if (baseClass == NamedElement.class) {
+			switch (derivedFeatureID) {
+				case SexecPackage.EXECUTION_FLOW__NAME: return SexecPackage.NAMED_ELEMENT__NAME;
+				default: return -1;
+			}
+		}
+		return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
+		if (baseClass == NamedElement.class) {
+			switch (baseFeatureID) {
+				case SexecPackage.NAMED_ELEMENT__NAME: return SexecPackage.EXECUTION_FLOW__NAME;
+				default: return -1;
+			}
+		}
+		return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public String toString() {
+		if (eIsProxy()) return super.toString();
+
+		StringBuffer result = new StringBuffer(super.toString());
+		result.append(" (name: ");
+		result.append(name);
+		result.append(')');
+		return result.toString();
+	}
+
 } //ExecutionFlowImpl

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/impl/SexecPackageImpl.java

@@ -496,6 +496,7 @@ public class SexecPackageImpl extends EPackageImpl implements SexecPackage {
 
 		// Add supertypes to classes
 		executionFlowEClass.getESuperTypes().add(theSGraphPackage.getScopedElement());
+		executionFlowEClass.getESuperTypes().add(this.getNamedElement());
 		executionStateEClass.getESuperTypes().add(this.getNamedElement());
 		cycleEClass.getESuperTypes().add(this.getSequence());
 		sequenceEClass.getESuperTypes().add(this.getStep());

+ 6 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/FactoryExtension.xtend

@@ -21,6 +21,8 @@ import org.yakindu.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.model.stext.stext.InternalScope
 import org.yakindu.sct.model.stext.stext.EventDefinition
 import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sgraph.Statechart
 
 class FactoryExtension {
 	
@@ -28,6 +30,10 @@ class FactoryExtension {
 	@Inject extension IQualifiedNameProvider qfnProvider
 
 
+	def ExecutionFlow create r : sexecFactory.createExecutionFlow create(Statechart statechart){
+		r.name = statechart.name
+	}
+
 	def dispatch Scope create r : stextFactory.createInterfaceScope  create(InterfaceScope scope) {
 		r.name = scope.name
 	}

+ 6 - 2
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/ModelSequencer.xtend

@@ -37,7 +37,9 @@ class ModelSequencer {
 
 
 	def ExecutionFlow transform(Statechart sc) {
-		val ef = createExecutionFlow(sc)
+		val ef = sc.create
+		
+		sc.mapExecutionFlow(ef)
 		sc.mapScopes(ef)
 		
 		ef
@@ -81,11 +83,13 @@ class ModelSequencer {
 	
 	
 	
-	def ExecutionFlow create r : sexecFactory.createExecutionFlow createExecutionFlow(Statechart statechart){
+	def ExecutionFlow mapExecutionFlow(Statechart statechart, ExecutionFlow r){
 		var content = EcoreUtil2::eAllContentsAsList(statechart)
 		val leafStates = content.filter(e | e instanceof State && (e as State).simple)
 		r.states.addAll(leafStates.map( s | (s as State).transform));
+		return r
 	}
+
 	
 	
 	def ExecutionState transform(State state) {

+ 1 - 0
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/util/SexecSwitch.java

@@ -75,6 +75,7 @@ public class SexecSwitch<T> extends Switch<T> {
 				ExecutionFlow executionFlow = (ExecutionFlow)theEObject;
 				T result = caseExecutionFlow(executionFlow);
 				if (result == null) result = caseScopedElement(executionFlow);
+				if (result == null) result = caseNamedElement(executionFlow);
 				if (result == null) result = defaultCase(theEObject);
 				return result;
 			}

+ 0 - 177
test-plugins/org.yakindu.sct.generator.cpp.test/src/org/yakindu/sct/generator/cpp/test/generator/CPPGeneratorTest.java

@@ -79,182 +79,5 @@ public class CPPGeneratorTest extends AbstractGeneratorTest {
 	}
 
 	
-	
-	/**
-	 * The event refs used in the trigger condition must refer to the event declarations in the flow model and not the sc source model.
-	 */
-	@Test public void testTriggerEventDeclarationIntegrity() {
-
-		Statechart sc = _createStatechart("test");
-		InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
-		EventDefinition e1 = _createEventDefinition("e1", s_scope);
-		Region r = _createRegion("main", sc);
-		State s1 = _createState("S1", r);
-		State s2 = _createState("S2", r);
-		Transition t = _createTransition(s1, s2);
-		ReactionTrigger tr1 = _createReactionTrigger(t);
-		_createRegularEventSpec(e1, tr1);
-
-		ExecutionFlow flow = sequencer.transform(sc);
-
-		EventDefinition _e1 = (EventDefinition) flow.getScopes().get(0).getDeclarations().get(0); 
-		assertNotSame(e1, _e1);
-		assertEquals(e1.getName(), _e1.getName());
-		
-		assertEquals(2, flow.getStates().size());
-		assertEquals(s1.getName(), flow.getStates().get(0).getSimpleName());
-		If _if = (If) flow.getStates().get(0).getCycle().getSteps().get(0);
-
-		ElementReferenceExpression _ere = (ElementReferenceExpression) _if.getCondition();
-		assertSame(_e1, _ere.getValue());
-	}
-
-
-	private ReactionTrigger _createReactionTrigger(Reaction reaction) {
-		ReactionTrigger rt = StextFactory.eINSTANCE.createReactionTrigger();
-		if (reaction != null) reaction.setTrigger(rt);
-		return rt;
-	}
-
-
-	protected Statechart _createStatechart(String name) {
-		Statechart sc = SGraphFactory.eINSTANCE.createStatechart();
-		sc.setName(name);
-		return sc;
-	}
-	
-
-	protected InterfaceScope _createInterfaceScope(String name, ScopedElement owner) {
-		InterfaceScope scope = StextFactory.eINSTANCE.createInterfaceScope();
-		scope.setName(name);
-		if (owner != null) owner.getScopes().add(scope);
-		return scope;
-	}
-	
-
-	protected Region _createRegion(String name, Statechart sc) {
-		Region region = SGraphFactory.eINSTANCE.createRegion();
-		region.setName(name);
-		if (sc != null ) sc.getRegions().add(region);
-		return region;
-	}
-	
-	protected State _createState(String name, Region r) {
-		State state = SGraphFactory.eINSTANCE.createState();
-		state.setName(name);
-		if (r!=null) r.getVertices().add(state);
-		return state;
-	}
-	
-	protected Transition _createTransition(Vertex source, Vertex target) {
-		Transition t = SGraphFactory.eINSTANCE.createTransition();
-		t.setSource(source);
-		t.setTarget(target);
-		return t;
-	}
-	
-	
-	@Test
-	public void testSingleRegularEventTriggerCondition() {
-
-		EventDefinition e1 = _createEventDefinition("e1", null);
-		ReactionTrigger tr1 = _createReactionTrigger(null);
-		_createRegularEventSpec(e1, tr1);
-
-		Statement s = sequencer.buildCondition(tr1);
-
-		assertTrue(s instanceof ElementReferenceExpression);
-	}
-
-	@Test
-	public void testMultipleRegularEventTriggerCondition() {
-
-		EventDefinition e1 = _createEventDefinition("e1", null);
-		EventDefinition e2 = _createEventDefinition("e2", null);
-
-		ReactionTrigger tr1 = _createReactionTrigger(null);
-		_createRegularEventSpec(e1, tr1);
-		_createRegularEventSpec(e2, tr1);
-
-		Statement s = sequencer.buildCondition(tr1);
-
-		assertTrue(s instanceof LogicalOrExpression);
-		assertTrue(((LogicalOrExpression) s).getLeftOperand() instanceof ElementReferenceExpression);
-		assertTrue(((LogicalOrExpression) s).getRightOperand() instanceof ElementReferenceExpression);
-	}
-
-	
-	@Test
-	public void testTransitionSequence() {
-
-		EventDefinition e1 = _createEventDefinition("e1", null);
-		EventDefinition e2 = _createEventDefinition("e2", null);
-
-		ReactionTrigger tr1 = _createReactionTrigger(null);
-		_createRegularEventSpec(e1, tr1);
-		_createRegularEventSpec(e2, tr1);
-
-		Transition t = SGraphFactory.eINSTANCE.createTransition();
-		t.setTrigger(tr1);
-
-		If s = sequencer.buildTransitionSequence(t);
-
-		assertTrue(s.getCondition() instanceof LogicalOrExpression);
-		assertTrue(((LogicalOrExpression) s.getCondition()).getLeftOperand() instanceof ElementReferenceExpression);
-		assertTrue(((LogicalOrExpression) s.getCondition()).getRightOperand() instanceof ElementReferenceExpression);
-
-		assertEquals(e1.getName(),
-				((ElementReferenceExpression)((LogicalOrExpression) s.getCondition()).getLeftOperand()).getValue().getName());
-		assertEquals(e2.getName(),
-				((ElementReferenceExpression)((LogicalOrExpression) s.getCondition()).getRightOperand()).getValue().getName());
-	}
-
-	
-	@Test
-	public void testCopyScope() {
-
-		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());	
-		}
-	}
-	
-	
-	protected EventDefinition _createEventDefinition(String name, Scope scope) {
-		EventDefinition e = StextFactory.eINSTANCE.createEventDefinition();
-		e.setName(name);
-		if (scope!=null) scope.getDeclarations().add(e);
-		return e;
-	}
-
-	protected VariableDefinition _createVariableDefinition(String name, Type type, Scope scope) {
-		VariableDefinition v = StextFactory.eINSTANCE.createVariableDefinition();
-		v.setName(name);
-		v.setType(type);
-		if (scope!=null) scope.getDeclarations().add(v);
-		return v;
-	}
-
-	protected RegularEventSpec _createRegularEventSpec(EventDefinition e1, ReactionTrigger rt) {
-		RegularEventSpec e1Spec = StextFactory.eINSTANCE.createRegularEventSpec();
-		e1Spec.setEvent(e1);
-		if (rt!=null) rt.getTriggers().add(e1Spec);
-		return e1Spec;
-	}
 
 }

+ 12 - 1
test-plugins/org.yakindu.sct.model.sexec.test/META-INF/MANIFEST.MF

@@ -5,4 +5,15 @@ Bundle-SymbolicName: org.yakindu.sct.model.sexec.test
 Bundle-Version: 1.0.0.qualifier
 Bundle-Vendor: YAKINDU
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.yakindu.sct.model.sexec;bundle-version="1.0.0"
+Require-Bundle: org.eclipse.core.runtime,
+ org.junit4;bundle-version="4.8.1",
+ org.apache.log4j;bundle-version="1.2.15",
+ org.eclipse.xtend;bundle-version="1.1.0",
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.eclipse.xpand;bundle-version="1.1.0",
+ org.yakindu.sct.model.sgraph;bundle-version="1.0.0",
+ org.eclipse.xtend.typesystem.emf;bundle-version="1.0.1",
+ org.yakindu.sct.model.stext;bundle-version="1.0.0",
+ org.yakindu.sct.model.sexec;bundle-version="1.0.0",
+ org.yakindu.sct.generator.cpp;bundle-version="1.0.0",
+ org.yakindu.sct.generator.base;bundle-version="1.0.0"

+ 201 - 0
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/ModelSequencerTest.java

@@ -0,0 +1,201 @@
+package org.yakindu.sct.model.sexec.transformation.test;
+
+import static org.junit.Assert.*;
+import static org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.*;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.If;
+import org.yakindu.sct.model.sexec.transformation.ModelSequencer;
+import org.yakindu.sct.model.sexec.transformation.SequencerModule;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.Type;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * 
+ * @author axel terfloth
+ * 
+ */
+public class ModelSequencerTest {
+
+	@Inject
+	private ModelSequencer sequencer;
+
+	@Before
+	public void setup() {
+		Injector injector = Guice.createInjector(new SequencerModule());
+		injector.injectMembers(this);
+	}
+
+	
+	
+	/**
+	 * The name of the execution flow must be equal to the statechart name.
+	 */
+	@Test public void testFlowName() {
+		Statechart sc = _createStatechart("Test");
+		assertEquals(sc.getName(), sequencer.transform(sc).getName());
+	}
+	
+	/**
+	 * The event refs used in the trigger condition must refer to the event declarations in the flow model 
+	 * and not the sc source model.
+	 */
+	@Test public void testTriggerEventDeclarationIntegrity() {
+
+		Statechart sc = _createStatechart("test");
+		InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
+		EventDefinition e1 = _createEventDefinition("e1", s_scope);
+		Region r = _createRegion("main", sc);
+		State s1 = _createState("S1", r);
+		State s2 = _createState("S2", r);
+		Transition t = _createTransition(s1, s2);
+		ReactionTrigger tr1 = _createReactionTrigger(t);
+		_createRegularEventSpec(e1, tr1);
+
+		ExecutionFlow flow = sequencer.transform(sc);
+
+		EventDefinition _e1 = (EventDefinition) flow.getScopes().get(0).getDeclarations().get(0); 
+		assertNotSame(e1, _e1);
+		assertEquals(e1.getName(), _e1.getName());
+		
+		assertEquals(2, flow.getStates().size());
+		assertEquals(s1.getName(), flow.getStates().get(0).getSimpleName());
+		If _if = (If) flow.getStates().get(0).getCycle().getSteps().get(0);
+
+		ElementReferenceExpression _ere = (ElementReferenceExpression) _if.getCondition();
+		assertSame(_e1, _ere.getValue());
+	}
+
+
+	/**
+	 * Single trigger events of a Reaction Trigger will be converted into a single condition 
+	 * that consists of a ElementReferenceExpression to the corresponding event definition.
+	 */
+	@Test public void testSingleRegularEventTriggerCondition() {
+
+		EventDefinition e1 = _createEventDefinition("e1", null);
+		ReactionTrigger tr1 = _createReactionTrigger(null);
+		_createRegularEventSpec(e1, tr1);
+
+		Statement s = sequencer.buildCondition(tr1);
+
+		assertTrue(s instanceof ElementReferenceExpression);
+	}
+
+
+	/**
+	 * Multiple trigger events of a ReactionTrigger will be converted to a condition 
+	 * that consists of a ElementReferenceExpressions connected by LogicalOrExpressions.
+	 * 
+	 * e1, e1 -> e1 || e2
+	 * 
+	 */
+	@Test public void testMultipleRegularEventTriggerCondition() {
+
+		EventDefinition e1 = _createEventDefinition("e1", null);
+		EventDefinition e2 = _createEventDefinition("e2", null);
+
+		ReactionTrigger tr1 = _createReactionTrigger(null);
+		_createRegularEventSpec(e1, tr1);
+		_createRegularEventSpec(e2, tr1);
+
+		Statement s = sequencer.buildCondition(tr1);
+
+		assertTrue(s instanceof LogicalOrExpression);
+		assertTrue(((LogicalOrExpression) s).getLeftOperand() instanceof ElementReferenceExpression);
+		assertTrue(((LogicalOrExpression) s).getRightOperand() instanceof ElementReferenceExpression);
+	}
+
+	
+	@Test
+	public void testTransitionSequence() {
+
+		EventDefinition e1 = _createEventDefinition("e1", null);
+		EventDefinition e2 = _createEventDefinition("e2", null);
+
+		ReactionTrigger tr1 = _createReactionTrigger(null);
+		_createRegularEventSpec(e1, tr1);
+		_createRegularEventSpec(e2, tr1);
+
+		Transition t = SGraphFactory.eINSTANCE.createTransition();
+		t.setTrigger(tr1);
+
+		If s = sequencer.buildTransitionSequence(t);
+
+		assertTrue(s.getCondition() instanceof LogicalOrExpression);
+		assertTrue(((LogicalOrExpression) s.getCondition()).getLeftOperand() instanceof ElementReferenceExpression);
+		assertTrue(((LogicalOrExpression) s.getCondition()).getRightOperand() instanceof ElementReferenceExpression);
+
+		assertEquals(e1.getName(),
+				((ElementReferenceExpression)((LogicalOrExpression) s.getCondition()).getLeftOperand()).getValue().getName());
+		assertEquals(e2.getName(),
+				((ElementReferenceExpression)((LogicalOrExpression) s.getCondition()).getRightOperand()).getValue().getName());
+	}
+
+	
+	/** 
+	 * 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());	
+		}
+	}
+	
+	
+}

+ 97 - 0
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/SCTTestUtil.java

@@ -0,0 +1,97 @@
+package org.yakindu.sct.model.sexec.transformation.test;
+
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.ScopedElement;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.RegularEventSpec;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.Type;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+public class SCTTestUtil {
+
+	public static EventDefinition _createEventDefinition(String name, Scope scope) {
+		EventDefinition e = StextFactory.eINSTANCE.createEventDefinition();
+		e.setName(name);
+		if (scope!=null) scope.getDeclarations().add(e);
+		return e;
+	}
+
+	public static VariableDefinition _createVariableDefinition(String name, Type type, Scope scope) {
+		VariableDefinition v = StextFactory.eINSTANCE.createVariableDefinition();
+		v.setName(name);
+		v.setType(type);
+		if (scope!=null) scope.getDeclarations().add(v);
+		return v;
+	}
+
+	public static RegularEventSpec _createRegularEventSpec(EventDefinition e1, ReactionTrigger rt) {
+		RegularEventSpec e1Spec = StextFactory.eINSTANCE.createRegularEventSpec();
+		e1Spec.setEvent(e1);
+		if (rt!=null) rt.getTriggers().add(e1Spec);
+		return e1Spec;
+	}
+
+	public static ReactionTrigger _createReactionTrigger(Reaction reaction) {
+		ReactionTrigger rt = StextFactory.eINSTANCE.createReactionTrigger();
+		if (reaction != null) reaction.setTrigger(rt);
+		return rt;
+	}
+
+
+	public static Statechart _createStatechart(String name) {
+		Statechart sc = SGraphFactory.eINSTANCE.createStatechart();
+		sc.setName(name);
+		return sc;
+	}
+	
+
+	public static InterfaceScope _createInterfaceScope(String name, ScopedElement owner) {
+		InterfaceScope scope = StextFactory.eINSTANCE.createInterfaceScope();
+		scope.setName(name);
+		if (owner != null) owner.getScopes().add(scope);
+		return scope;
+	}
+	
+
+	public static InternalScope _createInternalScope(ScopedElement owner) {
+		InternalScope scope = StextFactory.eINSTANCE.createInternalScope();
+		if (owner != null) owner.getScopes().add(scope);
+		return scope;
+	}
+	
+
+	public static Region _createRegion(String name, Statechart sc) {
+		Region region = SGraphFactory.eINSTANCE.createRegion();
+		region.setName(name);
+		if (sc != null ) sc.getRegions().add(region);
+		return region;
+	}
+	
+	public static State _createState(String name, Region r) {
+		State state = SGraphFactory.eINSTANCE.createState();
+		state.setName(name);
+		if (r!=null) r.getVertices().add(state);
+		return state;
+	}
+	
+	public static Transition _createTransition(Vertex source, Vertex target) {
+		Transition t = SGraphFactory.eINSTANCE.createTransition();
+		t.setSource(source);
+		t.setTarget(target);
+		return t;
+	}
+	
+	
+
+}