aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorghillairet2012-05-14 11:54:51 (EDT)
committermgolubev2012-05-14 11:54:51 (EDT)
commita57ff4189d05eed4dbcec059a5ce790f3bab67df (patch)
tree5226bd49fb82a43f58b2206ae3d98fcf87410fc1
parent63d5f3f6821284830b3149963f643233a8c8c178 (diff)
downloadorg.eclipse.gmf-tooling-a57ff4189d05eed4dbcec059a5ce790f3bab67df.zip
org.eclipse.gmf-tooling-a57ff4189d05eed4dbcec059a5ce790f3bab67df.tar.gz
org.eclipse.gmf-tooling-a57ff4189d05eed4dbcec059a5ce790f3bab67df.tar.bz2
Refactoring of tests for comparison of java and qvto bridge
-rw-r--r--tests/org.eclipse.gmf.tests/models/tests/test.gmfmap123
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java25
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerSimpleTest.java2
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java5
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/SimpleCompareTransformationEngineTest.java814
-rw-r--r--tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformationTestSupport.java136
6 files changed, 1092 insertions, 13 deletions
diff --git a/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap b/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap
index d7dbaff..2432a28 100644
--- a/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap
+++ b/tests/org.eclipse.gmf.tests/models/tests/test.gmfmap
@@ -11,6 +11,8 @@
<ownedChild>
<domainMetaElement
href="test.ecore#//NodeSrcA"/>
+ <domainSpecialization
+ body="true"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
@@ -18,6 +20,13 @@
<features
href="test.ecore#//NodeSrcA/label"/>
</labelMappings>
+ <labelMappings
+ xsi:type="gmfmap:ExpressionLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <viewExpression
+ body="true"/>
+ </labelMappings>
<contextMenu
href="test.gmftool#//@allMenus.1"/>
<tool
@@ -313,6 +322,47 @@
xsi:type="ecore:EReference"
href="test.ecore#//LinkAtoC/refLinkCrossLink"/>
</links>
+ <links>
+ <domainMetaElement
+ href="test.ecore#//NodeSrcA"/>
+ <domainSpecialization
+ body="true"/>
+ <domainInitializer
+ xsi:type="gmfmap:FeatureSeqInitializer">
+ <initializers
+ xsi:type="gmfmap:FeatureValueSpec">
+ <feature
+ xsi:type="ecore:EAttribute"
+ href="test.ecore#//NodeSrcA/label"/>
+ <value
+ body="'hello'"/>
+ </initializers>
+ </domainInitializer>
+ <labelMappings>
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ </labelMappings>
+ <labelMappings
+ xsi:type="gmfmap:ExpressionLabelMapping">
+ <diagramLabel
+ href="test.gmfgraph#TestLabel"/>
+ <viewExpression
+ body="'hello'"/>
+ </labelMappings>
+ <containmentFeature
+ href="test.ecore#//UltimateContainer/all"/>
+ <diagramLink
+ href="test.gmfgraph#Test-dd-link"/>
+ <linkMetaFeature
+ xsi:type="ecore:EReference"
+ href="test.ecore#//NodeSrcA/children1OfA"/>
+ <creationConstraints>
+ <sourceEnd
+ body="true"/>
+ <targetEnd
+ body="true"/>
+ </creationConstraints>
+ </links>
<diagram>
<diagramCanvas
href="test.gmfgraph#Test-dd-canvas"/>
@@ -325,4 +375,75 @@
<menuContributions
href="test.gmftool#//@allMenus.0"/>
</diagram>
-</gmfmap:Mapping> \ No newline at end of file
+ <audits
+ id="test"
+ name="test"
+ description="All Audits">
+ <audits
+ name="Node Label"
+ description="Empty node label check"
+ id="node_label"
+ severity="WARNING"
+ message="Node label should not be empty">
+ <rule
+ body="label.size() > 0"/>
+ <target
+ xsi:type="gmfmap:DomainElementTarget">
+ <element
+ href="test.ecore#//NodeSrcA"/>
+ </target>
+ </audits>
+ <audits
+ name="Node Label 2"
+ description="Node Label should be set"
+ id="node_label_2"
+ severity="WARNING"
+ message="Node Label should be set">
+ <rule
+ body="size() > 0"/>
+ <target
+ xsi:type="gmfmap:DomainAttributeTarget">
+ <attribute
+ href="test.ecore#//NodeSrcA/label"/>
+ </target>
+ </audits>
+ <audits
+ name="Node Type"
+ description="Node type check"
+ id="node_type"
+ message="Invalid Node Type">
+ <rule
+ body="element.eClass().name = 'NodeSrcA'"/>
+ <target
+ xsi:type="gmfmap:DiagramElementTarget"
+ element="//@nodes.0/@ownedChild"/>
+ </audits>
+ <audits
+ name="Node Audit Metric"
+ description="Some Audit Metric"
+ id="NodeAuditMetric"
+ message="Some Stuff">
+ <rule
+ body="true"/>
+ <target
+ xsi:type="gmfmap:AuditedMetricTarget"
+ metric="//@metrics/@metrics.0"/>
+ </audits>
+ </audits>
+ <metrics>
+ <metrics
+ name="Node Metric"
+ description="Some Metric"
+ key="NodeMetric"
+ lowLimit="5.0"
+ highLimit="10.0">
+ <rule
+ body="label->size()"/>
+ <target
+ xsi:type="gmfmap:DomainElementTarget">
+ <element
+ href="test.ecore#//NodeSrcA"/>
+ </target>
+ </metrics>
+ </metrics>
+</gmfmap:Mapping>
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
index 7feae22..ddf1f61 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
@@ -89,6 +89,7 @@ import org.eclipse.gmf.tests.tr.QvtTransformComparisonFullTest;
import org.eclipse.gmf.tests.tr.QvtTransformComparisonLinksTest;
import org.eclipse.gmf.tests.tr.QvtTransformComparisonNodeLabelsTest;
import org.eclipse.gmf.tests.tr.QvtTransformModeledViewmapTest;
+import org.eclipse.gmf.tests.tr.SimpleCompareTransformationEngineTest;
import org.eclipse.gmf.tests.tr.TestDefaultMergeService;
import org.eclipse.gmf.tests.tr.TransformToGenModelOperationTest;
import org.eclipse.gmf.tests.tr.XmlTextMergerTest;
@@ -205,13 +206,14 @@ public class AllTests {
suite.addTestSuite(QvtGenModelTransformerBasicRTTest.class);
suite.addTestSuite(QvtLabelMappingTransformTest.class);
suite.addTestSuite(QvtPaletteTransformationTest.class);
- suite.addTestSuite(QvtTransformComparisonNodeLabelsTest.class);
- suite.addTestSuite(QvtTransformComparisonLinksTest.class);
- suite.addTestSuite(QvtTransformComparisonAudtisTest.class);
- suite.addTestSuite(QvtTransformComparisonCompartmentRefNodeTest.class);
- suite.addTestSuite(QvtTransformComparisonFullTest.class);
+ suite.addTestSuite(SimpleCompareTransformationEngineTest.class);
+// suite.addTestSuite(QvtTransformComparisonNodeLabelsTest.class);
+// suite.addTestSuite(QvtTransformComparisonLinksTest.class);
+// suite.addTestSuite(QvtTransformComparisonAudtisTest.class);
+// suite.addTestSuite(QvtTransformComparisonCompartmentRefNodeTest.class);
+// suite.addTestSuite(QvtTransformComparisonFullTest.class);
suite.addTestSuite(QvtTransformModeledViewmapTest.class);
- suite.addTestSuite(QvtGenModelTransformerVisualIDWithTraceTest.class);
+// suite.addTestSuite(QvtGenModelTransformerVisualIDWithTraceTest.class);
suite.addTestSuite(EcoreGenModelMatcherTest.class);
suite.addTestSuite(ModelLoadHelperTest.class);
@@ -303,11 +305,12 @@ public class AllTests {
c.register(QvtGenModelTransformerBasicRTTest.class, SessionSetup.class);
c.register(QvtLabelMappingTransformTest.class, SessionSetup.class);
c.register(QvtPaletteTransformationTest.class, SessionSetup.class);
- c.register(QvtTransformComparisonNodeLabelsTest.class, SessionSetup.class);
- c.register(QvtTransformComparisonLinksTest.class, SessionSetup.class);
- c.register(QvtTransformComparisonAudtisTest.class, SessionSetup.class);
- c.register(QvtTransformComparisonCompartmentRefNodeTest.class, SessionSetup.class);
- c.register(QvtTransformComparisonFullTest.class, SessionSetup.class);
+ c.register(SimpleCompareTransformationEngineTest.class, SessionSetup.class);
+// c.register(QvtTransformComparisonNodeLabelsTest.class, SessionSetup.class);
+// c.register(QvtTransformComparisonLinksTest.class, SessionSetup.class);
+// c.register(QvtTransformComparisonAudtisTest.class, SessionSetup.class);
+// c.register(QvtTransformComparisonCompartmentRefNodeTest.class, SessionSetup.class);
+// c.register(QvtTransformComparisonFullTest.class, SessionSetup.class);
c.register(QvtTransformModeledViewmapTest.class, SessionSetup.class);
c.register(QvtGenModelTransformerVisualIDWithTraceTest.class, SessionSetup.class);
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerSimpleTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerSimpleTest.java
index 9e428aa..d93595a 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerSimpleTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtGenModelTransformerSimpleTest.java
@@ -84,6 +84,8 @@ public class QvtGenModelTransformerSimpleTest extends AbstractMappingTransformer
assertTrue(outObjects.get(0) instanceof GenEditorGenerator);
return (GenEditorGenerator) outObjects.get(0);
+ } else {
+ System.err.println(result.getMessage());
}
return null;
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java
index 9c136d1..b9b8ab7 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/QvtTransformCompareTestSupport.java
@@ -398,8 +398,11 @@ public abstract class QvtTransformCompareTestSupport extends ConfiguredTestCase
List<?> act = (List<?>) actual.eGet(attr);
assertEquals(exp.size(), act.size());
+ System.out.println(exp);
+ System.out.println(act);
for (int i=0; i<exp.size(); i++) {
- assertTrue(act.contains(exp.get(i)));
+ assertEquals(exp.get(i), act.get(i));
+// assertTrue(act.contains(exp.get(i)));
}
} else {
assertEquals(expected.eClass().getName()+" attribute: "+attr.getName(), expected.eGet(attr), actual.eGet(attr));
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/SimpleCompareTransformationEngineTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/SimpleCompareTransformationEngineTest.java
new file mode 100644
index 0000000..e12102d
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/SimpleCompareTransformationEngineTest.java
@@ -0,0 +1,814 @@
+package org.eclipse.gmf.tests.tr;
+
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.codegen.gmfgen.AbstractToolEntry;
+import org.eclipse.gmf.codegen.gmfgen.Attributes;
+import org.eclipse.gmf.codegen.gmfgen.Behaviour;
+import org.eclipse.gmf.codegen.gmfgen.ColorAttributes;
+import org.eclipse.gmf.codegen.gmfgen.DefaultSizeAttributes;
+import org.eclipse.gmf.codegen.gmfgen.ElementType;
+import org.eclipse.gmf.codegen.gmfgen.FigureViewmap;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditable;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
+import org.eclipse.gmf.codegen.gmfgen.GenContextMenu;
+import org.eclipse.gmf.codegen.gmfgen.GenContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenCustomPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenDomainAttributeTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenDomainElementTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorView;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNotationElementTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenPlugin;
+import org.eclipse.gmf.codegen.gmfgen.GenPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenStandardPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.InnerClassViewmap;
+import org.eclipse.gmf.codegen.gmfgen.LabelOffsetAttributes;
+import org.eclipse.gmf.codegen.gmfgen.ModeledViewmap;
+import org.eclipse.gmf.codegen.gmfgen.OpenDiagramBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.Palette;
+import org.eclipse.gmf.codegen.gmfgen.ParentAssignedViewmap;
+import org.eclipse.gmf.codegen.gmfgen.ResizeConstraints;
+import org.eclipse.gmf.codegen.gmfgen.SharedBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.SnippetViewmap;
+import org.eclipse.gmf.codegen.gmfgen.StandardEntry;
+import org.eclipse.gmf.codegen.gmfgen.StyleAttributes;
+import org.eclipse.gmf.codegen.gmfgen.ToolEntry;
+import org.eclipse.gmf.codegen.gmfgen.ToolGroup;
+import org.eclipse.gmf.codegen.gmfgen.ToolGroupItem;
+import org.eclipse.gmf.codegen.gmfgen.Viewmap;
+import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.gmf.tests.ConfiguredTestCase;
+import org.eclipse.gmf.tests.tr.TransformationTestSupport.Transformation;
+
+/**
+ * Compare results form Java & QVTO transformations.
+ *
+ * @author ghillairet
+ *
+ */
+public class SimpleCompareTransformationEngineTest extends ConfiguredTestCase {
+ protected static String testFolder = "platform:/plugin/org.eclipse.gmf.tests/models/tests/"; //$NON-NLS-1$
+
+ public SimpleCompareTransformationEngineTest(String name) {
+ super(name);
+ }
+
+ protected GenModel genModel;
+ protected Mapping mapping;
+ protected GenEditorGenerator expectedGenerator;
+ protected GenEditorGenerator actualGenerator;
+
+ private IProject myProject;
+ private URI traceURI;
+
+ // map -> test.gmfmap
+ // ecore -> test.ecore
+ // genmodel -> test.genmodel
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ myProject = createProject();
+ traceURI = URI.createURI(myProject.getFile("test.trace").getFullPath().toString());
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource mapRes = resourceSet.createResource(URI.createURI(testFolder+"test.gmfmap"));
+ mapRes.load(null);
+ Resource genRes = resourceSet.createResource(URI.createURI(testFolder+"test.genmodel"));
+ genRes.load(null);
+
+ mapping = (Mapping) mapRes.getContents().get(0);
+ genModel = (GenModel) genRes.getContents().get(0);
+
+ Transformation java = TransformationTestSupport.getJavaTransformation(genModel, mapping, false);
+ Transformation qvt = TransformationTestSupport.getQvtTransformation(genModel, mapping, false);
+
+ expectedGenerator = java.execute(traceURI.trimFileExtension().appendFileExtension("java.gmfgen"));
+ actualGenerator = qvt.execute(traceURI.trimFileExtension().appendFileExtension("qvt.gmfgen"));
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ deleteProject();
+ myProject = null;
+ super.tearDown();
+ }
+
+ public void testGenEditorGenerator() {
+ assertNotNull(expectedGenerator);
+ assertNotNull(actualGenerator);
+ assertNotSame(expectedGenerator, actualGenerator);
+ assertNotNull(expectedGenerator.eResource());
+ assertNotNull(actualGenerator.eResource());
+
+ assertNotSame(expectedGenerator.eResource(), actualGenerator.eResource());
+ assertSame(expectedGenerator.eResource().getResourceSet(), actualGenerator.eResource().getResourceSet());
+
+ assertEquals(expectedGenerator.getCopyrightText(), actualGenerator.getCopyrightText());
+ assertEquals(expectedGenerator.getDiagramFileExtension(), actualGenerator.getDiagramFileExtension());
+ assertEquals(expectedGenerator.getDomainFileExtension(), actualGenerator.getDomainFileExtension());
+ assertEquals(expectedGenerator.getModelID(), actualGenerator.getModelID());
+ assertEquals(expectedGenerator.getPackageNamePrefix(), actualGenerator.getPackageNamePrefix());
+ assertEquals(expectedGenerator.getPluginDirectory(), actualGenerator.getPluginDirectory());
+ assertEquals(expectedGenerator.getTemplateDirectory(), actualGenerator.getTemplateDirectory());
+ }
+
+ public void testGenEditorView() {
+ GenEditorView expected = expectedGenerator.getEditor();
+ GenEditorView actual = actualGenerator.getEditor();
+
+ assertEquals(expected.getActionBarContributorClassName(), actual.getActionBarContributorClassName());
+ assertEquals(expected.getClassName(), actual.getClassName());
+ assertEquals(expected.getContextID(), actual.getContextID());
+ assertEquals(expected.isEclipseEditor(), actual.isEclipseEditor());
+ assertEquals(expected.getIconPath(), actual.getIconPath());
+ assertEquals(expected.getIconPathX(), actual.getIconPathX());
+ assertEquals(expected.getID(), actual.getID());
+ assertEquals(expected.getPackageName(), actual.getPackageName());
+
+ assertEquals(expected.getActionBarContributorQualifiedClassName(), actual.getActionBarContributorQualifiedClassName());
+ assertEquals(expected.getQualifiedClassName(), actual.getQualifiedClassName());
+ }
+
+ public void testGenPlugin() {
+ GenPlugin expected = expectedGenerator.getPlugin();
+ GenPlugin actual = actualGenerator.getPlugin();
+
+ assertNotNull(expected);
+ assertNotNull(actual);
+
+ assertEquals(expected.getActivatorClassName(), actual.getActivatorClassName());
+ assertEquals(expected.getID(), actual.getID());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.isPrintingEnabled(), actual.isPrintingEnabled());
+ assertEquals(expected.getProvider(), actual.getProvider());
+ assertEquals(expected.getVersion(), actual.getVersion());
+
+ assertEquals(expected.getRequiredPlugins().size(), actual.getRequiredPlugins().size());
+ for (int i=0; i<expected.getRequiredPlugins().size(); i++) {
+ String exp = expected.getRequiredPlugins().get(i);
+ String act = actual.getRequiredPlugins().get(i);
+
+ assertEquals(exp, act);
+ }
+ }
+
+ public void testContextMenus() {
+ EList<GenContextMenu> expected = expectedGenerator.getContextMenus();
+ EList<GenContextMenu> actual = actualGenerator.getContextMenus();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0; i<expected.size(); i++) {
+ GenContextMenu exp = expected.get(i);
+ GenContextMenu act = actual.get(i);
+
+ assertEquals(exp.getID(), act.getID());
+ assertEquals(exp.getItems().size(), act.getItems().size());
+ }
+ }
+
+ protected void testGenContributionItem(GenContributionItem expected, GenContributionItem actual) {
+ // TODO
+ }
+
+ public void testNumberOfElementsInGenDiagram() {
+ GenDiagram expected = expectedGenerator.getDiagram();
+ GenDiagram actual = actualGenerator.getDiagram();
+
+ assertEquals(expected.getTopLevelNodes().size(), actual.getTopLevelNodes().size());
+ assertEquals(expected.getChildNodes().size(), actual.getChildNodes().size());
+ assertEquals(expected.getCompartments().size(), actual.getCompartments().size());
+ assertEquals(expected.getLinks().size(), actual.getLinks().size());
+ }
+
+ public void testGenDiagram() {
+ GenDiagram expected = expectedGenerator.getDiagram();
+ GenDiagram actual = actualGenerator.getDiagram();
+
+ assertNotNull(expected);
+ assertNotNull(actual);
+
+ for (EAttribute attribute: GMFGenPackage.eINSTANCE.getGenDiagram().getEAllAttributes()) {
+ if (expected.eIsSet(attribute)) {
+ assertTrue(attribute+" should be set", actual.eIsSet(attribute));
+
+ if (!attribute.isMany()) {
+ assertEquals(expected.eGet(attribute), actual.eGet(attribute));
+ }
+ } else {
+ assertFalse(attribute+" should not be set", actual.eIsSet(attribute));
+ }
+ }
+ }
+
+ public void testGenTopLevelNodeVisualID() {
+ // GenTopLevelNode
+ EList<GenTopLevelNode> expected = expectedGenerator.getDiagram().getTopLevelNodes();
+ EList<GenTopLevelNode> actual = actualGenerator.getDiagram().getTopLevelNodes();
+
+ assertEquals("Number of GenTopLevelNode should be the same", expected.size(), actual.size());
+ for (int i=0; i<expected.size(); i++) {
+ GenTopLevelNode exp = expected.get(i);
+ GenTopLevelNode act = actual.get(i);
+
+ assertEquals("Node visualID should be the same", exp.getVisualID(), act.getVisualID());
+
+ EList<GenNodeLabel> expLabels = exp.getLabels();
+ EList<GenNodeLabel> actLabels = act.getLabels();
+
+ assertEquals("Number of GenNodeLabel should be the same", expLabels.size(), actLabels.size());
+ for (int j=0; j<expLabels.size(); j++) {
+ GenNodeLabel expLabel = expLabels.get(j);
+ GenNodeLabel actLabel = actLabels.get(j);
+
+ assertEquals("Node visualID should be the same", expLabel.getVisualID(), actLabel.getVisualID());
+ }
+ }
+ }
+
+ public void testGenChildNodeVisualID() {
+ // GenChildNode
+ EList<GenChildNode> expChildNodes = expectedGenerator.getDiagram().getChildNodes();
+ EList<GenChildNode> actChildNodes = actualGenerator.getDiagram().getChildNodes();
+
+ assertEquals("Number of GenChildNode should be the same", expChildNodes.size(), actChildNodes.size());
+ for (int i=0; i<expChildNodes.size(); i++) {
+ GenChildNode exp = expChildNodes.get(i);
+ GenChildNode act = actChildNodes.get(i);
+
+ assertEquals("Node visualID should be the same", exp.getVisualID(), act.getVisualID());
+
+ EList<GenNodeLabel> expLabels = exp.getLabels();
+ EList<GenNodeLabel> actLabels = act.getLabels();
+
+ assertEquals("Number of GenNodeLabel should be the same", expLabels.size(), actLabels.size());
+ for (int j=0; j<expLabels.size(); j++) {
+ GenNodeLabel expLabel = expLabels.get(j);
+ GenNodeLabel actLabel = actLabels.get(j);
+
+ assertEquals("Node visualID should be the same", expLabel.getVisualID(), actLabel.getVisualID());
+ }
+ }
+ }
+
+ public void testGenLinkVisualID() {
+ // GenLink
+ EList<GenLink> expLinks = expectedGenerator.getDiagram().getLinks();
+ EList<GenLink> actLinks = actualGenerator.getDiagram().getLinks();
+
+ assertEquals("Number of GenLink should be the same", expLinks.size(), actLinks.size());
+ for (int i=0; i<expLinks.size(); i++) {
+ GenLink exp = expLinks.get(i);
+ GenLink act = actLinks.get(i);
+
+ assertEquals("Node visualID should be the same", exp.getVisualID(), act.getVisualID());
+
+ EList<GenLinkLabel> expLabels = exp.getLabels();
+ EList<GenLinkLabel> actLabels = act.getLabels();
+
+ assertEquals("Number of GenNodeLabel should be the same", expLabels.size(), actLabels.size());
+ for (int j=0; j<expLabels.size(); j++) {
+ GenLinkLabel expLabel = expLabels.get(j);
+ GenLinkLabel actLabel = actLabels.get(j);
+
+ assertEquals("Node visualID should be the same", expLabel.getVisualID(), actLabel.getVisualID());
+ }
+ }
+ }
+
+ public void testGenCompartmentVisualID() {
+ // GenCompartment
+ EList<GenCompartment> expCompartments = expectedGenerator.getDiagram().getCompartments();
+ EList<GenCompartment> actCompartments = actualGenerator.getDiagram().getCompartments();
+
+ assertEquals("Number of GenLink should be the same", expCompartments.size(), actCompartments.size());
+ for (int i=0; i<expCompartments.size(); i++) {
+ GenCompartment exp = expCompartments.get(i);
+ GenCompartment act = actCompartments.get(i);
+
+ assertEquals("Node visualID should be the same", exp.getVisualID(), act.getVisualID());
+ }
+ }
+
+ public void testGenTopLevelNodeAttributes() {
+ // GenTopLevelNode
+ EList<GenTopLevelNode> expected = expectedGenerator.getDiagram().getTopLevelNodes();
+ EList<GenTopLevelNode> actual = actualGenerator.getDiagram().getTopLevelNodes();
+
+ assertEquals("Number of GenLink should be the same", expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ GenTopLevelNode exp = expected.get(i);
+ GenTopLevelNode act = actual.get(i);
+
+ assertEquals(exp.getCanonicalEditPolicyClassName(), act.getCanonicalEditPolicyClassName());
+ assertEquals(exp.getCanonicalEditPolicyQualifiedClassName(), act.getCanonicalEditPolicyQualifiedClassName());
+ assertEquals(exp.getClassNamePrefix(), act.getClassNamePrefix());
+ assertEquals(exp.getClassNameSuffux(), act.getClassNameSuffux());
+ assertEquals(exp.getCreateCommandClassName(), act.getCreateCommandClassName());
+ assertEquals(exp.getCreateCommandQualifiedClassName(), act.getCreateCommandQualifiedClassName());
+ assertEquals(exp.getEditPartClassName(), act.getEditPartClassName());
+ assertEquals(exp.getEditPartQualifiedClassName(), act.getEditPartQualifiedClassName());
+ assertEquals(exp.getGraphicalNodeEditPolicyClassName(), act.getGraphicalNodeEditPolicyClassName());
+ assertEquals(exp.getGraphicalNodeEditPolicyQualifiedClassName(), act.getGraphicalNodeEditPolicyQualifiedClassName());
+ assertEquals(exp.getItemSemanticEditPolicyClassName(), act.getItemSemanticEditPolicyClassName());
+ assertEquals(exp.getItemSemanticEditPolicyQualifiedClassName(), act.getItemSemanticEditPolicyQualifiedClassName());
+ assertEquals(exp.getNotationViewFactoryClassName(), act.getNotationViewFactoryClassName());
+ assertEquals(exp.getNotationViewFactoryQualifiedClassName(), act.getNotationViewFactoryQualifiedClassName());
+ assertEquals(exp.getPrimaryDragEditPolicyQualifiedClassName(), act.getPrimaryDragEditPolicyQualifiedClassName());
+ assertEquals(exp.getUniqueIdentifier(), act.getUniqueIdentifier());
+ assertEquals(exp.getVisualID(), act.getVisualID());
+ }
+ }
+
+ public void testGenTopLevelNodeContainments() {
+ // GenTopLevelNode
+ EList<GenTopLevelNode> expected = expectedGenerator.getDiagram().getTopLevelNodes();
+ EList<GenTopLevelNode> actual = actualGenerator.getDiagram().getTopLevelNodes();
+
+ assertEquals("Number of GenLink should be the same", expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ GenTopLevelNode exp = expected.get(i);
+ GenTopLevelNode act = actual.get(i);
+
+ testElementType(exp.getElementType(), act.getElementType());
+ testViewmap(exp.getViewmap(), act.getViewmap());
+ testBehaviours(exp.getBehaviour(),act.getBehaviour());
+ }
+ }
+
+ public void testGenChildNodeAttributes() {
+ // GenChildNode
+ EList<GenChildNode> expected = expectedGenerator.getDiagram().getChildNodes();
+ EList<GenChildNode> actual = actualGenerator.getDiagram().getChildNodes();
+
+ assertEquals("Number of GenChildNode should be the same", expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ GenChildNode exp = expected.get(i);
+ GenChildNode act = actual.get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+
+ for (EAttribute attribute: exp.eClass().getEAllAttributes()) {
+ if (exp.eIsSet(attribute)) {
+ assertTrue(attribute+" should be set", act.eIsSet(attribute));
+
+ if (!attribute.isMany()) {
+ assertEquals(exp.eGet(attribute), act.eGet(attribute));
+ }
+ } else {
+ assertFalse(attribute+" should not be set", act.eIsSet(attribute));
+ }
+ }
+ }
+ }
+
+ public void testGenLinksAttributes() {
+ // GenTopLevelNode
+ EList<GenLink> expected = expectedGenerator.getDiagram().getLinks();
+ EList<GenLink> actual = actualGenerator.getDiagram().getLinks();
+
+ assertEquals("Number of GenLink should be the same", expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ GenLink expLink = expected.get(i);
+ GenLink actLink = actual.get(i);
+
+ assertEquals(expLink.getClassNamePrefix(), actLink.getClassNamePrefix());
+ assertEquals(expLink.getClassNameSuffux(), actLink.getClassNameSuffux());
+ assertEquals(expLink.getCreateCommandClassName(), actLink.getCreateCommandClassName());
+ assertEquals(expLink.getCreateCommandQualifiedClassName(), actLink.getCreateCommandQualifiedClassName());
+ assertEquals(expLink.getEditPartClassName(), actLink.getEditPartClassName());
+ assertEquals(expLink.getEditPartQualifiedClassName(), actLink.getEditPartQualifiedClassName());
+ assertEquals(expLink.getItemSemanticEditPolicyClassName(), actLink.getItemSemanticEditPolicyClassName());
+ assertEquals(expLink.getItemSemanticEditPolicyQualifiedClassName(), actLink.getItemSemanticEditPolicyQualifiedClassName());
+ assertEquals(expLink.getNotationViewFactoryClassName(), actLink.getNotationViewFactoryClassName());
+ assertEquals(expLink.getNotationViewFactoryQualifiedClassName(), actLink.getNotationViewFactoryQualifiedClassName());
+ assertEquals(expLink.getReorientCommandClassName(), actLink.getReorientCommandClassName());
+ assertEquals(expLink.getReorientCommandQualifiedClassName(), actLink.getReorientCommandQualifiedClassName());
+ assertEquals(expLink.getUniqueIdentifier(), actLink.getUniqueIdentifier());
+ assertEquals(expLink.getVisualID(), actLink.getVisualID());
+ }
+ }
+
+ public void testPalette() {
+ Palette expected = expectedGenerator.getDiagram().getPalette();
+ Palette actual = actualGenerator.getDiagram().getPalette();
+
+ assertNotNull("Expected Palette should not be null", expected);
+ assertNotNull("Actual Palette should not be null", actual);
+
+ System.out.println(expected + " -> " + actual);
+
+ assertEquals(expected.getFactoryClassName(), actual.getFactoryClassName());
+ assertEquals(expected.isFlyout(), actual.isFlyout());
+ assertEquals(expected.getPackageName(), actual.getPackageName());
+
+ assertEquals(expected.getGroups().size(), actual.getGroups().size());
+ for (int i=0; i<expected.getGroups().size(); i++) {
+ ToolGroup exp = expected.getGroups().get(i);
+ ToolGroup act = actual.getGroups().get(i);
+
+ testToolGroup(exp, act);
+ }
+ }
+
+ private void testToolGroup(ToolGroup expected, ToolGroup actual) {
+ assertEquals(expected.getId(), actual.getId());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getLargeIconPath(), actual.getLargeIconPath());
+ assertEquals(expected.getSmallIconPath(), actual.getSmallIconPath());
+ assertEquals(expected.getCreateMethodName(), actual.getCreateMethodName());
+
+ assertEquals(expected.isCollapse(), actual.isCollapse());
+ assertEquals(expected.isStack(), actual.isStack());
+ assertEquals(expected.isToolsOnly(), actual.isToolsOnly());
+
+ assertEquals(expected.getEntries().size(), actual.getEntries().size());
+ for (int i = 0; i < expected.getEntries().size(); i++) {
+ ToolGroupItem exp = expected.getEntries().get(i);
+ ToolGroupItem act = actual.getEntries().get(i);
+
+ if (exp instanceof AbstractToolEntry) {
+ testAbstractToolEntry((AbstractToolEntry)exp, (AbstractToolEntry)act);
+ }
+ }
+ }
+
+ private void testAbstractToolEntry(AbstractToolEntry expected, AbstractToolEntry actual) {
+ assertEquals(expected.eClass(), actual.eClass());
+
+ assertEquals(expected.getCreateMethodName(), actual.getCreateMethodName());
+ assertEquals(expected.getId(), actual.getId());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getTitle(), actual.getTitle());
+ assertEquals(expected.getLargeIconPath(), actual.getLargeIconPath());
+ assertEquals(expected.getSmallIconPath(), actual.getSmallIconPath());
+
+ assertEquals(expected.isDefault(), actual.isDefault());
+ assertEquals(expected.getQualifiedToolName(), actual.getQualifiedToolName());
+
+ assertEquals(expected.getProperties().size(), actual.getProperties().size());
+ for (int i=0; i<expected.getProperties().size(); i++) {
+ Entry<String, String> exp = expected.getProperties().get(i);
+ Entry<String, String> act = actual.getProperties().get(i);
+
+ assertEquals(exp.getKey(), act.getKey());
+ assertEquals(exp.getKey(), act.getValue());
+ }
+
+ if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getStandardEntry())) {
+ testStandardEntry((StandardEntry) expected, (StandardEntry) actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getToolEntry())) {
+ testToolEntry((ToolEntry) expected, (ToolEntry) actual);
+ }
+ }
+
+ private void testStandardEntry(StandardEntry expected, StandardEntry actual) {
+ assertEquals(expected.getKind().getLiteral(), actual.getKind().getLiteral());
+ }
+
+ private void testToolEntry(ToolEntry expected, ToolEntry actual) {
+ assertEquals(expected.getElements().size(), actual.getElements().size());
+ for (int i=0; i<expected.getElements().size(); i++) {
+ GenCommonBase exp = expected.getElements().get(i);
+ GenCommonBase act = expected.getElements().get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+ assertEquals(exp.getVisualID(), act.getVisualID());
+ assertEquals(exp.getUniqueIdentifier(), act.getUniqueIdentifier());
+ }
+ assertEquals(expected.getGenLinks().size(), actual.getGenLinks().size());
+ for (int i=0; i<expected.getGenLinks().size(); i++) {
+ GenLink exp = expected.getGenLinks().get(i);
+ GenLink act = expected.getGenLinks().get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+ assertEquals(exp.getVisualID(), act.getVisualID());
+ assertEquals(exp.getUniqueIdentifier(), act.getUniqueIdentifier());
+ }
+ assertEquals(expected.getGenNodes().size(), actual.getGenNodes().size());
+ for (int i=0; i<expected.getGenNodes().size(); i++) {
+ GenNode exp = expected.getGenNodes().get(i);
+ GenNode act = expected.getGenNodes().get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+ assertEquals(exp.getVisualID(), act.getVisualID());
+ assertEquals(exp.getUniqueIdentifier(), act.getUniqueIdentifier());
+ }
+ }
+
+ public void testGenAuditRoot() {
+ GenAuditRoot expected = expectedGenerator.getAudits();
+ GenAuditRoot actual = actualGenerator.getAudits();
+
+ testGenAuditContainers(expected.getCategories(), actual.getCategories());
+ }
+
+ public void testGenPreferencePages() {
+ EList<GenPreferencePage> expected = expectedGenerator.getDiagram().getPreferencePages();
+ EList<GenPreferencePage> actual = actualGenerator.getDiagram().getPreferencePages();
+
+ assertEquals(expected.size(), actual.size());
+ for (int i=0; i<expected.size(); i++) {
+ GenPreferencePage exp = expected.get(i);
+ GenPreferencePage act = actual.get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+ assertEquals(exp.getID(), act.getID());
+ assertEquals(exp.getName(), act.getName());
+ assertEquals(exp.getClassName(), act.getClassName());
+ assertEquals(exp.getParentCategory(), act.getParentCategory());
+ assertEquals(exp.getQualifiedClassName(), act.getQualifiedClassName());
+
+ if (exp.eClass().equals(GMFGenPackage.eINSTANCE.getGenCustomPreferencePage())) {
+ assertEquals((GenCustomPreferencePage)exp, (GenCustomPreferencePage)act);
+ } else if (exp.eClass().equals(GMFGenPackage.eINSTANCE.getGenStandardPreferencePage())) {
+ assertEquals((GenStandardPreferencePage)exp, (GenStandardPreferencePage)act);
+ }
+ }
+ }
+
+ private void assertEquals(GenCustomPreferencePage expected, GenCustomPreferencePage actual) {
+ assertEquals(expected.isGenerateBoilerplate(), actual.isGenerateBoilerplate());
+ assertEquals(expected.getQualifiedClassName(), actual.getQualifiedClassName());
+ }
+
+ private void assertEquals(GenStandardPreferencePage expected, GenStandardPreferencePage actual) {
+ assertEquals(expected.getClassName(), actual.getClassName());
+ assertEquals(expected.getKind().getLiteral(), actual.getKind().getLiteral());
+ }
+
+ protected void testGenAuditContainers(EList<GenAuditContainer> expected, EList<GenAuditContainer> actual) {
+ assertEquals(expected.size(), actual.size());
+ for (int i=0; i<expected.size(); i++) {
+ GenAuditContainer exp = expected.get(i);
+ GenAuditContainer act = actual.get(i);
+
+ assertEquals(exp.getId(), act.getId());
+ assertEquals(exp.getDescription(), act.getDescription());
+ assertEquals(exp.getName(), act.getName());
+
+ assertEquals(exp.getPath().size(), act.getPath().size());
+ }
+ }
+
+ protected void testGenAuditRules(EList<GenAuditRule> expected, EList<GenAuditRule> actual) {
+ assertEquals(expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ GenAuditRule exp = expected.get(i);
+ GenAuditRule act = actual.get(i);
+
+ assertEquals(exp.getId(), act.getId());
+ assertEquals(exp.getDescription(), act.getDescription());
+ assertEquals(exp.getMessage(), act.getMessage());
+ assertEquals(exp.getName(), act.getName());
+ assertEquals(exp.isRequiresConstraintAdapter(), act.isRequiresConstraintAdapter());
+ assertEquals(exp.getSeverity().getLiteral(), act.getSeverity().getLiteral());
+ assertEquals(exp.isUseInLiveMode(), act.isUseInLiveMode());
+
+ GenAuditable expAuditable = exp.getTarget();
+ GenAuditable actAuditable = act.getTarget();
+
+ assertEquals(expAuditable.eClass(), actAuditable.eClass());
+ assertEquals(expAuditable.getTargetClassModelQualifiedName(), actAuditable.getTargetClassModelQualifiedName());
+ assertEquals(expAuditable.getTargetClass(), actAuditable.getTargetClass());
+ assertEquals(expAuditable.getContext(), actAuditable.getContext());
+
+ if (expAuditable.eClass().equals(GMFGenPackage.eINSTANCE.getGenDomainAttributeTarget())) {
+ assertEquals((GenDomainAttributeTarget) expAuditable, (GenDomainAttributeTarget) actAuditable);
+ } else if (expAuditable.eClass().equals(GMFGenPackage.eINSTANCE.getGenDomainElementTarget())) {
+ assertEquals((GenDomainElementTarget) expAuditable, (GenDomainElementTarget) actAuditable);
+ } else if (expAuditable.eClass().equals(GMFGenPackage.eINSTANCE.getGenNotationElementTarget())) {
+ assertEquals((GenNotationElementTarget) expAuditable, (GenNotationElementTarget) actAuditable);
+ }
+ }
+ }
+
+ private void assertEquals(GenDomainAttributeTarget expected, GenDomainAttributeTarget actual) {
+ assertEquals(expected.isNullAsError(), actual.isNullAsError());
+ assertEquals(expected.getAttribute(), actual.getAttribute());
+ }
+
+ private void assertEquals(GenDomainElementTarget expected, GenDomainElementTarget actual) {
+ assertEquals(expected.getElement(), actual.getElement());
+ }
+
+ private void assertEquals(GenNotationElementTarget expected, GenNotationElementTarget actual) {
+ assertEquals(expected.getElement(), actual.getElement());
+ }
+
+ protected void testBehaviours(EList<Behaviour> expected, EList<Behaviour> actual) {
+ assertEquals(expected.size(), actual.size());
+
+ for (int i=0; i<expected.size(); i++) {
+ Behaviour exp = expected.get(i);
+ Behaviour act = actual.get(i);
+
+ assertEquals(exp.eClass(), act.eClass());
+ assertEquals(exp.getEditPolicyQualifiedClassName(), act.getEditPolicyQualifiedClassName());
+ assertEquals(exp.getSubject().getUniqueIdentifier(), act.getSubject().getUniqueIdentifier());
+
+ if (exp.eClass().equals(GMFGenPackage.eINSTANCE.getOpenDiagramBehaviour())) {
+ assertEquals((OpenDiagramBehaviour)exp, (OpenDiagramBehaviour)act);
+ } else if (exp.eClass().equals(GMFGenPackage.eINSTANCE.getSharedBehaviour())) {
+ assertEquals((SharedBehaviour)exp, (SharedBehaviour)act);
+ }
+ }
+ }
+
+ protected void assertEquals(OpenDiagramBehaviour expected, OpenDiagramBehaviour actual) {
+ assertEquals(expected.getDiagramKind(), actual.getDiagramKind());
+ assertEquals(expected.getEditorID(), actual.getEditorID());
+ assertEquals(expected.getEditPolicyClassName(), actual.getEditPolicyClassName());
+ }
+
+ protected void assertEquals(SharedBehaviour expected, SharedBehaviour actual) {
+ assertEquals(expected.getDelegate().getSubject().getUniqueIdentifier(), actual.getDelegate().getSubject().getUniqueIdentifier());
+ }
+
+ protected void testElementType(ElementType expected, ElementType actual) {
+ assertNotNull(expected);
+ assertNotNull(actual);
+
+ assertEquals(expected.getDisplayName(), actual.getDisplayName());
+ assertEquals(expected.getUniqueIdentifier(), actual.getUniqueIdentifier());
+ assertEquals(expected.getDiagramElement().getUniqueIdentifier(), actual.getDiagramElement().getUniqueIdentifier());
+ }
+
+ protected void testViewmap(Viewmap expected, Viewmap actual) {
+ assertNotNull(expected);
+ assertNotNull(actual);
+
+ assertEquals(expected.eClass(), actual.eClass());
+ assertEquals(expected.getLayoutType(), actual.getLayoutType());
+ assertEquals(expected.getRequiredPluginIDs().size(), actual.getRequiredPluginIDs().size());
+
+ for (int i=0; i<expected.getRequiredPluginIDs().size(); i++) {
+ String exp = expected.getRequiredPluginIDs().get(i);
+ String act = expected.getRequiredPluginIDs().get(i);
+
+ assertEquals(exp, act);
+ }
+ EList<Attributes> expAttributes = expected.getAttributes();
+ EList<Attributes> actAttributes = actual.getAttributes();
+ assertEquals(expAttributes.size(), actAttributes.size());
+ for (int j=0; j<expAttributes.size(); j++) {
+ Attributes expAttr = expAttributes.get(j);
+ Attributes actAttr = actAttributes.get(j);
+ testAttributes(expAttr, actAttr);
+ }
+
+ if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getFigureViewmap())) {
+ assertEquals((FigureViewmap)expected, (FigureViewmap)actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getSnippetViewmap())) {
+ assertEquals((SnippetViewmap)expected, (SnippetViewmap)actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getInnerClassViewmap())) {
+ assertEquals((InnerClassViewmap)expected, (InnerClassViewmap)actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getParentAssignedViewmap())) {
+ assertEquals((ParentAssignedViewmap)expected, (ParentAssignedViewmap)actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getModeledViewmap())) {
+ assertEquals((ModeledViewmap)expected, (ModeledViewmap)actual);
+ }
+ }
+
+ protected void assertEquals(ModeledViewmap expected, ModeledViewmap actual) {
+ assertEquals(expected.getFigureModel(), actual.getFigureModel());
+ }
+
+ protected void assertEquals(ParentAssignedViewmap expected, ParentAssignedViewmap actual) {
+ assertEquals(expected.getFigureQualifiedClassName(), actual.getFigureQualifiedClassName());
+ assertEquals(expected.getGetterName(), actual.getGetterName());
+ assertEquals(expected.getSetterName(), actual.getSetterName());
+ }
+
+ protected void assertEquals(InnerClassViewmap expected, InnerClassViewmap actual) {
+ assertEquals(expected.getClassBody(), actual.getClassBody());
+ assertEquals(expected.getClassName(), actual.getClassName());
+ }
+
+ protected void assertEquals(SnippetViewmap expected, SnippetViewmap actual) {
+ assertEquals(expected.getBody(), actual.getBody());
+ }
+
+ protected void assertEquals(FigureViewmap expected, FigureViewmap actual) {
+ assertEquals(expected.getFigureQualifiedClassName(), actual.getFigureQualifiedClassName());
+ }
+
+ protected void testAttributes(Attributes expected, Attributes actual) {
+ assertNotNull(expected);
+ assertNotNull(actual);
+
+ assertEquals(expected.eClass(), actual.eClass());
+
+ if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getColorAttributes())) {
+ assertEquals((ColorAttributes) expected, (ColorAttributes) actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getStyleAttributes())) {
+ assertEquals((StyleAttributes) expected, (StyleAttributes) actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getResizeConstraints())) {
+ assertEquals((ResizeConstraints) expected, (ResizeConstraints) actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getDefaultSizeAttributes())) {
+ assertEquals((DefaultSizeAttributes) expected, (DefaultSizeAttributes) actual);
+ } else if (expected.eClass().equals(GMFGenPackage.eINSTANCE.getLabelOffsetAttributes())) {
+ assertEquals((LabelOffsetAttributes) expected, (LabelOffsetAttributes) actual);
+ } else {
+ throw new IllegalArgumentException("EClass not found");
+ }
+ }
+
+ protected void assertEquals(ColorAttributes expected, ColorAttributes actual) {
+ assertEquals(expected.getBackgroundColor(), actual.getBackgroundColor());
+ assertEquals(expected.getForegroundColor(), actual.getForegroundColor());
+ }
+
+ protected void assertEquals(StyleAttributes expected, StyleAttributes actual) {
+ assertEquals(expected.isFixedBackground(), actual.isFixedBackground());
+ assertEquals(expected.isFixedFont(), actual.isFixedFont());
+ assertEquals(expected.isFixedForeground(), actual.isFixedForeground());
+ }
+
+ protected void assertEquals(ResizeConstraints expected, ResizeConstraints actual) {
+ assertEquals(expected.getNonResizeHandles(), actual.getNonResizeHandles());
+ assertEquals(expected.getResizeHandles(), actual.getResizeHandles());
+ assertEquals(expected.getResizeHandleNames().size(), actual.getResizeHandleNames().size());
+ for (int i=0; i<expected.getResizeHandleNames().size(); i++) {
+ String exp = expected.getResizeHandleNames().get(i);
+ String act = actual.getResizeHandleNames().get(i);
+
+ assertEquals(exp, act);
+ }
+ assertEquals(expected.getNonResizeHandleNames().size(), actual.getNonResizeHandleNames().size());
+ for (int i=0; i<expected.getNonResizeHandleNames().size(); i++) {
+ String exp = expected.getNonResizeHandleNames().get(i);
+ String act = actual.getNonResizeHandleNames().get(i);
+
+ assertEquals(exp, act);
+ }
+ }
+
+ protected void assertEquals(DefaultSizeAttributes expected, DefaultSizeAttributes actual) {
+ assertEquals(expected.getHeight(), actual.getHeight());
+ assertEquals(expected.getWidth(), actual.getWidth());
+ }
+
+ protected void assertEquals(LabelOffsetAttributes expected, LabelOffsetAttributes actual) {
+ assertEquals(expected.getX(), actual.getX());
+ assertEquals(expected.getY(), actual.getY());
+ }
+
+ protected IProject createProject() {
+ String projectName = "TransformToGenModelOperationTest_" + String.valueOf(System.currentTimeMillis()); //$NON-NLS-1$
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ assertFalse("Project with this name already present in the workspace: " + projectName, project.exists());
+ try {
+ project.create(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail(e.getMessage());
+ }
+ assertTrue("Project was not created: " + projectName, project.exists());
+ return project;
+ }
+
+ protected void deleteProject() throws CoreException {
+ if (getProject() != null) {
+ if (getProject().isOpen()) {
+ getProject().close(new NullProgressMonitor());
+ }
+ if (getProject().exists()) {
+ getProject().delete(true, new NullProgressMonitor());
+ }
+ }
+ }
+
+ protected IProject getProject() {
+ return myProject;
+ }
+}
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformationTestSupport.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformationTestSupport.java
new file mode 100644
index 0000000..34b784c
--- /dev/null
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/tr/TransformationTestSupport.java
@@ -0,0 +1,136 @@
+package org.eclipse.gmf.tests.tr;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.graphdef.codegen.MapModeCodeGenStrategy;
+import org.eclipse.gmf.internal.bridge.StatefulVisualIdentifierDispencer;
+import org.eclipse.gmf.internal.bridge.genmodel.BasicDiagramRunTimeModelHelper;
+import org.eclipse.gmf.internal.bridge.genmodel.DiagramGenModelTransformer;
+import org.eclipse.gmf.internal.bridge.genmodel.DiagramRunTimeModelHelper;
+import org.eclipse.gmf.internal.bridge.genmodel.GenModelProducer;
+import org.eclipse.gmf.internal.bridge.genmodel.InnerClassViewmapProducer;
+import org.eclipse.gmf.internal.bridge.genmodel.ModeledViewmapProducer;
+import org.eclipse.gmf.internal.bridge.genmodel.QVTDiagramGenModelTransformer;
+import org.eclipse.gmf.internal.bridge.genmodel.ViewmapProducer;
+import org.eclipse.gmf.internal.bridge.transform.VisualIdentifierDispenserProvider;
+import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.m2m.qvt.oml.BasicModelExtent;
+import org.eclipse.m2m.qvt.oml.ExecutionContextImpl;
+import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
+
+/**
+ * Utility class for tests around qvto-bridge.
+ *
+ * @author ghillairet
+ *
+ */
+public class TransformationTestSupport {
+
+ abstract static class Transformation {
+ protected GenEditorGenerator editor;
+ protected StatefulVisualIdentifierDispencer dispenser;
+
+ public GenEditorGenerator getEditor() {
+ return editor;
+ }
+ public abstract GenEditorGenerator execute(URI outputURI);
+ public StatefulVisualIdentifierDispencer getDispencer() {return dispenser;}
+ }
+
+ public static Transformation getJavaTransformation(final GenModel genModel, final Mapping mapping, final boolean useModeledViewmap) {
+ return new Transformation() {
+ @Override
+ public GenEditorGenerator execute(URI outputURI) {
+ VisualIdentifierDispenserProvider provider = new VisualIdentifierDispenserProvider(outputURI); //traceURI.trimFileExtension().appendFileExtension("java.gmfgen")
+ provider.acquire();
+
+ dispenser = (StatefulVisualIdentifierDispencer) provider.get();
+
+ GenModelProducer producer = getJavaGenModelProducer(useModeledViewmap, genModel, provider);
+ try {
+ editor = producer.process(mapping, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ Resource resource = genModel.eResource().getResourceSet().createResource(outputURI);
+ resource.getContents().add(editor);
+
+ return editor;
+ }
+ };
+ }
+
+ public static Transformation getQvtTransformation(final GenModel genModel, final Mapping mapping, final boolean useModeledViewmap) {
+ return new Transformation() {
+ @Override
+ public GenEditorGenerator execute(URI outputURI) {
+ VisualIdentifierDispenserProvider provider = new VisualIdentifierDispenserProvider(outputURI);
+ provider.acquire();
+
+ dispenser = (StatefulVisualIdentifierDispencer) provider.get();
+ GenModelProducer producer = getQvtGenModelProducer(useModeledViewmap, genModel, provider, genModel.eResource().getResourceSet());
+ try {
+ editor = producer.process(mapping, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ Resource resource = genModel.eResource().getResourceSet().createResource(outputURI);
+ resource.getContents().add(editor);
+
+ return editor;
+ }
+ };
+ }
+
+ public static GenModelProducer getJavaGenModelProducer(boolean useModeledViewmap, final GenModel genModel, VisualIdentifierDispenserProvider idDespenser) {
+ MapModeCodeGenStrategy mmStrategy = MapModeCodeGenStrategy.DYNAMIC;
+ ViewmapProducer viewmapProducer = useModeledViewmap ? new ModeledViewmapProducer() : new InnerClassViewmapProducer("full", mmStrategy, null);
+
+ final DiagramRunTimeModelHelper drtModelHelper = new BasicDiagramRunTimeModelHelper();
+ DiagramGenModelTransformer.Parameters opts = new DiagramGenModelTransformer.Parameters(drtModelHelper, viewmapProducer, idDespenser.get(), false);
+ final DiagramGenModelTransformer t = new DiagramGenModelTransformer(opts);
+
+ t.setEMFGenModel(genModel);
+
+ return new GenModelProducer() {
+ public GenEditorGenerator process(Mapping mapping, IProgressMonitor progress) {
+ t.transform(mapping);
+ return t.getResult();
+ }
+ };
+ }
+
+ public static GenModelProducer getQvtGenModelProducer(boolean useModeledViewmap, final GenModel genModel, VisualIdentifierDispenserProvider idDespenser, ResourceSet resourceSet) {
+ final ExecutionContextImpl context = new ExecutionContextImpl();
+ context.setConfigProperty("rcp", false);
+ context.setConfigProperty("useMapMode", false);
+ context.setConfigProperty("useFullRunTime", false);
+ context.setConfigProperty("useInTransformationCodeGen", !useModeledViewmap);
+
+ final QVTDiagramGenModelTransformer transformer = new QVTDiagramGenModelTransformer(resourceSet, idDespenser.get());
+
+ return new GenModelProducer() {
+ public GenEditorGenerator process(Mapping mapping, IProgressMonitor progress) throws CoreException {
+ final BasicModelExtent output = new BasicModelExtent();
+ final ExecutionDiagnostic result = transformer.transform(mapping, genModel, output, context);
+
+ if(result.getSeverity() == Diagnostic.OK) {
+ List<EObject> outObjects = output.getContents();
+ return outObjects.get(0) instanceof GenEditorGenerator ? (GenEditorGenerator) outObjects.get(0) : null;
+ }
+ return null;
+ }
+ };
+ }
+}