diff options
author | Arthur Daussy | 2014-07-01 15:29:29 +0000 |
---|---|---|
committer | Mikael Barbero | 2014-07-07 12:26:07 +0000 |
commit | 4c60210fd4816f1923d4c48826941d2caf5792ef (patch) | |
tree | ea4565f91b01e5fb5d524f7aed52c223b7b1c1bb | |
parent | 6474b03e2bb42855895d4a0736451d1aabc16b08 (diff) | |
download | org.eclipse.emf.compare-4c60210fd4816f1923d4c48826941d2caf5792ef.tar.gz org.eclipse.emf.compare-4c60210fd4816f1923d4c48826941d2caf5792ef.tar.xz org.eclipse.emf.compare-4c60210fd4816f1923d4c48826941d2caf5792ef.zip |
Test integration of profiles in EMF Compare.
Adds two tests to test the display of static and dynamic profile in EMF
Compare.
Change-Id: Ide7245bf03651e1850b481cd6b39183ef6b25902
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
20 files changed, 537 insertions, 33 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.papyrus.tests/src/org/eclipse/emf/compare/diagram/papyrus/tests/groups/PapyrusDifferencesOrderTest.java b/plugins/org.eclipse.emf.compare.diagram.papyrus.tests/src/org/eclipse/emf/compare/diagram/papyrus/tests/groups/PapyrusDifferencesOrderTest.java index c0acf5262..de13701d6 100644 --- a/plugins/org.eclipse.emf.compare.diagram.papyrus.tests/src/org/eclipse/emf/compare/diagram/papyrus/tests/groups/PapyrusDifferencesOrderTest.java +++ b/plugins/org.eclipse.emf.compare.diagram.papyrus.tests/src/org/eclipse/emf/compare/diagram/papyrus/tests/groups/PapyrusDifferencesOrderTest.java @@ -131,9 +131,9 @@ public class PapyrusDifferencesOrderTest extends AbstractDifferenceOrderTest { // Uncomment the following lines to reserialize the expected model // TestWriterHelper writerHelper = createTestHelper(); - // writerHelper.createExpectedModel(PATH_TO_MODEL_FILE+"/expectedResult_DiagRefineOff.nodes", roots); + // writerHelper.createExpectedModel(PATH_TO_MODEL_FILE+"/expectedResult_DiagRefineOff.nodes", roots,false); - compareTree(expectedResultData.getExpectedReseultWithFilterOff(), roots); + compareTree(expectedResultData.getExpectedReseultWithFilterOff(), roots, false); } @Test @@ -149,7 +149,7 @@ public class PapyrusDifferencesOrderTest extends AbstractDifferenceOrderTest { // TestWriterHelper writerHelper = createTestHelper(); // writerHelper.createExpectedModel(PATH_TO_MODEL_FILE+"/expectedResult_DiagRefineOn.nodes", roots); - compareTree(expectedResultData.getExpectedReseultWithFilterOn(), roots); + compareTree(expectedResultData.getExpectedReseultWithFilterOn(), roots,false); } /** diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF index 4c2f150ac..6b4db5afc 100644 --- a/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF @@ -36,11 +36,11 @@ Export-Package: org.eclipse.emf.compare.rcp.ui, org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl;x-friends:="org.eclipse.emf.compare.ide.ui", org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.actions;x-friends:="org.eclipse.emf.compare.ide.ui", org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", - org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests", + org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups;x-friends:="org.eclipse.emf.compare.ide.ui", org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.extender;x-friends:="org.eclipse.emf.compare.ide.ui", - org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests", - org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests", + org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", + org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", org.eclipse.emf.compare.rcp.ui.internal.util;x-friends:="org.eclipse.emf.compare.ide.ui", org.eclipse.emf.compare.rcp.ui.mergeviewer, org.eclipse.emf.compare.rcp.ui.mergeviewer.item, diff --git a/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF index 7732a622f..498fa67f5 100644 --- a/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.edit/META-INF/MANIFEST.MF @@ -23,5 +23,5 @@ Import-Package: com.google.common.base;version="[11.0.0,16.0.0)", com.google.common.collect;version="[11.0.0,16.0.0)", org.eclipse.emf.compare.provider Export-Package: org.eclipse.emf.compare.uml2.internal.provider;x-internal:=true, - org.eclipse.emf.compare.uml2.internal.provider.custom;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests", - org.eclipse.emf.compare.uml2.internal.provider.decorator;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.tests" + org.eclipse.emf.compare.uml2.internal.provider.custom;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", + org.eclipse.emf.compare.uml2.internal.provider.decorator;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests" diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF index 59aeb761c..4bf6974a2 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/META-INF/MANIFEST.MF @@ -13,7 +13,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.emf.compare.tests;bundle-version="3.1.0", org.eclipse.emf.compare.uml2.edit;bundle-version="2.2.0", org.eclipse.uml2.uml.edit;bundle-version="5.0.0", - org.eclipse.emf.compare.uml2.rcp.ui;bundle-version="2.2.0" + org.eclipse.emf.compare.uml2.rcp.ui;bundle-version="2.2.0", + org.eclipse.uml2.uml.resources, + org.eclipse.emf.compare.uml2.tests Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/pom.xml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/pom.xml index d361c9553..99ba8c995 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/pom.xml +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/pom.xml @@ -23,8 +23,8 @@ <includes> <include>org/eclipse/emf/compare/uml2/rcp/ui/tests/suite/AllTests.class</include> </includes> - <useUIHarness>false</useUIHarness> - <useUIThread>false</useUIThread> + <useUIHarness>true</useUIHarness> + <useUIThread>true</useUIThread> <appArgLine>-Xmx1024m -XX:MaxPermSize=256m</appArgLine> </configuration> </plugin> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java index 41f0d0d0d..3d0a0c493 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/AbstractDifferenceOrderTest.java @@ -38,8 +38,10 @@ import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.Stru import org.eclipse.emf.compare.scope.DefaultComparisonScope; import org.eclipse.emf.compare.scope.IComparisonScope; import org.eclipse.emf.compare.tests.nodes.Node; +import org.eclipse.emf.compare.tests.nodes.NodeSingleValueAttribute; import org.eclipse.emf.compare.tests.nodes.NodesFactory; import org.eclipse.emf.compare.tests.nodes.util.NodesResourceFactoryImpl; +import org.eclipse.emf.compare.uml2.tests.edit.provider.StereotypedElementItemProviderTestUtil; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.resource.Resource; @@ -121,8 +123,11 @@ public abstract class AbstractDifferenceOrderTest { * Resource holding a Nodes models. This "nodes" model represent the expected. * @param actualTrees * Actual trees that the viewer would display (without any filter being applied). + * @param testIcons + * Set to true if the icon of each element should be checked. */ - protected void compareTree(Resource expectedResult, List<? extends TreeNode> actualTrees) { + protected void compareTree(Resource expectedResult, List<? extends TreeNode> actualTrees, + boolean testIcons) { List<? extends TreeNode> nonFilteredActualRoot = Lists.newArrayList(Collections2.filter(actualTrees, viewerFilterPredicate)); EList<EObject> expectedContent = expectedResult.getContents(); @@ -136,12 +141,13 @@ public abstract class AbstractDifferenceOrderTest { final Iterator<EObject> realIterator = Iterators.filter(actualRoot.eAllContents(), viewerFilterPredicate); // Compares - compareTree(expectedIterator, realIterator); + compareTree(expectedIterator, realIterator, testIcons); } } - private void compareTree(TreeIterator<EObject> expectedIterator, final Iterator<EObject> realIterator) { + private void compareTree(TreeIterator<EObject> expectedIterator, final Iterator<EObject> realIterator, + boolean testIcons) { while (expectedIterator.hasNext()) { Node expectedElement = (Node)expectedIterator.next(); Assert.assertTrue("No match for element " + expectedElement.getName(), realIterator.hasNext()); //$NON-NLS-1$ @@ -150,6 +156,15 @@ public abstract class AbstractDifferenceOrderTest { // Checks same name. Assert.assertEquals(getErrorMessage(actualElem), expectedElement.getName(), itemDelegator .getText(actualElem)); + if (testIcons) { + // Checks correct icon + Assert.assertTrue(expectedElement instanceof NodeSingleValueAttribute); + List<String> actualIcons = StereotypedElementItemProviderTestUtil + .getIconsLocation(itemDelegator.getImage(actualElem)); + Assert.assertEquals("Wrong icon on " + expectedElement.getName(), //$NON-NLS-1$ + ((NodeSingleValueAttribute)expectedElement).getSingleValuedAttribute(), Joiner + .on(',').join(actualIcons)); + } if (expectedElement.eContainer() != null) { final Collection<Node> expectedChildren = expectedElement.getContainmentRef1(); // Checks same number of children. @@ -288,13 +303,15 @@ public abstract class AbstractDifferenceOrderTest { * Location of newly created file will be serialized. * @param roots * Lists of roots to serialize in the model. + * @param fillIcon + * Set to true if the generated model should keep track of the element icons. */ - public void createExpectedModel(String fileLocation, List<? extends TreeNode> roots) { + public void createExpectedModel(String fileLocation, List<? extends TreeNode> roots, boolean fillIcon) { URI fileURI = URI.createFileURI(fileLocation); Resource.Factory resourceFactory = new NodesResourceFactoryImpl(); // resourceFactory cannot be null Resource res = resourceFactory.createResource(fileURI); - fillTree(res, roots); + fillTree(res, roots, fillIcon); try { res.save(Collections.EMPTY_MAP); } catch (IOException e) { @@ -310,26 +327,38 @@ public abstract class AbstractDifferenceOrderTest { * </p> * * @param n + * @param saveIcon + * Set to true if the icon name should be serialized in the model * @return */ - private Node createNode(TreeNode n) { + private Node createNode(TreeNode n, boolean saveIcon) { Node newNode = null; if (viewerFilterPredicate.apply(n)) { - newNode = NodesFactory.eINSTANCE.createNode(); + if (saveIcon) { + newNode = NodesFactory.eINSTANCE.createNodeSingleValueAttribute(); + } else { + newNode = NodesFactory.eINSTANCE.createNode(); + } newNode.setName(itemDelegator.getText(n)); for (TreeNode child : n.getChildren()) { - Node createNode = createNode(child); + Node createNode = createNode(child, saveIcon); if (createNode != null) { newNode.getContainmentRef1().add(createNode); } } + if (saveIcon) { + // Save the icon name to test the picture + Object icon = itemDelegator.getImage(n); + ((NodeSingleValueAttribute)newNode).setSingleValuedAttribute(Joiner.on(',').join( + StereotypedElementItemProviderTestUtil.getIconsLocation(icon))); + } } return newNode; } - private void fillTree(Resource resource, List<? extends TreeNode> roots) { + private void fillTree(Resource resource, List<? extends TreeNode> roots, boolean fillIcon) { for (TreeNode n : roots) { - Node createNode = createNode(n); + Node createNode = createNode(n, fillIcon); if (createNode != null) { resource.getContents().add(createNode); } diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java index 4e408dc58..8edefb6f5 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/groups/UMLDifferencesOrderTest.java @@ -48,7 +48,6 @@ import org.junit.Test; * * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> */ -@SuppressWarnings("restriction") public class UMLDifferencesOrderTest extends AbstractDifferenceOrderTest { private ExpectedResultData expectedResult; @@ -101,9 +100,9 @@ public class UMLDifferencesOrderTest extends AbstractDifferenceOrderTest { List<? extends TreeNode> roots = group.getChildren(); // Uncomment the following lines to reserialize the expected model // TestWriterHelper writerHelper = createTestHelper(); - // writerHelper.createExpectedModel("PATH_TO_MODEL_FILE/expectedResult.nodes", roots); + // writerHelper.createExpectedModel("PATH_TO_MODEL_FILE/expectedResult.nodes", roots,false); - compareTree(expectedResult.getExpectedResultWithoutFilter(), roots); + compareTree(expectedResult.getExpectedResultWithoutFilter(), roots, false); } @@ -125,7 +124,7 @@ public class UMLDifferencesOrderTest extends AbstractDifferenceOrderTest { // writerHelper.createExpectedModel("PATH_TO_MODEL_FILE/expectedResultWithUMLRefineElement.nodes", // roots); - compareTree(expectedResult.getExpectedResultWithFilter(), roots); + compareTree(expectedResult.getExpectedResultWithFilter(), roots, false); } diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/DynamicProfileIntegrationDisplayTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/DynamicProfileIntegrationDisplayTest.java new file mode 100644 index 000000000..1431066fa --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/DynamicProfileIntegrationDisplayTest.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * Copyright (c) 2014 Obeo. + * 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.emf.compare.uml2.rcp.ui.tests.profile; + +import static com.google.common.base.Predicates.alwaysTrue; + +import com.google.common.collect.Lists; + +import java.io.IOException; +import java.util.List; +import java.util.regex.Pattern; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.compare.postprocessor.BasicPostProcessorDescriptorImpl; +import org.eclipse.emf.compare.postprocessor.IPostProcessor; +import org.eclipse.emf.compare.postprocessor.PostProcessorDescriptorRegistryImpl; +import org.eclipse.emf.compare.provider.spec.CompareItemProviderAdapterFactorySpec; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.CascadingDifferencesFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.EmptyMatchedResourcesFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.IdenticalElementsFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.BasicDifferenceGroupImpl; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeItemProviderAdapterFactorySpec; +import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroup; +import org.eclipse.emf.compare.tests.framework.AbstractInputData; +import org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor; +import org.eclipse.emf.compare.uml2.internal.postprocessor.UMLPostProcessor; +import org.eclipse.emf.compare.uml2.internal.provider.custom.ProfileIntegrationItemProviderAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.custom.UMLCompareCustomItemProviderAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLCompareItemProviderDecoratorAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLProfileItemProviderAdapterFactoryDecorator; +import org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.UML2CompareTestProfilePackage; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.structuremergeviewer.filters.UMLRefinedElementsFilter; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.groups.AbstractDifferenceOrderTest; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.groups.NotifierScopeProvider; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.tree.TreeNode; +import org.eclipse.uml2.uml.UMLPlugin; +import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Tests the display (label and icon) of UML elements on a model with a dynamic profile applied. + * <p> + * This test uses the full integration of profile in EMF Compare. That is to say: + * <ul> + * <li>The integration of {@link ProfileIntegrationItemProviderAdapterFactory}</li> + * <li>The integration of {@link StereotypedElementChangePostProcessor}</li> + * </ul> + * </p> + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ +public class DynamicProfileIntegrationDisplayTest extends AbstractDifferenceOrderTest { + + static URI registeredURI; + + static Object registeredPackage; + + @BeforeClass + public static void addProfilePathmap() { + registeredURI = UMLPlugin.getEPackageNsURIToProfileLocationMap().remove( + UML2CompareTestProfilePackage.eNS_URI); + registeredPackage = EPackage.Registry.INSTANCE.remove(UML2CompareTestProfilePackage.eNS_URI); + } + + @AfterClass + public static void resetProfilePathmap() { + UMLPlugin.getEPackageNsURIToProfileLocationMap().put(UML2CompareTestProfilePackage.eNS_URI, + registeredURI); + EPackage.Registry.INSTANCE.put(UML2CompareTestProfilePackage.eNS_URI, registeredPackage); + } + + @Override + protected IPostProcessor.Descriptor.Registry<?> getPostProcessorRegistry() { + PostProcessorDescriptorRegistryImpl<Object> postProcessorRegistry = new PostProcessorDescriptorRegistryImpl<Object>(); + BasicPostProcessorDescriptorImpl umlPostProcessor = new BasicPostProcessorDescriptorImpl( + new UMLPostProcessor(), Pattern.compile("http://www.eclipse.org/uml2/\\d.0.0/UML"), null); //$NON-NLS-1$ + postProcessorRegistry.put(UMLPostProcessor.class.getName(), umlPostProcessor); + BasicPostProcessorDescriptorImpl stereotypeElementPostProcessor = new BasicPostProcessorDescriptorImpl( + new StereotypedElementChangePostProcessor(), Pattern + .compile("http://www.eclipse.org/uml2/\\d.0.0/UML"), null); //$NON-NLS-1$ + postProcessorRegistry.put(StereotypedElementChangePostProcessor.class.getName(), + stereotypeElementPostProcessor); + return postProcessorRegistry; + } + + @Override + protected List<AdapterFactory> getAdaptersFactory() { + return Lists.<AdapterFactory> newArrayList(new ProfileIntegrationItemProviderAdapterFactory(), + new UMLProfileItemProviderAdapterFactoryDecorator(), + new CompareItemProviderAdapterFactorySpec(), new TreeItemProviderAdapterFactorySpec(), + new UMLCompareCustomItemProviderAdapterFactory(), new UMLItemProviderAdapterFactory(), + new UMLCompareItemProviderDecoratorAdapterFactory(), + new ReflectiveItemProviderAdapterFactory()); + } + + @Override + protected NotifierScopeProvider getInput() { + return new DataInput(); + } + + @Test + public void testDynamicProfileElementDisplay() throws IOException { + getFilter().addFilter(new UMLRefinedElementsFilter()); + getFilter().addFilter(new EmptyMatchedResourcesFilter()); + getFilter().addFilter(new IdenticalElementsFilter()); + getFilter().addFilter(new CascadingDifferencesFilter()); + + IDifferenceGroup group = new BasicDifferenceGroupImpl(getComparison(), alwaysTrue(), + getCrossReferenceAdapter()); + List<? extends TreeNode> roots = group.getChildren(); + + // Uncomment the following lines to reserialize the expected model + // TestWriterHelper writerHelper = createTestHelper(); + // writerHelper + // .createExpectedModel( + // "{$Git_REPO_PATH}/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/expectedResult.nodes", + // roots, true); + + compareTree(new ExpectedResult().getExpectedResult(), roots, true); + } + + /** + * Input data for this test. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ + private static class DataInput extends AbstractUMLInputData implements NotifierScopeProvider { + + public Resource getLeft() throws IOException { + return loadFromClassLoader("data/dynamic/left.uml");//$NON-NLS-1$ + } + + public Resource getRight() throws IOException { + return loadFromClassLoader("data/dynamic/right.uml");//$NON-NLS-1$ + } + + public Notifier getOrigin() throws IOException { + return null; + } + } + + /** + * Expected result data for this test. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ + private static class ExpectedResult extends AbstractInputData { + + public Resource getExpectedResult() throws IOException { + return loadFromClassLoader("data/dynamic/expectedResult.nodes");//$NON-NLS-1$ + } + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/StaticProfileIntegrationDisplayTest.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/StaticProfileIntegrationDisplayTest.java new file mode 100644 index 000000000..a53c07160 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/StaticProfileIntegrationDisplayTest.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * Copyright (c) 2014 Obeo. + * 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.emf.compare.uml2.rcp.ui.tests.profile; + +import static com.google.common.base.Predicates.alwaysTrue; + +import com.google.common.collect.Lists; + +import java.io.IOException; +import java.util.List; +import java.util.regex.Pattern; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.compare.postprocessor.BasicPostProcessorDescriptorImpl; +import org.eclipse.emf.compare.postprocessor.IPostProcessor; +import org.eclipse.emf.compare.postprocessor.PostProcessorDescriptorRegistryImpl; +import org.eclipse.emf.compare.provider.spec.CompareItemProviderAdapterFactorySpec; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.CascadingDifferencesFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.EmptyMatchedResourcesFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.IdenticalElementsFilter; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.BasicDifferenceGroupImpl; +import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeItemProviderAdapterFactorySpec; +import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroup; +import org.eclipse.emf.compare.tests.framework.AbstractInputData; +import org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor; +import org.eclipse.emf.compare.uml2.internal.postprocessor.UMLPostProcessor; +import org.eclipse.emf.compare.uml2.internal.provider.custom.ProfileIntegrationItemProviderAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.custom.UMLCompareCustomItemProviderAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLCompareItemProviderDecoratorAdapterFactory; +import org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLProfileItemProviderAdapterFactoryDecorator; +import org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.provider.UML2CompareTestProfileItemProviderAdapterFactory; +import org.eclipse.emf.compare.uml2.rcp.ui.internal.structuremergeviewer.filters.UMLRefinedElementsFilter; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.groups.AbstractDifferenceOrderTest; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.groups.NotifierScopeProvider; +import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.tree.TreeNode; +import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory; +import org.junit.Test; + +/** + * Tests the display (label and icon) of UML elements on a model with a static profile applied. + * <p> + * This test uses the full integration of profiles in EMF Compare. That is to say: + * <ul> + * <li>The integration of {@link ProfileIntegrationItemProviderAdapterFactory}</li> + * <li>The integration of {@link StereotypedElementChangePostProcessor}</li> + * </ul> + * </p> + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ +public class StaticProfileIntegrationDisplayTest extends AbstractDifferenceOrderTest { + + @Override + protected IPostProcessor.Descriptor.Registry<?> getPostProcessorRegistry() { + PostProcessorDescriptorRegistryImpl<Object> postProcessorRegistry = new PostProcessorDescriptorRegistryImpl<Object>(); + BasicPostProcessorDescriptorImpl umlPostProcessor = new BasicPostProcessorDescriptorImpl( + new UMLPostProcessor(), Pattern.compile("http://www.eclipse.org/uml2/\\d.0.0/UML"), null); //$NON-NLS-1$ + postProcessorRegistry.put(UMLPostProcessor.class.getName(), umlPostProcessor); + BasicPostProcessorDescriptorImpl stereotypeElementPostProcessor = new BasicPostProcessorDescriptorImpl( + new StereotypedElementChangePostProcessor(), Pattern + .compile("http://www.eclipse.org/uml2/\\d.0.0/UML"), null); //$NON-NLS-1$ + postProcessorRegistry.put(StereotypedElementChangePostProcessor.class.getName(), + stereotypeElementPostProcessor); + return postProcessorRegistry; + } + + @Override + protected List<AdapterFactory> getAdaptersFactory() { + // Adds UML2CompareTestProfileItemProviderAdapterFactory item adapter factory to use the custom icon + // defined in it. + return Lists.<AdapterFactory> newArrayList(new ProfileIntegrationItemProviderAdapterFactory(), + new UMLProfileItemProviderAdapterFactoryDecorator(), + new CompareItemProviderAdapterFactorySpec(), new TreeItemProviderAdapterFactorySpec(), + new UMLCompareCustomItemProviderAdapterFactory(), + new UML2CompareTestProfileItemProviderAdapterFactory(), new UMLItemProviderAdapterFactory(), + new UMLCompareItemProviderDecoratorAdapterFactory(), + new ReflectiveItemProviderAdapterFactory()); + } + + @Override + protected NotifierScopeProvider getInput() { + return new DataInput(); + } + + @Test + public void testStaticProfileDisplay() throws IOException { + getFilter().addFilter(new UMLRefinedElementsFilter()); + getFilter().addFilter(new EmptyMatchedResourcesFilter()); + getFilter().addFilter(new IdenticalElementsFilter()); + getFilter().addFilter(new CascadingDifferencesFilter()); + + IDifferenceGroup group = new BasicDifferenceGroupImpl(getComparison(), alwaysTrue(), + getCrossReferenceAdapter()); + List<? extends TreeNode> roots = group.getChildren(); + // Uncomment the following lines to reserialize the expected model + // TestWriterHelper writerHelper = createTestHelper(); + // writerHelper + // .createExpectedModel( + // "{$Git_REPO_PATH}/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/expectedResult.nodes", + // roots, true); + + compareTree(new ExpectedResult().getExpectedResult(), roots, true); + } + + /** + * Input data for this test. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ + private static class DataInput extends AbstractUMLInputData implements NotifierScopeProvider { + + public Resource getLeft() throws IOException { + return loadFromClassLoader("data/static_/left.uml");//$NON-NLS-1$ + } + + public Resource getRight() throws IOException { + return loadFromClassLoader("data/static_/right.uml");//$NON-NLS-1$ + } + + public Notifier getOrigin() throws IOException { + return null; + } + } + + /** + * Expected result data for this test. + * + * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> + */ + private static class ExpectedResult extends AbstractInputData { + + public Resource getExpectedResult() throws IOException { + return loadFromClassLoader("data/static_/expectedResult.nodes");//$NON-NLS-1$ + } + } + +} diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/expectedResult.nodes b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/expectedResult.nodes new file mode 100644 index 000000000..7833647d2 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/expectedResult.nodes @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="ASCII"?> +<nodes:NodeSingleValueAttribute xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_ZXd1sAEbEeSEjKYb5Aambw" name="<Model> model" singleValuedAttribute="Model.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC8AEbEeSEjKYb5Aambw" name="<Class> NormalClass" singleValuedAttribute="Class.gif,VisibilityKind_protected.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC8QEbEeSEjKYb5Aambw" name="<Property> newProperty [ownedAttribute add]" singleValuedAttribute="Property.gif,add_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC8gEbEeSEjKYb5Aambw" name="protected [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC8wEbEeSEjKYb5Aambw" name="true [isLeaf changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC9AEbEeSEjKYb5Aambw" name="<ACliche> ACliche_Element" singleValuedAttribute="eclipse_luna.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC9QEbEeSEjKYb5Aambw" name="<ACliche2> ACliche2_Element [singleValuedReference changed]" singleValuedAttribute="Class.gif,VisibilityKind_package.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC9gEbEeSEjKYb5Aambw" name="<ACliche3> ACliche3_Element [manyValuedReference delete]" singleValuedAttribute="Class.gif,del_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC9wEbEeSEjKYb5Aambw" name="cliche attribute value [New] [singleValuedAttribute changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC-AEbEeSEjKYb5Aambw" name="Value3 [manyValuedAttribute add]" singleValuedAttribute="AttributeChange.gif,add_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC-QEbEeSEjKYb5Aambw" name="<ACliche2> ACliche2_Element" singleValuedAttribute="Class.gif,VisibilityKind_package.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC-gEbEeSEjKYb5Aambw" name="package [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC-wEbEeSEjKYb5Aambw" name="<ACliche3> ACliche3_Element [manyValuedReference add]" singleValuedAttribute="Class.gif,VisibilityKind_private.gif,add_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC_AEbEeSEjKYb5Aambw" name="Setting of value [singleValuedAttribute set]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC_QEbEeSEjKYb5Aambw" name="Value1 [manyValuedAttribute add]" singleValuedAttribute="AttributeChange.gif,add_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC_gEbEeSEjKYb5Aambw" name="<ACliche3> ACliche3_Element" singleValuedAttribute="Class.gif,VisibilityKind_private.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_ZXqC_wEbEeSEjKYb5Aambw" name="private [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + </containmentRef1> +</nodes:NodeSingleValueAttribute> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/left.uml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/left.uml new file mode 100644 index 000000000..1895f11c8 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/left.uml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"> + <uml:Model xmi:id="_vjD-8P3KEeOpqsVKyPHM4g" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_0QWNcP3KEeOpqsVKyPHM4g" name="NormalClass" visibility="protected" isLeaf="true"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_cUc_kP3LEeOpqsVKyPHM4g" name="newProperty"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_03lzoP3KEeOpqsVKyPHM4g" name="ACliche_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_3QMCsP3KEeOpqsVKyPHM4g" name="ACliche2_Element" visibility="package"/> + <packagedElement xmi:type="uml:Class" xmi:id="_4Fer8P3KEeOpqsVKyPHM4g" name="ACliche3_Element" visibility="private"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_znNJ0P3KEeOpqsVKyPHM4g"> + <eAnnotations xmi:id="_zonfEP3KEeOpqsVKyPHM4g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"/> + </eAnnotations> + <appliedProfile href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche3 xmi:id="_BwKBgP3LEeOpqsVKyPHM4g" base_Class="_4Fer8P3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche2 xmi:id="_CWWe0P3LEeOpqsVKyPHM4g" singleValuedAttribute="Setting of value" manyValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" base_Class="_3QMCsP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + </testProfile:ACliche2> + <testProfile:ACliche xmi:id="_C-EmIP3LEeOpqsVKyPHM4g" singleValuedAttribute="cliche attribute value [New]" singleValuedReference="_3QMCsP3KEeOpqsVKyPHM4g" base_Class="_03lzoP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + <manyValuedAttribute>Value2</manyValuedAttribute> + <manyValuedAttribute>Value3</manyValuedAttribute> + </testProfile:ACliche> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/right.uml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/right.uml new file mode 100644 index 000000000..1d258e06a --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/dynamic/right.uml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"> + <uml:Model xmi:id="_vjD-8P3KEeOpqsVKyPHM4g" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_0QWNcP3KEeOpqsVKyPHM4g" name="NormalClass"/> + <packagedElement xmi:type="uml:Class" xmi:id="_03lzoP3KEeOpqsVKyPHM4g" name="ACliche_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_3QMCsP3KEeOpqsVKyPHM4g" name="ACliche2_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_4Fer8P3KEeOpqsVKyPHM4g" name="ACliche3_Element"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_znNJ0P3KEeOpqsVKyPHM4g"> + <eAnnotations xmi:id="_zonfEP3KEeOpqsVKyPHM4g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_59tLoPU0EeOznPU7N6uHbQ"/> + </eAnnotations> + <appliedProfile href="pathmap://UML_COMPARE_TESTS_PROFILE/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche3 xmi:id="_BwKBgP3LEeOpqsVKyPHM4g" base_Class="_4Fer8P3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche2 xmi:id="_CWWe0P3LEeOpqsVKyPHM4g" base_Class="_3QMCsP3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche xmi:id="_C-EmIP3LEeOpqsVKyPHM4g" singleValuedAttribute="cliche attribute value" singleValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" manyValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" base_Class="_03lzoP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + <manyValuedAttribute>Value2</manyValuedAttribute> + </testProfile:ACliche> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/expectedResult.nodes b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/expectedResult.nodes new file mode 100644 index 000000000..70267aee7 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/expectedResult.nodes @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="ASCII"?> +<nodes:NodeSingleValueAttribute xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_Wfl-wAEdEeSL9_utQEgyiQ" name="<Model> model" singleValuedAttribute="Model.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjMAEdEeSL9_utQEgyiQ" name="<Class> NormalClass" singleValuedAttribute="Class.gif,VisibilityKind_protected.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjMQEdEeSL9_utQEgyiQ" name="<Property> newProperty [ownedAttribute add]" singleValuedAttribute="Property.gif,add_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjMgEdEeSL9_utQEgyiQ" name="protected [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjMwEdEeSL9_utQEgyiQ" name="true [isLeaf changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjNAEdEeSL9_utQEgyiQ" name="<ACliche> ACliche_Element" singleValuedAttribute="eclipse_luna.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjNQEdEeSL9_utQEgyiQ" name="<ACliche2> ACliche2_Element [singleValuedReference changed]" singleValuedAttribute="eclipse_kepler.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjNgEdEeSL9_utQEgyiQ" name="<ACliche3> ACliche3_Element [manyValuedReference delete]" singleValuedAttribute="ACliche3.gif,del_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjNwEdEeSL9_utQEgyiQ" name="cliche attribute value [New] [singleValuedAttribute changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjOAEdEeSL9_utQEgyiQ" name="Value3 [manyValuedAttribute add]" singleValuedAttribute="AttributeChange.gif,add_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjOQEdEeSL9_utQEgyiQ" name="<ACliche2> ACliche2_Element" singleValuedAttribute="eclipse_kepler.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjOgEdEeSL9_utQEgyiQ" name="package [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjOwEdEeSL9_utQEgyiQ" name="<ACliche3> ACliche3_Element [manyValuedReference add]" singleValuedAttribute="ACliche3.gif,add_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjPAEdEeSL9_utQEgyiQ" name="Setting of value [singleValuedAttribute set]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjPQEdEeSL9_utQEgyiQ" name="Value1 [manyValuedAttribute add]" singleValuedAttribute="AttributeChange.gif,add_ov.gif"/> + </containmentRef1> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjPgEdEeSL9_utQEgyiQ" name="<ACliche3> ACliche3_Element" singleValuedAttribute="ACliche3.gif,match_ov.gif"> + <containmentRef1 xsi:type="nodes:NodeSingleValueAttribute" xmi:id="_WgHjPwEdEeSL9_utQEgyiQ" name="private [visibility changed]" singleValuedAttribute="AttributeChange.gif,chg_ov.gif"/> + </containmentRef1> +</nodes:NodeSingleValueAttribute> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/left.uml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/left.uml new file mode 100644 index 000000000..c40f2b10e --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/left.uml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_vjD-8P3KEeOpqsVKyPHM4g" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_0QWNcP3KEeOpqsVKyPHM4g" name="NormalClass" visibility="protected" isLeaf="true"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_cUc_kP3LEeOpqsVKyPHM4g" name="newProperty"/> + </packagedElement> + <packagedElement xmi:type="uml:Class" xmi:id="_03lzoP3KEeOpqsVKyPHM4g" name="ACliche_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_3QMCsP3KEeOpqsVKyPHM4g" name="ACliche2_Element" visibility="package"/> + <packagedElement xmi:type="uml:Class" xmi:id="_4Fer8P3KEeOpqsVKyPHM4g" name="ACliche3_Element" visibility="private"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_znNJ0P3KEeOpqsVKyPHM4g"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_zonfEP3KEeOpqsVKyPHM4g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://EMF_Compare_Test_profile/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche3 xmi:id="_BwKBgP3LEeOpqsVKyPHM4g" base_Class="_4Fer8P3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche2 xmi:id="_CWWe0P3LEeOpqsVKyPHM4g" singleValuedAttribute="Setting of value" manyValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" base_Class="_3QMCsP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + </testProfile:ACliche2> + <testProfile:ACliche xmi:id="_C-EmIP3LEeOpqsVKyPHM4g" singleValuedAttribute="cliche attribute value [New]" singleValuedReference="_3QMCsP3KEeOpqsVKyPHM4g" base_Class="_03lzoP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + <manyValuedAttribute>Value2</manyValuedAttribute> + <manyValuedAttribute>Value3</manyValuedAttribute> + </testProfile:ACliche> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/right.uml b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/right.uml new file mode 100644 index 000000000..a315acb43 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/profile/data/static_/right.uml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML"> + <uml:Model xmi:id="_vjD-8P3KEeOpqsVKyPHM4g" name="model"> + <packagedElement xmi:type="uml:Class" xmi:id="_0QWNcP3KEeOpqsVKyPHM4g" name="NormalClass"/> + <packagedElement xmi:type="uml:Class" xmi:id="_03lzoP3KEeOpqsVKyPHM4g" name="ACliche_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_3QMCsP3KEeOpqsVKyPHM4g" name="ACliche2_Element"/> + <packagedElement xmi:type="uml:Class" xmi:id="_4Fer8P3KEeOpqsVKyPHM4g" name="ACliche3_Element"/> + <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_znNJ0P3KEeOpqsVKyPHM4g"> + <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_zonfEP3KEeOpqsVKyPHM4g" source="http://www.eclipse.org/uml2/2.0.0/UML"> + <references xmi:type="ecore:EPackage" href="http://www.eclipse.org/emf/compare/uml2/1.0.0/testprofile#/"/> + </eAnnotations> + <appliedProfile xmi:type="uml:Profile" href="pathmap://EMF_Compare_Test_profile/uml2.compare.testprofile.profile.uml#_hZFTgIwkEeC_FYHMbTTxXw"/> + </profileApplication> + </uml:Model> + <testProfile:ACliche3 xmi:id="_BwKBgP3LEeOpqsVKyPHM4g" base_Class="_4Fer8P3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche2 xmi:id="_CWWe0P3LEeOpqsVKyPHM4g" base_Class="_3QMCsP3KEeOpqsVKyPHM4g"/> + <testProfile:ACliche xmi:id="_C-EmIP3LEeOpqsVKyPHM4g" singleValuedAttribute="cliche attribute value" singleValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" manyValuedReference="_4Fer8P3KEeOpqsVKyPHM4g" base_Class="_03lzoP3KEeOpqsVKyPHM4g"> + <manyValuedAttribute>Value1</manyValuedAttribute> + <manyValuedAttribute>Value2</manyValuedAttribute> + </testProfile:ACliche> +</xmi:XMI> diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/suite/AllTests.java index 91d671e68..b6335d66e 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/suite/AllTests.java +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui.tests/src/org/eclipse/emf/compare/uml2/rcp/ui/tests/suite/AllTests.java @@ -15,6 +15,8 @@ import junit.framework.Test; import junit.textui.TestRunner; import org.eclipse.emf.compare.uml2.rcp.ui.tests.groups.UMLDifferencesOrderTest; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.profile.DynamicProfileIntegrationDisplayTest; +import org.eclipse.emf.compare.uml2.rcp.ui.tests.profile.StaticProfileIntegrationDisplayTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @@ -25,7 +27,8 @@ import org.junit.runners.Suite.SuiteClasses; * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a> */ @RunWith(Suite.class) -@SuiteClasses(UMLDifferencesOrderTest.class) +@SuiteClasses({UMLDifferencesOrderTest.class, DynamicProfileIntegrationDisplayTest.class, + StaticProfileIntegrationDisplayTest.class }) public class AllTests { /** diff --git a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF index 0c7f20cbe..a3f0703bd 100644 --- a/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.rcp.ui/META-INF/MANIFEST.MF @@ -18,4 +18,4 @@ Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Export-Package: org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor;x-internal:=true, org.eclipse.emf.compare.uml2.rcp.ui.internal.accessor.factory;x-internal:=true, - org.eclipse.emf.compare.uml2.rcp.ui.internal.structuremergeviewer.filters;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests" + org.eclipse.emf.compare.uml2.rcp.ui.internal.structuremergeviewer.filters;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests" diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF index d499ab301..15d2bcc3b 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2.tests/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Export-Package: org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl, org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.provider, org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.util, - org.eclipse.emf.compare.uml2.tests + org.eclipse.emf.compare.uml2.tests, + org.eclipse.emf.compare.uml2.tests.edit.provider Require-Bundle: org.eclipse.core.runtime, org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.uml2.uml;bundle-version="5.0.0";visibility:=reexport, diff --git a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/edit/provider/StereotypedElementItemProviderTestUtil.java b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/edit/provider/StereotypedElementItemProviderTestUtil.java index 9823ce6cc..70bf7b55f 100644 --- a/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/edit/provider/StereotypedElementItemProviderTestUtil.java +++ b/plugins/org.eclipse.emf.compare.uml2.tests/src/org/eclipse/emf/compare/uml2/tests/edit/provider/StereotypedElementItemProviderTestUtil.java @@ -37,7 +37,9 @@ import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Stereotype; /** - * Util class for testing the {@link org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLProfileItemProviderAdapterFactoryDecorator}. + * Util class for testing the + * {@link org.eclipse.emf.compare.uml2.internal.provider.decorator.UMLProfileItemProviderAdapterFactoryDecorator} + * . * * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a> */ @@ -70,8 +72,7 @@ public class StereotypedElementItemProviderTestUtil { assertEquals(1, actualIcons.size()); assertEquals( "Wrong icon for stereotypes :" + generateExpectedIconKey(appliedStereotypes), //$NON-NLS-1$ - getExpectedIcon(appliedStereotypes, expectedStaticIcons), actualIcons - .get(0)); + getExpectedIcon(appliedStereotypes, expectedStaticIcons), actualIcons.get(0)); } else { assertNotNull(itemLabelProvider); assertTrue("Wrong item provider for object " + itemLabelProvider.getText(eObject), //$NON-NLS-1$ @@ -95,7 +96,17 @@ public class StereotypedElementItemProviderTestUtil { return Joiner.on(',').join(Iterables.transform(stereotypes, TO_NAME_FUNCTION)); } - private static List<String> getIconsLocation(Object icon) { + /** + * Retrieves the name of each icon from the object returned by an item provider. + * <p> + * The name of an icon is only the last segment of its full path location + * </p> + * + * @param icon + * Object returned by the {@link org.eclipse.emf.edit.provider.ItemProvider#getImage()} method. + * @return A list of name of icon. + */ + public static List<String> getIconsLocation(Object icon) { final List<String> result = Lists.newArrayList(); if (icon instanceof ComposedImage) { for (Object image : ((ComposedImage)icon).getImages()) { diff --git a/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF index 8580004df..df176912e 100644 --- a/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.compare.uml2/META-INF/MANIFEST.MF @@ -28,7 +28,7 @@ Export-Package: org.eclipse.emf.compare.uml2.internal; org.eclipse.emf.compare.uml2.rcp.ui, org.eclipse.emf.compare.uml2.tests", org.eclipse.emf.compare.uml2.internal.merge;x-internal:=true, - org.eclipse.emf.compare.uml2.internal.postprocessor;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.tests", + org.eclipse.emf.compare.uml2.internal.postprocessor;x-friends:="org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests", org.eclipse.emf.compare.uml2.internal.postprocessor.extension;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz;x-internal:=true, org.eclipse.emf.compare.uml2.internal.postprocessor.extension.profile;x-internal:=true, |