Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-08-09 08:41:24 -0400
committerCamille Letavernier2018-09-24 06:48:47 -0400
commitd583b291496ce0df25eb976e545ab3bc03c32513 (patch)
treef9624be90997fdab61573cf21b5e8ba2cb8e2e3e
parente06a54bbd7c60b9c867089063bb7f9a977b57440 (diff)
downloadorg.eclipse.papyrus-d583b291496ce0df25eb976e545ab3bc03c32513.tar.gz
org.eclipse.papyrus-d583b291496ce0df25eb976e545ab3bc03c32513.tar.xz
org.eclipse.papyrus-d583b291496ce0df25eb976e545ab3bc03c32513.zip
Bug 536631: [Sequence Diagram] Support DurationConstraint/Observation as
a Connection between two events Bug 537561: [Sequence Diagram] Support GeneralOrdering as a Connection between two events - Add deletion tests Change-Id: I4b698c01f9036257a7386c9ee50f9eaf10f327b1 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java65
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java10
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java10
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java11
4 files changed, 81 insertions, 15 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java
index 17e396563ed..5ac44948f59 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java
@@ -39,6 +39,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeTopAnchor;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenceForExecSpecEditPolicy;
import org.eclipse.uml2.uml.ActionExecutionSpecification;
import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.NamedElement;
@@ -220,21 +221,6 @@ public abstract class AbstractOccurrenceLinkTest<T extends NamedElement> extends
checkDeleted(links[0]);
}
- /**
- * Execute a semantic change on the given link that doesn't affect
- * its source or target
- *
- * @param linkToChange
- */
- protected abstract void doUnrelatedChange(T linkToChange);
-
- /**
- * Execute a semantic change on the given link that modifies its target
- *
- * @param linkToChange
- */
- protected abstract void doChangeTarget(T linkToChange);
-
@Test
public void testLinkDisappearOnAnchorageChange() {
editor.delete(message1);
@@ -253,6 +239,36 @@ public abstract class AbstractOccurrenceLinkTest<T extends NamedElement> extends
Assert.assertTrue(linkNames[6] + " should still be active", links[6].isActive());
}
+ // Link deletion shouldn't deleted linked events
+ @Test
+ public void testLinkDeletion() {
+ Message umlMessage1 = (Message) EMFHelper.getEObject(message1);
+ Assert.assertNotNull(umlMessage1.eResource());
+
+ for (ConnectionNodeEditPart linkPart : links) {
+ @SuppressWarnings("unchecked")
+ T link = (T) EMFHelper.getEObject(linkPart);
+ Element source = getSourceElement(link);
+ Element target = getTargetElement(link);
+
+ Assert.assertNotNull(source);
+ Assert.assertNotNull(target);
+
+ editor.delete(linkPart);
+
+ // Check that source/target events are still present in the UML Model
+ Assert.assertEquals(umlMessage1.eResource(), source.eResource());
+ Assert.assertEquals(umlMessage1.eResource(), target.eResource());
+ }
+
+ // Check that the Message/Exec/Destruction edit parts are unaffected
+ Assert.assertTrue(message1.isActive());
+ Assert.assertTrue(message4.isActive());
+ Assert.assertTrue(exec1.isActive());
+ Assert.assertTrue(exec3.isActive());
+ Assert.assertTrue(destruction.isActive());
+ }
+
private static void checkDeleted(EditPart editPart) {
Assert.assertFalse("The edit part should be destroyed", editPart.isActive());
View view = (View) editPart.getModel();
@@ -282,4 +298,23 @@ public abstract class AbstractOccurrenceLinkTest<T extends NamedElement> extends
Assert.assertThat("Invalid source anchor for " + connectionName, connection.getConnectionFigure().getSourceAnchor(), IsInstanceOf.instanceOf(sourceAnchor));
Assert.assertThat("Invalid target anchor for " + connectionName, connection.getConnectionFigure().getTargetAnchor(), IsInstanceOf.instanceOf(targetAnchor));
}
+
+ /**
+ * Execute a semantic change on the given link that doesn't affect
+ * its source or target
+ *
+ * @param linkToChange
+ */
+ protected abstract void doUnrelatedChange(T linkToChange);
+
+ /**
+ * Execute a semantic change on the given link that modifies its target
+ *
+ * @param linkToChange
+ */
+ protected abstract void doChangeTarget(T linkToChange);
+
+ protected abstract Element getSourceElement(T link);
+
+ protected abstract Element getTargetElement(T link);
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java
index fb12695f6e4..6b7b866cfa2 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java
@@ -69,4 +69,14 @@ public class TestDurationConstraintDisplay extends AbstractOccurrenceLinkTest<Du
editor.execute(provider.getEditCommand(request));
}
+ @Override
+ protected Element getSourceElement(DurationConstraint link) {
+ return link.getConstrainedElements().get(0);
+ }
+
+ @Override
+ protected Element getTargetElement(DurationConstraint link) {
+ return link.getConstrainedElements().size() == 1 ? link.getConstrainedElements().get(0) : link.getConstrainedElements().get(1);
+ }
+
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java
index 3c2fdc08be2..97a03e90bda 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java
@@ -70,4 +70,14 @@ public class TestDurationObservationDisplay extends AbstractOccurrenceLinkTest<D
editor.execute(provider.getEditCommand(request));
}
+ @Override
+ protected Element getSourceElement(DurationObservation link) {
+ return link.getEvents().get(0);
+ }
+
+ @Override
+ protected Element getTargetElement(DurationObservation link) {
+ return link.getEvents().size() == 1 ? link.getEvents().get(0) : link.getEvents().get(1);
+ }
+
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java
index 8c836a832d2..fecdc346bec 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java
@@ -20,6 +20,7 @@ import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
import org.eclipse.papyrus.uml.diagram.sequence.figures.GeneralOrderingDescriptor;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.GeneralOrdering;
import org.eclipse.uml2.uml.UMLPackage.Literals;
@@ -62,4 +63,14 @@ public class TestGeneralOrderingDisplay extends AbstractOccurrenceLinkTest<Gener
editor.execute(provider.getEditCommand(request));
}
+ @Override
+ protected Element getSourceElement(GeneralOrdering link) {
+ return link.getBefore();
+ }
+
+ @Override
+ protected Element getTargetElement(GeneralOrdering link) {
+ return link.getAfter();
+ }
+
}

Back to the top