Skip to main content
summaryrefslogtreecommitdiffstats
blob: 37d64a8764b81d94e5c3a63c5ed14ce86fa49a8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*******************************************************************************
 * 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.tests.edit.provider;

import com.google.common.collect.Lists;

import java.io.IOException;
import java.util.HashMap;
import java.util.regex.Pattern;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.tests.postprocess.data.TestPostProcessor;
import org.eclipse.emf.compare.uml2.internal.postprocessor.StereotypedElementChangePostProcessor;
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.tests.AbstractStaticProfileTest;
import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData;
import org.eclipse.emf.compare.uml2.tests.edit.provider.data.ModelInputData;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Tests the {@link UMLProfileItemProviderAdapterFactoryDecorator} on a model with a static profile.
 * 
 * @author <a href="mailto:arthur.daussy@obeo.fr">Arthur Daussy</a>
 */
public class StaticStereotypedElementItemProviderTest extends AbstractStaticProfileTest {

	private ModelInputData inputData = new ModelInputData();

	@BeforeClass
	public static void setupClass() {
		fillRegistriesForStatic();
	}

	@AfterClass
	public static void teardownClass() {
		resetRegistriesForStatic();
	}

	@Override
	protected AbstractUMLInputData getInput() {
		return inputData;
	}

	@Override
	protected void registerPostProcessors(
			org.eclipse.emf.compare.postprocessor.IPostProcessor.Descriptor.Registry<String> postProcessorRegistry) {
		super.registerPostProcessors(postProcessorRegistry);
		postProcessorRegistry.put(StereotypedElementChangePostProcessor.class.getName(),
				new TestPostProcessor.TestPostProcessorDescriptor(Pattern
						.compile("http://www.eclipse.org/uml2/\\d\\.0\\.0/UML"), null, //$NON-NLS-1$
						new StereotypedElementChangePostProcessor(), 25));
	}

	@Before
	@Override
	public void before() {
		super.before();
	}

	@Test
	public void testIconsAndLabelsStaticProfile() throws IOException {
		AdapterFactory stereotypedElementItemProviderDecorator = new ComposedAdapterFactory(Lists
				.<AdapterFactory> newArrayList(new UMLProfileItemProviderAdapterFactoryDecorator(),
						new UML2CompareTestProfileItemProviderAdapterFactory()));

		// Map<Ordered list of applied stereotyped, Expected icon>
		HashMap<String, String> expectedStaticIcons = new HashMap<String, String>();
		expectedStaticIcons.put("ACliche", "eclipse_luna.gif"); //$NON-NLS-1$ //$NON-NLS-2$
		expectedStaticIcons.put("ACliche,ACliche2", "eclipse_luna.gif"); //$NON-NLS-1$//$NON-NLS-2$
		expectedStaticIcons.put("ACliche2,ACliche", "eclipse_kepler.gif"); //$NON-NLS-1$//$NON-NLS-2$
		expectedStaticIcons.put("ACliche2", "eclipse_kepler.gif"); //$NON-NLS-1$ //$NON-NLS-2$
		expectedStaticIcons.put("ACliche3", "ACliche3.gif"); //$NON-NLS-1$ //$NON-NLS-2$

		Resource resource = inputData.getStaticProfileModel();

		StereotypedElementItemProviderTestUtil.checkIconAndLabel(stereotypedElementItemProviderDecorator,
				expectedStaticIcons, resource);

	}

}

Back to the top