Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2017-12-22 08:57:28 +0000
committerPierre-Charles David2018-01-31 10:44:59 +0000
commit8e2dccede576215216a8295095cb2160885916b1 (patch)
treee25ba969f2d383c8adf8046f6d6c3d6daf954fad
parent9c043a88f5016c5107861c79032f0b6291c0fb6e (diff)
downloadorg.eclipse.sirius-8e2dccede576215216a8295095cb2160885916b1.tar.gz
org.eclipse.sirius-8e2dccede576215216a8295095cb2160885916b1.tar.xz
org.eclipse.sirius-8e2dccede576215216a8295095cb2160885916b1.zip
[525533] Complete Color tests.
Add tests for DiagramPackage. Allow declaration of color references not required and without initialization. Bug: 525533 Change-Id: Iacb69ea5f2f2b3a6e3ac193396bdb110f30cdf78 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractColorReferenceTestCase.java11
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java4
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/DiagramColorTest.java28
3 files changed, 39 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractColorReferenceTestCase.java b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractColorReferenceTestCase.java
index ed0daf1508..c706fae40a 100644
--- a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractColorReferenceTestCase.java
+++ b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractColorReferenceTestCase.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2012, 2014 THALES GLOBAL SERVICES
+ * Copyright (c) 2012, 2017 THALES GLOBAL SERVICES
* 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
@@ -28,6 +28,8 @@ import com.google.common.collect.Iterables;
import junit.framework.TestCase;
+import junit.framework.TestCase;
+
/**
* Test cardinality and initialization of Color references.
*
@@ -39,6 +41,9 @@ public abstract class AbstractColorReferenceTestCase extends TestCase {
private Collection<EClass> classesWithColorReferences;
+ // Specific color references : non required and without initalization.
+ private Collection<EReference> specialColorRefs = new ArrayList<>();
+
private EPackage basePackage;
private final Predicate<EReference> isColorReference = new Predicate<EReference>() {
@@ -91,7 +96,7 @@ public abstract class AbstractColorReferenceTestCase extends TestCase {
Predicate<EReference> shouldBeRequired = new Predicate<EReference>() {
@Override
public boolean apply(EReference input) {
- return !input.isRequired();
+ return !input.isRequired() && !specialColorRefs.contains(input);
}
};
@@ -107,7 +112,7 @@ public abstract class AbstractColorReferenceTestCase extends TestCase {
for (EClass clazz : classesWithColorReferences) {
EObject created = EcoreUtil.create(clazz);
for (EReference colorRef : Iterables.filter(clazz.getEAllReferences(), isColorReference)) {
- if (!created.eIsSet(colorRef) || created.eGet(colorRef) == null) {
+ if ((!created.eIsSet(colorRef) || created.eGet(colorRef) == null) && !specialColorRefs.contains(colorRef)) {
sb.append(" . " + clazz.getName() + "#" + colorRef.getName() + "\n");
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
index a89da69241..0fbe647c3e 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES.
* 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
@@ -37,6 +37,7 @@ import org.eclipse.sirius.tests.unit.diagram.views.session.ResourceFolderItemTes
import org.eclipse.sirius.tests.unit.diagram.views.session.ResourceItemTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.ViewpointItemTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.ViewpointsFolderItemTest;
+import org.eclipse.sirius.tests.unit.diagram.vsm.DiagramColorTest;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
@@ -84,6 +85,7 @@ public class AllDiagramStandaloneTests {
suite.addTestSuite(ChangeContextOperationTest.class);
suite.addTestSuite(DDiagramDAnnotationTest.class);
suite.addTestSuite(DDiagramElementSynchronizerTest.class);
+ suite.addTestSuite(DiagramColorTest.class);
suite.addTest(AllSequenceDiagramsStandaloneTests.suite());
// Ecore modeler services
suite.addTest(new JUnit4TestAdapter(EcoreServiceTest.class));
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/DiagramColorTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/DiagramColorTest.java
new file mode 100644
index 0000000000..b19d0743bc
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/vsm/DiagramColorTest.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.unit.diagram.vsm;
+
+import org.eclipse.sirius.diagram.DiagramPackage;
+import org.eclipse.sirius.tests.support.api.AbstractColorReferenceTestCase;
+
+/**
+ * Test cardinality and initialization of Color references of meta-model Sequence.
+ *
+ * @author mporhel
+ */
+public class DiagramColorTest extends AbstractColorReferenceTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ setBasePackage(DiagramPackage.eINSTANCE);
+ super.setUp();
+ }
+}

Back to the top