diff options
author | Benoit Maggi | 2017-09-07 12:29:02 +0000 |
---|---|---|
committer | Benoit Maggi | 2017-09-07 12:29:02 +0000 |
commit | b17beb38df83897cc36857678365d1ebc0eeaf30 (patch) | |
tree | c3a09be56277b2815fd6e5dce18844d54eefbb43 | |
parent | cc2b1b7c9019138d6f29eae0db174f3c720016dd (diff) | |
download | org.eclipse.papyrus-b17beb38df83897cc36857678365d1ebc0eeaf30.tar.gz org.eclipse.papyrus-b17beb38df83897cc36857678365d1ebc0eeaf30.tar.xz org.eclipse.papyrus-b17beb38df83897cc36857678365d1ebc0eeaf30.zip |
Bug 521957 - [Class diagram, Use case, Composite] Fix palette in these
diagrams
- add test, documentation to detect generation that override association
palette in class diagram
Change-Id: I998f094339ee7133f272e1ba5abacf634bc28f07
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
6 files changed, 206 insertions, 1 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/README.md b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/README.md new file mode 100755 index 00000000000..a57b02d8549 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/README.md @@ -0,0 +1,9 @@ +org.eclipse.papyrus.uml.diagram.clazz +====================== + +#Diagram generation +* Check general information here https://wiki.eclipse.org/Papyrus_Developer_Guide/Papyrus_diagram_generation +* /!\ : Associations in palette should be manually updated after the generation +** or org.eclipse.papyrus.uml.diagram.clazz.test.resources.ClassPaletteTest will fail +** that's bad and generator should be improved +** still please don't break association (*again*)
\ No newline at end of file diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF index 1c1d3e4cbf8..5f43d33f3c0 100755 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/META-INF/MANIFEST.MF @@ -31,7 +31,12 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.uml.service.types;bundle-version="[3.1.0,4.0.0)"
Export-Package: org.eclipse.papyrus.uml.diagram.clazz.test,
org.eclipse.papyrus.uml.diagram.clazz.test.canonical,
+ org.eclipse.papyrus.uml.diagram.clazz.test.copyPaste,
+ org.eclipse.papyrus.uml.diagram.clazz.test.dnd,
+ org.eclipse.papyrus.uml.diagram.clazz.test.legacy,
org.eclipse.papyrus.uml.diagram.clazz.test.load,
+ org.eclipse.papyrus.uml.diagram.clazz.test.resources,
+ org.eclipse.papyrus.uml.diagram.clazz.test.tests,
org.eclipse.papyrus.uml.diagram.clazz.tests.generation
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java index 28f7e49b67d..08e3b4667aa 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/AllTests.java @@ -20,6 +20,8 @@ import org.eclipse.papyrus.uml.diagram.clazz.test.canonical.TestClassDiagram; import org.eclipse.papyrus.uml.diagram.clazz.test.copyPaste.ConstraintPasteStrategyTest; import org.eclipse.papyrus.uml.diagram.clazz.test.dnd.DragAndDropAssociationsTest; import org.eclipse.papyrus.uml.diagram.clazz.test.legacy.PackageDiagramLegacyTest; +import org.eclipse.papyrus.uml.diagram.clazz.test.resources.ClassPaletteTest; +import org.eclipse.papyrus.uml.diagram.clazz.test.resources.ModelValidationTest; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug382954_InstanceSpecificationLink; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug476872_MoveCommandTest; import org.eclipse.papyrus.uml.diagram.clazz.test.tests.Bug481317_MoveGeneralizationTest; @@ -43,9 +45,11 @@ import org.junit.runners.Suite.SuiteClasses; Bug476872_MoveCommandTest.class, Bug481317_MoveGeneralizationTest.class, MoveContentsTest.class, - DragAndDropAssociationsTest.class + DragAndDropAssociationsTest.class, // load // LoadTests.class + ClassPaletteTest.class, + ModelValidationTest.class }) @DynamicClasses("org.eclipse.papyrus.uml.diagram.clazz.test.AllGenTests") diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ClassPaletteTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ClassPaletteTest.java new file mode 100755 index 00000000000..805cc46941a --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ClassPaletteTest.java @@ -0,0 +1,86 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST 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.diagram.clazz.test.resources; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +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.impl.ResourceSetImpl; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ChildConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.DrawerConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ElementDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.LeafConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.StackConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ToolConfiguration; +import org.eclipse.papyrus.infra.types.ElementTypeConfiguration; +import org.eclipse.papyrus.infra.types.core.registries.ElementTypeSetConfigurationRegistry; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Check palette for class diagram + */ +@SuppressWarnings("nls") +public class ClassPaletteTest { + + @Before + public void loadElementTypeRegistry() { + ElementTypeSetConfigurationRegistry.getInstance(); + } + + /** + * Check that association isn't overridden by regeneration + */ + @Test + public void checkPaletteIds() { + URI createPlatformPluginURI = URI.createPlatformPluginURI("org.eclipse.papyrus.uml.diagram.clazz/model/PapyrusUMLClassDiagram.paletteconfiguration", true); + ResourceSetImpl resourceSetImpl = new ResourceSetImpl(); + Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true); + + TreeIterator<EObject> allContents = resource.getAllContents(); + while (allContents.hasNext()) { + EObject eObject = (EObject) allContents.next(); + if (eObject instanceof PaletteConfiguration) { + PaletteConfiguration p = (PaletteConfiguration) eObject; + EList<DrawerConfiguration> drawerConfigurations = p.getDrawerConfigurations(); + for (DrawerConfiguration drawerConfiguration : drawerConfigurations) { + EList<ChildConfiguration> ownedConfigurations = drawerConfiguration.getOwnedConfigurations(); + for (ChildConfiguration childConfiguration : ownedConfigurations) { + + if (childConfiguration instanceof StackConfiguration) { + StackConfiguration stackConfiguration = (StackConfiguration) childConfiguration; + + EList<LeafConfiguration> leafs = stackConfiguration.getOwnedConfigurations(); + for (LeafConfiguration leafConfiguration : leafs) { + if (leafConfiguration instanceof ToolConfiguration) { + ToolConfiguration toolConfiguration = (ToolConfiguration) leafConfiguration; + EList<ElementDescriptor> elementDescriptors = toolConfiguration.getElementDescriptors(); + for (ElementDescriptor elementDescriptor : elementDescriptors) { + ElementTypeConfiguration elementType = elementDescriptor.getElementType(); + Assert.assertNotEquals("Association_Edge shouldn't be refered in Palette check class plugin README.md", "org.eclipse.papyrus.umldi.Association_Edge", elementType.getIdentifier()); + } + } + } + } + } + } + } + } + } + +} diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ModelValidationTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ModelValidationTest.java new file mode 100755 index 00000000000..9dae3f163e4 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/ModelValidationTest.java @@ -0,0 +1,80 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST 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.diagram.clazz.test.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.uml.diagram.clazz.part.UMLDiagramEditorPlugin; +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/PapyrusUMLClassDiagram.paletteconfiguration"}, + //FIXME should be valid {"/model/classdiagram.assistants"}, + {"/model/classdiagram.elementtypesconfigurations"}, + //FIXME should be valid : Missing GmfGEn Metamodel {"/model/classdiagram.gmfgen"}, + }); + } + + 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 = UMLDiagramEditorPlugin.ID + 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/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/package-info.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/package-info.java new file mode 100755 index 00000000000..b795a4fa421 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz.tests/test/org/eclipse/papyrus/uml/diagram/clazz/test/resources/package-info.java @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST 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 + * + *****************************************************************************/ + +/** + * Store here all tests on resources (Not Java API) + * - model + * - icons + * + * @author Benoit Maggi + */ +package org.eclipse.papyrus.uml.diagram.clazz.test.resources;
\ No newline at end of file |