diff options
author | Remi Schnekenburger | 2015-12-10 16:37:18 +0000 |
---|---|---|
committer | Remi Schnekenburger | 2015-12-10 16:37:18 +0000 |
commit | 36932e4d7849a607228807230984adf9ed3d19c5 (patch) | |
tree | f389dd56873cc1e916715565fb8f32a1e33b3160 /tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse | |
parent | d2abacf247952bcacb6cfefec77d3611d269e3b8 (diff) | |
download | org.eclipse.papyrus-rt-36932e4d7849a607228807230984adf9ed3d19c5.tar.gz org.eclipse.papyrus-rt-36932e4d7849a607228807230984adf9ed3d19c5.tar.xz org.eclipse.papyrus-rt-36932e4d7849a607228807230984adf9ed3d19c5.zip |
Bug 474486: [Core] CapsulePart should be protected by default
https://bugs.eclipse.org/bugs/show_bug.cgi?id=474486
Change-Id: I1653276749eb9bd8fb068a16357c652fb27a7fdd
Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr>
Diffstat (limited to 'tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse')
2 files changed, 55 insertions, 1 deletions
diff --git a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateCapsulePartInCapsuleValidation.java b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateCapsulePartInCapsuleValidation.java new file mode 100644 index 000000000..a8930af45 --- /dev/null +++ b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/creation/CreateCapsulePartInCapsuleValidation.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * 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 static org.junit.Assert.assertEquals; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrusrt.umlrt.core.tests.utils.IValidationRule; +import org.eclipse.papyrusrt.umlrt.core.types.ElementTypeUtils; +import org.eclipse.papyrusrt.umlrt.core.types.IUMLRTElementTypes; +import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.Capsule; +import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.CapsulePart; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.VisibilityKind; +import org.junit.Assert; + +/** + * Validation Rule for {@link CapsulePart} creation in a {@link Capsule} + */ +public class CreateCapsulePartInCapsuleValidation implements IValidationRule { + + /** + * {@inheritDoc} + */ + @Override + public void validatePostEdition(Element targetElement, 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 a Property", result instanceof Property); + Assert.assertTrue("new element should be a capsulePart", ElementTypeUtils.matches((EObject) result, IUMLRTElementTypes.CAPSULE_PART_ID)); + + Property capsulePart = (Property) result; + assertEquals(VisibilityKind.PROTECTED_LITERAL, capsulePart.getVisibility()); // see Bug 474486 + } + + /** + * {@inheritDoc} + */ + @Override + public void validatePostUndo(Element targetElement, Object[] commandResults) throws Exception { + // nothing specific here + } + +} 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 15d37c4ed..0094ca86e 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 @@ -140,7 +140,7 @@ public class CreateElementTest extends AbstractPapyrusRTCoreTest { @Test public void testCreateCapsulePartInCapsule() throws Exception { // test creation of CapsulePart in capsule0 - runCreationTest(capsule, UMLRTElementTypesEnumerator.CAPSULE_PART, true); + runCreationTestWithGetContext(capsule, UMLRTElementTypesEnumerator.CAPSULE_PART, true, CreateCapsulePartInCapsuleValidation.class); } @Test |