Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2018-06-19 08:28:30 -0400
committerBenoit Maggi2018-06-19 08:28:30 -0400
commita634e9d9dcf04bd336e70fc588e0492ef04c036a (patch)
treec7cbd4d56e27b33bd4170f284f4aa622ed065537
parent49735abfa37bfec5ba8df800aae6f2e057d8469e (diff)
downloadorg.eclipse.papyrus-a634e9d9dcf04bd336e70fc588e0492ef04c036a.tar.gz
org.eclipse.papyrus-a634e9d9dcf04bd336e70fc588e0492ef04c036a.tar.xz
org.eclipse.papyrus-a634e9d9dcf04bd336e70fc588e0492ef04c036a.zip
Bug 536048 - [Core] Test that model are valid
- Add ModelValidationTest to check models - fix english typo - small quality patches Change-Id: Ib7eaa0767553167710390aaa0adff1623dea67c7 Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddBorderItem.expansionmodel2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddChildLabel.expansionmodel2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartment.expansionmodel4
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartmentWithKind.expansionmodel2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddLink.expansionmodel2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AllTests.java5
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AssistantUsage.java18
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/ModelValidationTest.java77
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/TestModelValidationTest.java99
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/ClassifierViewFactory.java19
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java17
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/resources/ModelValidationTest.java80
13 files changed, 294 insertions, 35 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddBorderItem.expansionmodel b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddBorderItem.expansionmodel
index a2fd34c98af..2ab611afd3c 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddBorderItem.expansionmodel
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddBorderItem.expansionmodel
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<expansionmodel:DiagramExpansion xmlns:expansionmodel="http:///expansionmodel.ecore" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="test AddBorderItem" xmi:id="_BOX98NnkEeSFtu511b-yaw" xmi:version="2.0">
- <usages diagramType="Class Diagram" name="Add acomparment on class of papyrus" representations="//@usages.0/@gmftRepresentations.0">
+ <usages diagramType="Class Diagram" name="Add a compartment on class of Papyrus" representations="//@usages.0/@gmftRepresentations.0">
<gmftRepresentations editPartQualifiedName="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart" name="Reuse representation of class of the class diagram" reusedID="Class_Shape" subRepresentations="//@libraries.0/@representations.0" viewFactory="org.eclipse.papyrus.infra.gmfdiag.common.utils.ClassifierViewFactory"/>
</usages>
<libraries name="library">
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddChildLabel.expansionmodel b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddChildLabel.expansionmodel
index da83a080316..aa0ba9f30f3 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddChildLabel.expansionmodel
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddChildLabel.expansionmodel
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<expansionmodel:DiagramExpansion xmlns:expansionmodel="http:///expansionmodel.ecore" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="AddChildLabel" xmi:id="_BOX98NnkEeSFtu511b-yaw" xmi:version="2.0">
- <usages diagramType="Class Diagram" name="Add acomparment on class of papyrus" representations="//@usages.0/@gmftRepresentations.0">
+ <usages diagramType="Class Diagram" name="Add a compartment on class of Papyrus" representations="//@usages.0/@gmftRepresentations.0">
<gmftRepresentations editPartQualifiedName="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart" inducedRepresentations="//@libraries.0/@representations.0" name="Reuse representation of class of the class diagram" reusedID="Class_Shape" viewFactory="org.eclipse.papyrus.infra.gmfdiag.common.utils.ClassifierViewFactory"/>
</usages>
<libraries name="compartmentlibrary">
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartment.expansionmodel b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartment.expansionmodel
index 6103fdb57d8..88c104a7191 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartment.expansionmodel
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartment.expansionmodel
@@ -8,10 +8,10 @@
ID="Add CompartmentText">
<usages diagramType="Class Diagram"
representations="//@usages.0/@gmftRepresentations.0"
- name="Add acomparment on class of papyrus">
+ name="Add a compartment on class of Papyrus">
<gmftRepresentations
editPartQualifiedName="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart"
- name="Reuse respresentation of class of the class diagram"
+ name="Reuse representation of class of the class diagram"
viewFactory="org.eclipse.papyrus.infra.gmfdiag.common.utils.ClassifierViewFactory"
inducedRepresentations="//@libraries.0/@representations.0"
reusedID="Class_Shape"/>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartmentWithKind.expansionmodel b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartmentWithKind.expansionmodel
index ee6c736c9ff..c693159a84c 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartmentWithKind.expansionmodel
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddCompartmentWithKind.expansionmodel
@@ -8,7 +8,7 @@
ID="Add CompartmentText">
<usages diagramType="Class Diagram"
representations="//@usages.0/@gmftRepresentations.0"
- name="Add acomparment on class of papyrus">
+ name="Add a compartment on class of Papyrus">
<gmftRepresentations
editPartQualifiedName="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart"
name="Reuse respresentation of class of the class diagram"
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddLink.expansionmodel b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddLink.expansionmodel
index 697db944774..e3383ee2eed 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddLink.expansionmodel
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/models/AddLink.expansionmodel
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<expansionmodel:DiagramExpansion xmlns:expansionmodel="http:///expansionmodel.ecore" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="test new link" xmi:id="_BOX98NnkEeSFtu511b-yaw" xmi:version="2.0">
- <usages diagramType="Class Diagram" name="Add link on class of papyrus" representations="//@libraries.0/@representations.0"/>
+ <usages diagramType="Class Diagram" name="Add link on class of Papyrus" representations="//@libraries.0/@representations.0"/>
<libraries name="library">
<representations description="" editPartQualifiedName="org.eclipse.papyrus.uml.diagram.clazz.edit.parts.DependencyEditPart" name="NewDependency" viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.ConnectorViewFactory" xsi:type="expansionmodel:Representation">
<graphicalElementTypeRef href="TestExpansionDiagram.elementtypesconfigurations#org.eclipse.papyrus.uml.diagram.testexpansion.Dependency_Link" xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration"/>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AllTests.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AllTests.java
index 207337bcd5e..2edaa72b74c 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AllTests.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AllTests.java
@@ -19,6 +19,8 @@ import org.eclipse.papyrus.infra.gmfdiag.common.commands.tests.DefaultDiagramPas
import org.eclipse.papyrus.infra.gmfdiag.common.commands.tests.DefaultPasteCommandTest;
import org.eclipse.papyrus.infra.gmfdiag.common.providers.tests.NotationLabelProviderTest;
import org.eclipse.papyrus.infra.gmfdiag.common.sync.tests.SyncTests;
+import org.eclipse.papyrus.infra.gmfdiag.common.tests.resources.ModelValidationTest;
+import org.eclipse.papyrus.infra.gmfdiag.common.tests.resources.TestModelValidationTest;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafeTest;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
import org.junit.runner.RunWith;
@@ -30,7 +32,6 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(ClassificationSuite.class)
@SuiteClasses({
- // {oep.commands}
LoadExpansionModel.class,
ExpansionAddCompartment.class,
ExpansionAddChildLabel.class,
@@ -47,6 +48,8 @@ import org.junit.runners.Suite.SuiteClasses;
DefaultPasteCommandTest.class,
DefaultDiagramCopyCommandTest.class,
DefaultDiagramPasteCommandTest.class,
+ ModelValidationTest.class,
+ TestModelValidationTest.class,
})
public class AllTests {
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AssistantUsage.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AssistantUsage.java
index 8249b2c11e2..4dd25c5a9d9 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AssistantUsage.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/AssistantUsage.java
@@ -99,18 +99,17 @@ public class AssistantUsage extends AbstractEditorTest {
// test the data structure that is interpreted by the framework
ChildrenListRepresentation childrenListRepresentation = diagramExpansionsRegistry.mapChildreen.get(CLASS_DIAGRAM_TYPE);
- System.out.println(childrenListRepresentation);
Assert.assertNotNull("A usage contex has been defined for " + CLASS_DIAGRAM_TYPE, childrenListRepresentation);
Assert.assertNotNull("The class has been redefined", childrenListRepresentation.IDMap.get(CLASS_VISUALID));
Assert.assertNotNull("The compartment of class has been added", childrenListRepresentation.IDMap.get(IMPLEMENTED_INTERFACES_HINT));
- List<String> the_class_shape_Children = childrenListRepresentation.parentChildrenRelation.get(CLASS_VISUALID);
- Assert.assertEquals("class shape can have a new compartment", 1, the_class_shape_Children.size());
- Assert.assertEquals("class shape has to contain " + IMPLEMENTED_INTERFACES_HINT, IMPLEMENTED_INTERFACES_HINT, the_class_shape_Children.get(0));
+ List<String> theClassShapeChildren = childrenListRepresentation.parentChildrenRelation.get(CLASS_VISUALID);
+ Assert.assertEquals("class shape can have a new compartment", 1, theClassShapeChildren.size());
+ Assert.assertEquals("class shape has to contain " + IMPLEMENTED_INTERFACES_HINT, IMPLEMENTED_INTERFACES_HINT, theClassShapeChildren.get(0));
Assert.assertNotNull("The Nested Interface has to be added", childrenListRepresentation.IDMap.get(NESTED_INTERFACE_LABEL));
- List<String> the_IMPLEMENTED_INTERFACES_Children = childrenListRepresentation.parentChildrenRelation.get(IMPLEMENTED_INTERFACES_HINT);
- Assert.assertEquals("Nested Interface can have a new compartment", 1, the_IMPLEMENTED_INTERFACES_Children.size());
- Assert.assertEquals("Nested Interface has to contain " + NESTED_INTERFACE_LABEL, NESTED_INTERFACE_LABEL, the_IMPLEMENTED_INTERFACES_Children.get(0));
+ List<String> theImplementedInterfacesChildren = childrenListRepresentation.parentChildrenRelation.get(IMPLEMENTED_INTERFACES_HINT);
+ Assert.assertEquals("Nested Interface can have a new compartment", 1, theImplementedInterfacesChildren.size());
+ Assert.assertEquals("Nested Interface has to contain " + NESTED_INTERFACE_LABEL, NESTED_INTERFACE_LABEL, theImplementedInterfacesChildren.get(0));
// the model is valid
// now launch a class diagram
@@ -157,9 +156,6 @@ public class AssistantUsage extends AbstractEditorTest {
for (Object object : types) {
if (object instanceof ISpecializationType) {
ISpecializationType elementType = (ISpecializationType) object;
- System.out.println(elementType);
-
-
if (("org.eclipse.papyrus.uml.diagram.testexpansion.Interface_Label".equals(elementType.getId()))) {
// find the good short cut
@@ -177,8 +173,6 @@ public class AssistantUsage extends AbstractEditorTest {
}
}
Assert.assertTrue("the assistant must contain the shortcut of interface label ", founded);
-
-
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
index 18a9fecf70c..17971c5b779 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/ExpansionAddLink.java
@@ -113,7 +113,7 @@ public class ExpansionAddLink extends AbstractEditorTest {
Command command = myOtherclassEditPart.getCommand(createConnectionViewRequest(elementType_Dependency, myclassEditPart, myOtherclassEditPart, diagramEditPart));
assertNotNull("The command to create link must be not null", command);
- assertTrue("The command to create link must be executable", command.canExecute() == true);
+ assertTrue("The command to create link must be executable", command.canExecute());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
assertTrue("The edge must be created", (diagramEditPart.getDiagramView()).getEdges().size() == 1);
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart linkEditPart = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) diagramEditPart.getConnections().get(0);
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/ModelValidationTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/ModelValidationTest.java
new file mode 100644
index 00000000000..d2d5e7d6afe
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/ModelValidationTest.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.tests.resources;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is a parameterized test to validate all model in the plugin
+ *
+ * @author Benoit Maggi
+ */
+@SuppressWarnings("nls")
+@RunWith(Parameterized.class)
+public class ModelValidationTest {
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ {"/model/gmfdiag-common.elementtypesconfigurations"},
+ {"/model/notation.elementtypesconfigurations"},
+ });
+ }
+
+ private String modelPath;
+
+ public ModelValidationTest(String modelPath) {
+ this.modelPath = modelPath;
+ }
+
+ /**
+ * Validate the model with the rules defined in the meta-model tooling
+ */
+ @Test
+ public void validateModel() {
+ String fullPath = "org.eclipse.papyrus.infra.gmfdiag.common"+ this.modelPath;
+ URI modelPlatformURI = URI.createPlatformPluginURI(fullPath, true);
+ Resource resource = new ResourceSetImpl().getResource(modelPlatformURI, true);
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ Assert.assertEquals("The "+modelPath+" model is invalid "+print(diagnostic), Diagnostic.OK, diagnostic.getSeverity());
+ }
+
+ // FIXME : Something should exist in API to do that
+ private String print(Diagnostic diagnostic) {
+ List<Diagnostic> children = diagnostic.getChildren();
+ StringBuilder stringBuilder = new StringBuilder(diagnostic.getMessage());
+ for (Diagnostic diagnosticChildren : children) {
+ stringBuilder.append("\n"); //$NON-NLS-1$
+ stringBuilder.append(diagnosticChildren.getMessage());
+ }
+ return stringBuilder.toString();
+ }
+
+}
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/TestModelValidationTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/TestModelValidationTest.java
new file mode 100644
index 00000000000..b1020bf9335
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/tests/resources/TestModelValidationTest.java
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.tests.resources;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.papyrus.infra.types.core.registries.ElementTypeSetConfigurationRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is a parameterized test to validate all model in the plugin
+ *
+ * @author Benoit Maggi
+ */
+@SuppressWarnings("nls")
+@RunWith(Parameterized.class)
+public class TestModelValidationTest {
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ {"/models/AddBorderItem.expansionmodel"}, //
+ {"/models/AddChildLabel.expansionmodel"}, //
+ {"/models/AddCompartment.expansionmodel"},
+ {"/models/AddCompartmentWithKind.expansionmodel"},
+ {"/models/AddLink.expansionmodel"}, //
+ /* TODO :the 3 following models are invalid
+ * It may be expected (deduced from 'Bad' prefix)
+ * If so:
+ * - replace bad by Invalid
+ * - setup custom test to check that the correct diganostic is done
+ */
+ //{"/models/BadContextExpansion.expansionmodel"}, //
+ //{"/models/BadElementTypeForExpansion.expansionmodel"},
+ //{"/models/BadProviderForExpansion.expansionmodel"},
+ {"/models/MyChildLabelAssistant.assistants"},
+ {"/models/NullExpansion.expansionmodel"},
+ {"/models/TestExpansionDiagram.elementtypesconfigurations"},
+ });
+ }
+
+ private String modelPath;
+
+ public TestModelValidationTest(String modelPath) {
+ this.modelPath = modelPath;
+ }
+
+ @BeforeClass
+ public static void loadElementTypeSet(){
+ ElementTypeSetConfigurationRegistry.getInstance();
+ }
+
+ /**
+ * Validate the model with the rules defined in the meta-model tooling
+ */
+ @Test
+ public void validateModel() {
+ String fullPath = "org.eclipse.papyrus.infra.gmfdiag.common.tests"+ this.modelPath;
+ URI modelPlatformURI = URI.createPlatformPluginURI(fullPath, true);
+ Resource resource = new ResourceSetImpl().getResource(modelPlatformURI, true);
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ Assert.assertEquals("The "+modelPath+" model is invalid "+print(diagnostic), Diagnostic.OK, diagnostic.getSeverity());
+ }
+
+ // FIXME : Something should exist in API to do that
+ private String print(Diagnostic diagnostic) {
+ List<Diagnostic> children = diagnostic.getChildren();
+ StringBuilder stringBuilder = new StringBuilder(diagnostic.getMessage());
+ for (Diagnostic diagnosticChildren : children) {
+ stringBuilder.append("\n"); //$NON-NLS-1$
+ stringBuilder.append(diagnosticChildren.getMessage());
+ }
+ return stringBuilder.toString();
+ }
+
+}
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/ClassifierViewFactory.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/ClassifierViewFactory.java
index 4d2f46fff41..137770abbb1 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/ClassifierViewFactory.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common.tests/src/org/eclipse/papyrus/infra/gmfdiag/common/utils/ClassifierViewFactory.java
@@ -31,18 +31,18 @@ import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCom
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart;
/**
- *
* extraction from class diagram UML view Provider
*
*/
public class ClassifierViewFactory implements ViewFactory {
+ @Override
public View createView(IAdaptable semanticAdapter, View containerView, String semanticHint, int index,
boolean persisted, PreferencesHint preferencesHint) {
- return createClass_Shape((EObject) semanticAdapter.getAdapter(EObject.class), containerView, semanticHint, index, persisted, preferencesHint);
+ return createClassShape((EObject) semanticAdapter.getAdapter(EObject.class), containerView, semanticHint, index, persisted);
}
- public Node createClass_Shape(EObject domainElement, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createClassShape(EObject domainElement, View containerView, String semanticHint, int index, boolean persisted) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
node.setType(semanticHint);
@@ -50,15 +50,15 @@ public class ClassifierViewFactory implements ViewFactory {
node.setElement(domainElement);
// initializeFromPreferences
- Node classNamelabel = createLabel(node, ClassNameEditPart.VISUAL_ID);
+ createLabel(node, ClassNameEditPart.VISUAL_ID);
Node classFloatingNamelabel = createLabel(node, ClassFloatingNameEditPart.VISUAL_ID);
classFloatingNamelabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
Location classFloatingNameLabelLocation = (Location) classFloatingNamelabel.getLayoutConstraint();
classFloatingNameLabelLocation.setX(0);
classFloatingNameLabelLocation.setY(5);
- createCompartment(node, ClassAttributeCompartmentEditPart.VISUAL_ID, true, true, true, true);
- createCompartment(node, ClassOperationCompartmentEditPart.VISUAL_ID, true, true, true, true);
- createCompartment(node, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, true, true, true, true);
+ createCompartment(node, ClassAttributeCompartmentEditPart.VISUAL_ID, true, true, true);
+ createCompartment(node, ClassOperationCompartmentEditPart.VISUAL_ID, true, true, true);
+ createCompartment(node, ClassNestedClassifierCompartmentEditPart.VISUAL_ID, true, true, true);
return node;
}
@@ -69,10 +69,7 @@ public class ClassifierViewFactory implements ViewFactory {
return rv;
}
- protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
- // SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
- // rv.setShowTitle(showTitle);
- // rv.setCollapsed(isCollapsed);
+ protected Node createCompartment(View owner, String hint, boolean hasTitle, boolean canSort, boolean canFilter) {
Node rv = NotationFactory.eINSTANCE.createBasicCompartment();
rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
index 5ccea442a14..38db3791ca3 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
@@ -24,15 +24,24 @@ import org.eclipse.papyrus.uml.modelexplorer.tests.paste.CutPasteModelExplorerTe
import org.eclipse.papyrus.uml.modelexplorer.tests.paste.DiagramCopyPasteModelExplorerTest;
import org.eclipse.papyrus.uml.modelexplorer.tests.paste.StereotypeCopyPasteModelExplorerTest;
import org.eclipse.papyrus.uml.modelexplorer.tests.paste.TableCopyPasteModelExplorerTest;
+import org.eclipse.papyrus.uml.modelexplorer.tests.resources.ModelValidationTest;
import org.junit.runner.RunWith;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(ClassificationSuite.class)
-@SuiteClasses({ //
-DeleteModelExplorerTest.class, RenameHandlerTest.class, ModelExplorerViewTests.class, CutPasteModelExplorerTest.class, CopyPasteModelExplorerTest.class, //
-DiagramCopyPasteModelExplorerTest.class, TableCopyPasteModelExplorerTest.class, StereotypeCopyPasteModelExplorerTest.class, //
-AdvancedModeTest.class })
+@SuiteClasses({
+ DeleteModelExplorerTest.class,
+ RenameHandlerTest.class,
+ ModelExplorerViewTests.class,
+ CutPasteModelExplorerTest.class,
+ CopyPasteModelExplorerTest.class,
+ DiagramCopyPasteModelExplorerTest.class,
+ TableCopyPasteModelExplorerTest.class,
+ StereotypeCopyPasteModelExplorerTest.class,
+ AdvancedModeTest.class,
+ ModelValidationTest.class
+ })
public class AllTests {
// JUnit for test suite
}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/resources/ModelValidationTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/resources/ModelValidationTest.java
new file mode 100644
index 00000000000..3cf237c5ef0
--- /dev/null
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/resources/ModelValidationTest.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.modelexplorer.tests.resources;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is a parameterized test to validate all model in the plugin
+ *
+ * @author Benoit Maggi
+ */
+@SuppressWarnings("nls")
+@RunWith(Parameterized.class)
+public class ModelValidationTest {
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] {
+ // FIXME model should be valid {"/resource/CustomizableUMLLabel.custom"},
+ // FIXME model should be valid {"/resource/SimpleUML.custom"},
+ // FIXME model should be valid {"/resource/StereotypeDisplay.custom"},
+ {"/resource/UML.creationmenumodel"},
+ {"/resource/UMLEdges.creationmenumodel"},
+ });
+ }
+
+ private String modelPath;
+
+ public ModelValidationTest(String modelPath) {
+ this.modelPath = modelPath;
+ }
+
+ /**
+ * Validate the model with the rules defined in the meta-model tooling
+ */
+ @Test
+ public void validateModel() {
+ String fullPath = "org.eclipse.papyrus.uml.modelexplorer"+ this.modelPath;
+ URI modelPlatformURI = URI.createPlatformPluginURI(fullPath, true);
+ Resource resource = new ResourceSetImpl().getResource(modelPlatformURI, true);
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ Assert.assertEquals("The "+modelPath+" model is invalid "+print(diagnostic), Diagnostic.OK, diagnostic.getSeverity());
+ }
+
+ // FIXME : Something should exist in API to do that
+ private String print(Diagnostic diagnostic) {
+ List<Diagnostic> children = diagnostic.getChildren();
+ StringBuilder stringBuilder = new StringBuilder(diagnostic.getMessage());
+ for (Diagnostic diagnosticChildren : children) {
+ stringBuilder.append("\n"); //$NON-NLS-1$
+ stringBuilder.append(diagnosticChildren.getMessage());
+ }
+ return stringBuilder.toString();
+ }
+
+}

Back to the top