Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1ada10a27deff72afa1d5b2027487e319adbf7da (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
/*****************************************************************************
 * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, 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  benoit.maggi@cea.fr - Initial API and implementation
 *  Christian W. Damus - bug 485220
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.tools.utils.tests.tests;

import java.util.List;

import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.ModelSetFixture;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
import org.eclipse.papyrus.uml.tools.utils.NameResolutionHelper;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

@PluginResource("resources/recursiveModelImport.di")
public class NameResolutionHelperTest extends AbstractPapyrusTest {

	public final static String PACKAGE1_NAME = "Package1"; //$NON-NLS-1$

	public final static String PACKAGE2_NAME = "Package2"; //$NON-NLS-1$

	public final static String CLASS1_NAME = "Class1"; //$NON-NLS-1$

	public static final String PROJECT_NAME = "NameResolutionHelperTest"; //$NON-NLS-1$

	@Rule
	public final ModelSetFixture model = new ModelSetFixture();

	/**
	 * Check NameResolution on a recursive model
	 */
	@Test
	public void recursiveImportPackage() {
		Package rootUMLModel = model.getModel();
		Assert.assertNotNull("RootModel is null", rootUMLModel); //$NON-NLS-1$
		org.eclipse.uml2.uml.Package package1 = (org.eclipse.uml2.uml.Package) rootUMLModel.getPackagedElement(PACKAGE1_NAME);
		Assert.assertNotNull("The package 1 is not present", package1); //$NON-NLS-1$
		NameResolutionHelper nameResolutionHelper = new NameResolutionHelper(package1, null);
		List<NamedElement> namedElements = nameResolutionHelper.getNamedElements(PACKAGE1_NAME + NamedElementUtil.QUALIFIED_NAME_SEPARATOR + PACKAGE2_NAME + NamedElementUtil.QUALIFIED_NAME_SEPARATOR + CLASS1_NAME);
		Assert.assertNotNull("NamedElements is  null", namedElements); //$NON-NLS-1$
		Assert.assertFalse("NamedElements is empty", namedElements.isEmpty()); //$NON-NLS-1$
	}

}

Back to the top