Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2015-12-01 09:36:03 +0000
committerRemi Schnekenburger2015-12-01 09:36:03 +0000
commit869192996ecb2f57d9621a7bba9e67286a9ea9e5 (patch)
tree8703cb7162bc3e374d23f910f8011513641d576a /tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt
parentddcd1f216f7996d3252b45deb8d48784cf057a7e (diff)
downloadorg.eclipse.papyrus-rt-869192996ecb2f57d9621a7bba9e67286a9ea9e5.tar.gz
org.eclipse.papyrus-rt-869192996ecb2f57d9621a7bba9e67286a9ea9e5.tar.xz
org.eclipse.papyrus-rt-869192996ecb2f57d9621a7bba9e67286a9ea9e5.zip
Bug 469677: [UML-RT] Provide a new child menu for the UML-RT DSML
https://bugs.eclipse.org/bugs/show_bug.cgi?id=469677 - refactor code on RTPort:kind (push code in RTPortUtils) and add some unit tests. Change-Id: Idb9f61ea4ffb7edfee2003cfc1f3815e5637a505 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/papyrusrt/umlrt')
-rw-r--r--tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/utils/RTPortUtilsTest.java268
1 files changed, 268 insertions, 0 deletions
diff --git a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/utils/RTPortUtilsTest.java b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/utils/RTPortUtilsTest.java
index 3725eb02b..033bef362 100644
--- a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/utils/RTPortUtilsTest.java
+++ b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/utils/RTPortUtilsTest.java
@@ -12,7 +12,11 @@
package org.eclipse.papyrusrt.umlrt.core.tests.utils;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.eclipse.emf.common.command.Command;
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;
@@ -125,4 +129,268 @@ public class RTPortUtilsTest extends AbstractPapyrusTest {
assertEquals("error in RTPortUtils#getKind(Port)", RTPortKindEnum.SPP, RTPortUtils.getKind(capsule_legacySpp));
}
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSAPtoSPP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_sap, RTPortKindEnum.SPP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSAPtoSAP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_sap, RTPortKindEnum.SAP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSAPtoExternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_sap, RTPortKindEnum.EXTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSAPtoInternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_sap, RTPortKindEnum.INTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSAPtoRelay() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_sap, RTPortKindEnum.RELAY);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSPPtoSPP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_spp, RTPortKindEnum.SPP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSPPtoSAP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_spp, RTPortKindEnum.SAP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSPPtoExternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_spp, RTPortKindEnum.EXTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSPPtoInternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_spp, RTPortKindEnum.INTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromSPPtoRelay() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_spp, RTPortKindEnum.RELAY);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromRelaytoSPP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_relay, RTPortKindEnum.SPP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromRelaytoSAP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_relay, RTPortKindEnum.SAP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromRelaytoExternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_relay, RTPortKindEnum.EXTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromRelaytoInternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_relay, RTPortKindEnum.INTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromRelaytoRelay() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_relay, RTPortKindEnum.RELAY);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromExternaltoSPP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_externalBehavior, RTPortKindEnum.SPP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromExternaltoSAP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_externalBehavior, RTPortKindEnum.SAP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromExternaltoExternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_externalBehavior, RTPortKindEnum.EXTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromExternaltoInternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_externalBehavior, RTPortKindEnum.INTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromExternaltoRelay() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_externalBehavior, RTPortKindEnum.RELAY);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromInternaltoSPP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_internalBehavior, RTPortKindEnum.SPP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromInternaltoSAP() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_internalBehavior, RTPortKindEnum.SAP);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromInternaltoExternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_internalBehavior, RTPortKindEnum.EXTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromInternaltoInternal() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_internalBehavior, RTPortKindEnum.INTERNAL);
+ }
+
+ /**
+ * Test {@link RTPortUtils#getChangeKindCommand(Port, RTPortKindEnum)}
+ */
+ @Test
+ public void testRTPortUtils_getChangeFromInternaltoRelay() throws Exception {
+ testRTPortUtils_getChangeKindcommand(capsule_internalBehavior, RTPortKindEnum.RELAY);
+ }
+
+ protected void testRTPortUtils_getChangeKindcommand(Port portToModify, RTPortKindEnum newKind) {
+ RTPortKindEnum oldKind = RTPortUtils.getKind(portToModify);
+
+ Command command = RTPortUtils.getChangeKindCommand(portToModify, newKind);
+ if (!command.canExecute()) {
+ fail("Change command is not executable");
+ }
+ command.execute();
+ checkPort(portToModify, newKind);
+
+ if (!command.canUndo()) {
+ fail("Change command is not undoable");
+ }
+ command.undo();
+ checkPort(portToModify, oldKind);
+
+ command.redo();
+ checkPort(portToModify, newKind);
+
+ command.undo();
+ // check not dirty
+
+
+ }
+
+ protected void checkPort(Port port, RTPortKindEnum kind) {
+ switch (kind) {
+ case EXTERNAL:
+ assertTrue("Service: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isService(port));
+ assertTrue("Wired: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isWired(port));
+ assertTrue("Behavior: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isBehavior(port));
+ assertFalse("Publish: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isPublish(port));
+ break;
+ case INTERNAL:
+ assertFalse("Service: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isService(port));
+ assertTrue("Wired: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isWired(port));
+ assertTrue("Behavior: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isBehavior(port));
+ assertFalse("Publish: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isPublish(port));
+ break;
+ case RELAY:
+ assertTrue("Service: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isService(port));
+ assertTrue("Wired: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isWired(port));
+ assertFalse("Behavior: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isBehavior(port));
+ assertFalse("Publish: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isPublish(port));
+ break;
+ case SPP:
+ // assertTrue("Service: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isService(port)); // legacy
+ assertFalse("Wired: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isWired(port));
+ assertTrue("Behavior: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isBehavior(port));
+ assertTrue("Publish: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isPublish(port));
+ break;
+ case SAP:
+ // assertTrue("Service: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isService(port));// legacy
+ assertFalse("Wired: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isWired(port));
+ assertTrue("Behavior: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isBehavior(port));
+ assertFalse("Publish: error in RTPortUtils#getChangeKindCommand(Port)", RTPortUtils.isPublish(port));
+ break;
+
+ default:
+ break;
+ }
+ }
+
}

Back to the top