diff options
author | Remi Schnekenburger | 2015-10-21 13:05:32 +0000 |
---|---|---|
committer | Remi Schnekenburger | 2015-10-21 13:06:07 +0000 |
commit | 670c178932ebba945048df8da61b6db534c3f82b (patch) | |
tree | 5c5a0e8a912ea14b8025cfae4e24031d3afce13b /tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse | |
parent | c7c1b10ac3d638e4f0014384f30a9aabe3f8e971 (diff) | |
download | org.eclipse.papyrus-rt-670c178932ebba945048df8da61b6db534c3f82b.tar.gz org.eclipse.papyrus-rt-670c178932ebba945048df8da61b6db534c3f82b.tar.xz org.eclipse.papyrus-rt-670c178932ebba945048df8da61b6db534c3f82b.zip |
469825: [UML-RT] Inconsistent default naming of UML-RT Protocol and its
internal elements
https://bugs.eclipse.org/bugs/show_bug.cgi?id=469825
- adding a test (annotated with @failingTest annotation) to check
protocol, protocolcontainer and messageset names
Change-Id: Ibca6011c7f7cba172e329cadeec2335f10cd128d
Diffstat (limited to 'tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse')
2 files changed, 91 insertions, 12 deletions
diff --git a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateElementTest.java b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateElementTest.java index 1fb33f920..1e5bb2996 100644 --- a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateElementTest.java +++ b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateElementTest.java @@ -50,6 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.infra.services.edit.utils.IRequestCacheEntries; +import org.eclipse.papyrus.junit.framework.classification.FailingTest; import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest; import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils; import org.eclipse.papyrus.junit.utils.rules.HouseKeeper; @@ -78,25 +79,25 @@ public class CreateElementTest extends AbstractPapyrusTest { @ClassRule public static final HouseKeeper.Static houseKeeper = new HouseKeeper.Static(); - private static IProject createProject; + protected static IProject createProject; - private static IFile copyPapyrusModel; + protected static IFile copyPapyrusModel; - private static IMultiDiagramEditor openPapyrusEditor; + protected static IMultiDiagramEditor openPapyrusEditor; - private static ModelSet modelset; + protected static ModelSet modelset; - private static UmlModel umlIModel; + protected static UmlModel umlIModel; - private static Model rootModel; + protected static Model rootModel; - private static TransactionalEditingDomain transactionalEditingDomain; + protected static TransactionalEditingDomain transactionalEditingDomain; - private static Package protocolContainer; + protected static Package protocolContainer; - private static Collaboration protocol; + protected static Collaboration protocol; - private static Interface messageSetIn; + protected static Interface messageSetIn; /** * Init test class @@ -155,7 +156,7 @@ public class CreateElementTest extends AbstractPapyrusTest { /** * Init fields corresponding to element in the test model */ - private static void initExistingElements() throws Exception { + protected static void initExistingElements() throws Exception { protocolContainer = (Package) rootModel.getPackagedElement(null, false, UMLPackage.eINSTANCE.getPackage(), false); Assert.assertNotNull(protocolContainer); @@ -219,8 +220,9 @@ public class CreateElementTest extends AbstractPapyrusTest { } @Test + @FailingTest public void testCreateProtocolInModel() throws Exception { - runCreationTest(rootModel, UMLRTElementTypesEnumerator.PROTOCOL, true); + runCreationTestWithGetContext(rootModel, UMLRTElementTypesEnumerator.PROTOCOL, true, CreateProtocolOnModelValidation.class); } @Test diff --git a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateProtocolOnModelValidation.java b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateProtocolOnModelValidation.java new file mode 100644 index 000000000..a8d9b1a7d --- /dev/null +++ b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateProtocolOnModelValidation.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2014 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.papyrusrt.umlrt.core.tests.creation; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrusrt.umlrt.core.types.ElementTypeUtils; +import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes; +import org.eclipse.papyrusrt.umlrt.core.utils.ProtocolContainerUtils; +import org.eclipse.uml2.uml.Collaboration; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.Assert; + +/** + * Additional validation rules for Protocol created on a model + */ +public class CreateProtocolOnModelValidation implements IValidationRule { + + /** + * {@inheritDoc} + */ + @Override + public void validatePostCreation(Element targetContainer, Object[] commandResults) throws Exception { + Assert.assertEquals("comand result should not be empty", 1, commandResults.length); + Object result = commandResults[0]; + Assert.assertTrue("new element should be an EObject", result instanceof EObject); + Assert.assertTrue("new element should be a protocol", ElementTypeUtils.matches((EObject) result, IUMLRTElementTypes.PROTOCOL_ID)); + + Collaboration protocol = (Collaboration) result; + /* checkProtocol */ + // name + Assert.assertEquals("Protocol1", protocol.getName()); + // other? + + /* check protocolcontainer */ + Element owner = protocol.getOwner(); + Assert.assertTrue("Container of the protcol should be a ProtocolContainer", ElementTypeUtils.matches(owner, IUMLRTElementTypes.PROTOCOL_CONTAINER_ID)); + Package protocolContainer = (Package) owner; + // check name + Assert.assertEquals("Protocol1", protocolContainer.getName()); + + Interface messageSetIn = ProtocolContainerUtils.getMessageSetIn(protocolContainer); + Assert.assertNotNull(messageSetIn); + Assert.assertEquals("Protocol1", messageSetIn.getName()); + + Interface messageSetOut = ProtocolContainerUtils.getMessageSetOut(protocolContainer); + Assert.assertNotNull(messageSetOut); + Assert.assertEquals("Protocol1~", messageSetOut.getName()); + + Interface messageSetInOut = ProtocolContainerUtils.getMessageSetInOut(protocolContainer); + Assert.assertNotNull(messageSetInOut); + Assert.assertEquals("Protocol1IO", messageSetInOut.getName()); + + } + + /** + * {@inheritDoc} + */ + @Override + public void validatePostUndo(Element targetContainer, Object[] commandResults) throws Exception { + // targetcontainer should be a package + Assert.assertTrue(targetContainer instanceof Package); + Assert.assertNull(((Package) targetContainer).getPackagedElement("Protocol1", false, UMLPackage.eINSTANCE.getPackage(), false)); + } + +} |