Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2018-05-14 21:54:12 +0000
committerNicolas FAUVERGUE2018-07-06 07:27:02 +0000
commit5af9263e49248bbaa7048522909cda202f37642b (patch)
tree28bf984c3dc8e45994eaf2a645701418190308e3 /tests/junit/plugins
parent8ba78ef5f3941027769e6c537f078d173177a979 (diff)
downloadorg.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.tar.gz
org.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.tar.xz
org.eclipse.papyrus-5af9263e49248bbaa7048522909cda202f37642b.zip
Bug 530201: [Sequence Diagram] Covered feature is broken for InteractionFragment
Ensure that all interaction fragments that can be created in an interaction (continuation apparently not supported) are initialized with lifeline coverage for the lifelines that they visually cover. This includes updating the GridManagementEditPolicy to stop just adding all interaction operands to the 'coveredBys' of all lifelines in the interaction. Change-Id: I6e6dd83138b2433456beacbab1acacb9fb5155a3 Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
Diffstat (limited to 'tests/junit/plugins')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation44
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml16
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java137
5 files changed, 201 insertions, 1 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di
new file mode 100644
index 00000000000..8c549eecdc6
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" contextId="org.eclipse.papyrus.infra.services.edit.TypeContext"/>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation
new file mode 100644
index 00000000000..bf3176c7daa
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.notation
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/gmfdiag/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_QKU0YEMwEeiEZ5Jtfh6-KA" type="PapyrusUMLSequenceDiagram" name="sequence" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_QKU0YUMwEeiEZ5Jtfh6-KA" type="Interaction_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_QKU0YkMwEeiEZ5Jtfh6-KA" type="Interaction_NameLabel">
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_QKU0Y0MwEeiEZ5Jtfh6-KA" type="Interaction_SubfragmentCompartment">
+ <children xmi:type="notation:Shape" xmi:id="_RZ4XwEMwEeiEZ5Jtfh6-KA" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_RZ4-0EMwEeiEZ5Jtfh6-KA" type="Lifeline_NameLabel">
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_RZwb8EMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_RZwb8EMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_RZ4XwUMwEeiEZ5Jtfh6-KA" x="58" y="10"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_R0X7YEMwEeiEZ5Jtfh6-KA" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_R0X7YkMwEeiEZ5Jtfh6-KA" type="Lifeline_NameLabel">
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_R0cM0EMwEeiEZ5Jtfh6-KA" type="compartment_shape_display">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_R0cM0UMwEeiEZ5Jtfh6-KA"/>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_R0cM0kMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_R0URAEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_R0X7YUMwEeiEZ5Jtfh6-KA" x="237" y="10"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_N4VMoFe1EeioAP7w1C-s3w" type="Lifeline_Shape">
+ <children xmi:type="notation:DecorationNode" xmi:id="_N4VMole1EeioAP7w1C-s3w" type="Lifeline_NameLabel"/>
+ <element xmi:type="uml:Lifeline" href="bug530201.uml#_N4Oe8Fe1EeioAP7w1C-s3w"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_N4VMoVe1EeioAP7w1C-s3w" x="514" y="10"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_QKU0ZEMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_QKU0ZUMwEeiEZ5Jtfh6-KA"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_QKU0ZkMwEeiEZ5Jtfh6-KA" name="diagram_compatibility_version" stringValue="1.4.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_QKU0Z0MwEeiEZ5Jtfh6-KA"/>
+ <styles xmi:type="style:PapyrusDiagramStyle" xmi:id="_QKU0aEMwEeiEZ5Jtfh6-KA" diagramKindId="org.eclipse.papyrus.uml.diagram.sequence">
+ <owner xmi:type="uml:Class" href="bug530201.uml#_Jqu6wEMwEeiEZ5Jtfh6-KA"/>
+ </styles>
+ <element xmi:type="uml:Interaction" href="bug530201.uml#_POkWwEMwEeiEZ5Jtfh6-KA"/>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml
new file mode 100644
index 00000000000..5c2fc9874bf
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug530201.uml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_HWN6cEMwEeiEZ5Jtfh6-KA" name="bug530201">
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_HeHSMEMwEeiEZ5Jtfh6-KA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="_Jqu6wEMwEeiEZ5Jtfh6-KA" name="Foo" classifierBehavior="_POkWwEMwEeiEZ5Jtfh6-KA">
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_LwEPkEMwEeiEZ5Jtfh6-KA" name="a"/>
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_M6OVkEMwEeiEZ5Jtfh6-KA" name="b"/>
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_PQddMFe1EeioAP7w1C-s3w" name="c"/>
+ <ownedBehavior xmi:type="uml:Interaction" xmi:id="_POkWwEMwEeiEZ5Jtfh6-KA" name="DoIt">
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_RZwb8EMwEeiEZ5Jtfh6-KA" name="a" represents="_LwEPkEMwEeiEZ5Jtfh6-KA"/>
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_R0URAEMwEeiEZ5Jtfh6-KA" name="b" represents="_M6OVkEMwEeiEZ5Jtfh6-KA"/>
+ <lifeline xmi:type="uml:Lifeline" xmi:id="_N4Oe8Fe1EeioAP7w1C-s3w" name="c" represents="_PQddMFe1EeioAP7w1C-s3w"/>
+ </ownedBehavior>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
index 875fb41e54c..a8a5734e776 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 533673
+ * Christian W. Damus - bugs 533673, 530201
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
@@ -35,6 +35,7 @@ import org.junit.runners.Suite.SuiteClasses;
TestGuardEdition_364808.class,
CombinedFragmentRegressionTest.class,
TestCombinedFragmentOperandsLayout.class,
+ LifelineCoverageRegressionTest.class,
TestCFOperandsCoveredNodes.class,
TestCFOperandsSemanticCoverage.class,
})
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java
new file mode 100644
index 00000000000..9020a5b6e50
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/LifelineCoverageRegressionTest.java
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, Christian W. Damus, and others.
+ *
+ * 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
+
+import static org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture.at;
+import static org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture.sized;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.InteractionOperand;
+import org.eclipse.uml2.uml.InteractionUse;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.StateInvariant;
+import org.hamcrest.FeatureMatcher;
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Regression tests specifically for lifeline coverage of newly created interaction
+ * fragments, per <a href="http://eclip.se/530201">bug 530201</a>.
+ *
+ * @author Christian W. Damus
+ * @see <a href="http://eclip.se/530201">bug 530201</a>
+ */
+@ActiveDiagram("sequence")
+@PluginResource("resource/bugs/bug530201.di")
+public class LifelineCoverageRegressionTest extends AbstractPapyrusTest {
+ private static final Dimension DEFAULT_SIZE = null;
+
+ @Rule
+ public final PapyrusEditorFixture editor = new PapyrusEditorFixture();
+
+ /**
+ * Initializes me.
+ */
+ public LifelineCoverageRegressionTest() {
+ super();
+ }
+
+ /**
+ * Verify the lifeline coverage of an {@link InteractionUse}.
+ */
+ @Test
+ public void createInteractionUse() {
+ testScenario(UMLElementTypes.InteractionUse_Shape);
+ }
+
+ void testScenario(IElementType type) {
+ testScenario(type, ep -> ep.getAdapter(InteractionFragment.class));
+ }
+
+ void testScenario(IElementType type, Function<? super EditPart, ? extends InteractionFragment> fragmentExtractor) {
+ EditPart fragmentEP = editor.createShape(type, at(20, 100), sized(360, 60));
+
+ InteractionFragment fragment = fragmentExtractor.apply(fragmentEP);
+ assertThat(fragment, covers("a", "b")); // Not lifeline 'c'
+ }
+
+ /**
+ * Verify the lifeline coverage of a {@link CombinedFragment}.
+ */
+ @Test
+ public void createCombinedFragment() {
+ testScenario(UMLElementTypes.CombinedFragment_Shape);
+ }
+
+ /**
+ * Verify the lifeline coverage of the initial {@link InteractionOperand}
+ * of a new {@link CombinedFragment}.
+ */
+ @Test
+ public void createCombinedFragment_operand() {
+ testScenario(UMLElementTypes.CombinedFragment_Shape,
+ ep -> ep.getAdapter(CombinedFragment.class).getOperands().get(0));
+ }
+
+ /**
+ * Verify the lifeline coverage of a {@link StateInvariant}. Note that the EMF-based
+ * UML2 API cannot effect the redefinition of {@link InteractionFragment#getCovereds() covered}
+ * as a single-valued property, so the tooling enforces single coverage.
+ */
+ @Test
+ public void createStateInvariant() {
+ EditPart fragmentEP = editor.createShape(UMLElementTypes.StateInvariant_Shape,
+ at(100, 100), DEFAULT_SIZE);
+
+ InteractionFragment fragment = fragmentEP.getAdapter(InteractionFragment.class);
+ assertThat(fragment, covers("a")); // Neither lifeline 'b' nor 'c'
+ }
+
+ //
+ // Test framework
+ //
+
+ Matcher<InteractionFragment> covers(String... lifelineName) {
+ Set<String> lifelineNames = new HashSet<>(Arrays.asList(lifelineName));
+
+ return new FeatureMatcher<InteractionFragment, Set<String>>(equalTo(lifelineNames), "covered lifelines", "covers") {
+ @Override
+ protected Set<String> featureValueOf(InteractionFragment actual) {
+ return actual.getCovereds().stream()
+ .map(NamedElement::getName)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ }
+ };
+ }
+}

Back to the top