blob: 2e807e5dc7c081a5293128ab61d36067ccdff20a (
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
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
*
* 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.diagram.stereotypeproperty;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Profile;
import org.junit.Test;
public class TestProfileApplication extends AbstractPapyrusTestCase {
@Test
public void testToManageModel() throws ServiceException {
RegisteredProfile registeredProfile = RegisteredProfile.getRegisteredProfile("TestProfile");
final Model root = ((Model)getDiagramEditPart().resolveSemanticElement());
assertTrue("Registered profile not found", registeredProfile != null);
URI modelUri = registeredProfile.uri;
final Resource modelResource = Util.getResourceSet(root).getResource(modelUri, true);
assertTrue("the registered profile is not a profile", (modelResource.getContents().get(0) instanceof Profile));
assertTrue("strange profile", ("".equals(registeredProfile.qualifiednames)));
final Profile profile = (Profile)modelResource.getContents().get(0);
// PackageUtil.applyProfile(root,profile, false);
final TransactionalEditingDomain domain = ServiceUtils.getInstance().getTransactionalEditingDomain(papyrusEditor.getServicesRegistry());
AppliedProfileCommand appliedProfileCommand = new AppliedProfileCommand(domain, root, profile);
domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(appliedProfileCommand));
EList<Profile> list = root.getAllAppliedProfiles();
assertTrue("Profile not applied", root.getAllAppliedProfiles().size() == 1);
}
}
|