Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBelqassim Djafer2014-10-30 13:01:06 +0000
committerMaxime Porhel2014-11-25 15:16:09 +0000
commitc0255820a714445e22e3477760a7fad5daa5fc35 (patch)
treeaa389bb42a7c29e6fab2ac60ab77768f47df2c44
parentabc74e48ca5659297f00b825a7b4de3c52586a7f (diff)
downloadorg.eclipse.sirius-c0255820a714445e22e3477760a7fad5daa5fc35.tar.gz
org.eclipse.sirius-c0255820a714445e22e3477760a7fad5daa5fc35.tar.xz
org.eclipse.sirius-c0255820a714445e22e3477760a7fad5daa5fc35.zip
[449349] Tests for validation Domain class name in VSM
Two cases are checked : 1- Test VSM validation when the domain class name contains white spaces after, before or both. 2- Ensure that VSM validation checks the Domain class name and fails when the domain class name is invalid. Bug: 449349 Bug: 452286 Bug: 452287 Change-Id: I868c3d2c80f5213710ec685f2db903c738dbf5c4 Signed-off-by: Belqassim Djafer <belqassim.djafer@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/valideDomainClassVSM.odesign65
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMValidationTest.java106
2 files changed, 171 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/valideDomainClassVSM.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/valideDomainClassVSM.odesign
new file mode 100644
index 0000000000..f676757a96
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/valideDomainClassVSM.odesign
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:description_3="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" name="valideDomainClassVSM" version="8.1.0">
+ <ownedViewpoints>
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="class" domainClass="EClass">
+ <defaultLayer name="Default">
+ <containerMappings name="class1" domainClass="EClass">
+ <subContainerMappings name="attr1" semanticCandidatesExpression="feature:eAllContents" domainClass="EAttribute">
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </subContainerMappings>
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="class2" domainClass="EClass">
+ <subContainerMappings name="attr2" semanticCandidatesExpression="feature:eAllContents" domainClass="EAttribute">
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </subContainerMappings>
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="class3" domainClass="EClass">
+ <subContainerMappings name="attr3" semanticCandidatesExpression="feature:eAllContents" domainClass="EAttribute">
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </subContainerMappings>
+ <style xsi:type="style:FlatContainerStyleDescription">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <decorationDescriptionsSet>
+ <decorationDescriptions xsi:type="description:SemanticBasedDecoration" name="Deco" decoratorPath="\platform" domainClass="EClass"/>
+ </decorationDescriptionsSet>
+ </defaultLayer>
+ </ownedRepresentations>
+ <ownedRepresentations xsi:type="description_2:CrossTableDescription" name="CrossTable" domainClass="EPackage">
+ <ownedLineMappings name="Line" domainClass="EClass"/>
+ <ownedColumnMappings name="Column" domainClass="EClass"/>
+ </ownedRepresentations>
+ <ownedRepresentations xsi:type="description_3:TreeDescription" name="Tree" domainClass="EPackage"/>
+ </ownedViewpoints>
+</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMValidationTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMValidationTest.java
index 0a5ceb6ac1..a085121010 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMValidationTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/VSMValidationTest.java
@@ -11,7 +11,10 @@
package org.eclipse.sirius.tests.unit.diagram.vsm;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.Diagnostician;
@@ -32,11 +35,14 @@ public class VSMValidationTest extends SiriusDiagramTestCase {
private Group modelerWithDiagramExtension;
+ private Group modelerForDomainClassValidation;
+
public void setUp() throws Exception {
ResourceSet set = new ResourceSetImpl();
modeler = (Group) ModelUtils.load(URI.createPlatformPluginURI("/org.eclipse.sirius.tests.junit/data/unit/vsm/valideVSM.odesign", true), set);
modelerWithNoStyle = (Group) ModelUtils.load(URI.createPlatformPluginURI("/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVSMWithNoStyle.odesign", true), set);
modelerWithDiagramExtension = (Group) ModelUtils.load(URI.createPlatformPluginURI("/org.eclipse.sirius.tests.junit/data/unit/vsm/valideVSMWithDiagramExtension.odesign", true), set);
+ modelerForDomainClassValidation = (Group) ModelUtils.load(URI.createPlatformPluginURI("/org.eclipse.sirius.tests.junit/data/unit/vsm/valideDomainClassVSM.odesign", true), set);
}
/**
@@ -83,6 +89,106 @@ public class VSMValidationTest extends SiriusDiagramTestCase {
}
}
+ /**
+ * Test VSM validation when the domain class name contains white spaces
+ * after, before or both.
+ */
+ public void testValidationWithWhiteSpaceAfterAndBeforeDomainClassName() {
+ // Ensure that the domain class name contains white space (before, after
+ // or both).
+ TreeIterator<EObject> elements = modelerForDomainClassValidation.eAllContents();
+ // Variable to make choice between add space before (0), after
+ // (1) or both (2) domain class name
+ int i = 0;
+ while (elements.hasNext()) {
+ EObject current = elements.next();
+ for (EAttribute attribute : current.eClass().getEAllAttributes()) {
+ if ("domainClass".equals(attribute.getName())) {
+ addSpaceInDomainClassValue(current, attribute, i);
+ if (i < 2) {
+ i++;
+ } else {
+ i = 0;
+ }
+ }
+ }
+ }
+ // Test that the modeler is valid. In this case the modeler is valid, so
+ // test if diagnostic is ok.
+ Diagnostician diagnostician = new Diagnostician();
+ Diagnostic diagnostic = diagnostician.validate(modelerForDomainClassValidation);
+ assertEquals("The VSM is valid, it should not have popup error message", Diagnostic.OK, diagnostic.getSeverity());
+ }
+
+ /**
+ * Ensure that VSM validation check the Domain class name and fails when the
+ * domain class name is invalid.
+ */
+ public void testValidationDomainClass() {
+ // Ensure that the domain class name is invalid.
+ TreeIterator<EObject> elements = modelerForDomainClassValidation.eAllContents();
+ // variable to make choice between add chars before (0), after
+ // (1), both (2) or in the middle (3) of domain class name
+ int i = 0;
+ while (elements.hasNext()) {
+ EObject current = elements.next();
+ for (EAttribute attribute : current.eClass().getEAllAttributes()) {
+ if ("domainClass".equals(attribute.getName())) {
+ editDomainClassValue(current, attribute, i);
+ if (i < 3) {
+ i++;
+ } else {
+ i = 0;
+ }
+ }
+ }
+ }
+ // Test that the modeler is not valid. In this case the modeler is not
+ // valid, so Check that there is a pop up for validation problems.
+ Diagnostician diagnostician = new Diagnostician();
+ Diagnostic diagnostic = diagnostician.validate(modelerForDomainClassValidation);
+ assertEquals("The VSM is not valid, it should have popup error message", Diagnostic.ERROR, diagnostic.getSeverity());
+ }
+
+ private void addSpaceInDomainClassValue(EObject current, EAttribute attribute, int iterate) {
+
+ switch (iterate) {
+ case 0:
+ current.eSet(attribute, current.eGet(attribute) + " ");
+ break;
+ case 1:
+ current.eSet(attribute, " " + current.eGet(attribute));
+ break;
+ case 2:
+ current.eSet(attribute, " " + current.eGet(attribute) + " ");
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void editDomainClassValue(EObject current, EAttribute attribute, int iterate) {
+
+ switch (iterate) {
+ case 0:
+ current.eSet(attribute, "AAA");
+ break;
+ case 1:
+ current.eSet(attribute, "- " + current.eGet(attribute));
+ break;
+ case 2:
+ current.eSet(attribute, "1E" + current.eGet(attribute) + "./");
+ break;
+ case 3:
+ String value = current.eGet(attribute) + "";
+ value.replace(value.charAt(1), ' ');
+ current.eSet(attribute, value);
+ break;
+ default:
+ break;
+ }
+ }
+
public void tearDown() {
modeler = null;
}

Back to the top