Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCamille Letavernier2013-08-06 09:20:13 -0400
committerCamille Letavernier2013-08-06 09:20:13 -0400
commite1b47da134dd0430946f669b0586d28d0a41e235 (patch)
treebd31197946c054c74a188f2e7c47b80be1c36810 /tests
parente345c35bf9d7f31d98d10486a4983d0bc3b203be (diff)
downloadorg.eclipse.papyrus-e1b47da134dd0430946f669b0586d28d0a41e235.tar.gz
org.eclipse.papyrus-e1b47da134dd0430946f669b0586d28d0a41e235.tar.xz
org.eclipse.papyrus-e1b47da134dd0430946f669b0586d28d0a41e235.zip
389531: [Sequence Diagram] Graphical Presentation of Gate with In/Out
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389531
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/BugTest_m7.java2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestExecutionEndsWithMessageOccurrenceSpecification.java266
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java158
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGraphicalGate_389531.java5
4 files changed, 428 insertions, 3 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/m7/BugTest_m7.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/BugTest_m7.java
index 7d5e4501787..9412acafa0a 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/BugTest_m7.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/BugTest_m7.java
@@ -21,6 +21,6 @@ import org.junit.runners.Suite.SuiteClasses;
* @author Jin Liu (jin.liu@soyatec.com)
*/
@RunWith(Suite.class)
-@SuiteClasses({ TestDurationConstraint_402967.class, TestElementIcon_396799.class, TestExecutionSpecificationPosition_395462.class, TestGraphicalGate_389531.class, TestGuardVisibility_402966.class, TestInteractionUseInCombinedFragment_402971.class, TestMessageCreateWithLifeline_403134.class, TestResizeStateInvariant_395774.class, TestTooltip_402964.class, TestMessageOccurrenceSpecification_402975.class, TestMakeSameHeightForLifelines_402978.class, TestMoveAnchorInsideCoRegion_402970.class, TestMoveMessageLostFound_403138.class, TestOrderingFragments_403233.class, TestShiftEnclosingMessageInOperand_402969.class })
+@SuiteClasses({ TestDurationConstraint_402967.class, TestElementIcon_396799.class, TestExecutionSpecificationPosition_395462.class, TestGraphicalGate_389531.class, TestGuardVisibility_402966.class, TestInteractionUseInCombinedFragment_402971.class, TestMessageCreateWithLifeline_403134.class, TestResizeStateInvariant_395774.class, TestTooltip_402964.class, TestMessageOccurrenceSpecification_402975.class, TestMakeSameHeightForLifelines_402978.class, TestMoveAnchorInsideCoRegion_402970.class, TestMoveMessageLostFound_403138.class, TestOrderingFragments_403233.class, TestShiftEnclosingMessageInOperand_402969.class, TestGateNameOnCombinedFragment.class, TestExecutionEndsWithMessageOccurrenceSpecification.class })
public class BugTest_m7 {
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestExecutionEndsWithMessageOccurrenceSpecification.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestExecutionEndsWithMessageOccurrenceSpecification.java
new file mode 100644
index 00000000000..ecef169e85d
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestExecutionEndsWithMessageOccurrenceSpecification.java
@@ -0,0 +1,266 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.tests.bug.m7;
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ExecutionSpecificationEndEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+import org.junit.Test;
+
+
+/**
+ * Test Execution ends(one is MessageOccurrenceSpecification of linked message) when the message reconnected or deleted.
+ *
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public class TestExecutionEndsWithMessageOccurrenceSpecification extends AbstractNodeTest {
+
+ private AbstractExecutionSpecificationEditPart createExecutionSpecificationWithLifeline(Point lifelineLocation, Dimension executionSize) {
+ LifelineEditPart lifeline = (LifelineEditPart)createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), lifelineLocation, null);
+ assertNotNull("create ExecutionSpecification's Lifeline", lifeline);
+ AbstractExecutionSpecificationEditPart es = (AbstractExecutionSpecificationEditPart)createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifeline, getAbsoluteBounds(lifeline).getCenter(), executionSize);
+ assertNotNull("create ExecutionSpecification", es);
+ return es;
+ }
+
+ @SuppressWarnings("rawtypes")
+ private ExecutionSpecificationEndEditPart findEndEditPart(AbstractExecutionSpecificationEditPart parent, boolean startEnd) {
+ if(parent == null) {
+ return null;
+ }
+ ExecutionSpecification execution = (ExecutionSpecification)parent.resolveSemanticElement();
+ OccurrenceSpecification end = startEnd ? execution.getStart() : execution.getFinish();
+ List children = parent.getChildren();
+ for(Object object : children) {
+ if(object instanceof ExecutionSpecificationEndEditPart && ((ExecutionSpecificationEndEditPart)object).resolveSemanticElement() == end) {
+ return (ExecutionSpecificationEndEditPart)object;
+ }
+ }
+ return null;
+ }
+
+ private void checkExecutionEnds(ExecutionSpecification execution, OccurrenceSpecification start, OccurrenceSpecification finish) {
+ checkExecutionValid(execution);
+ assertNotNull("start", start);
+ assertNotNull("finish", finish);
+ assertEquals("execution start", start, execution.getStart());
+ assertEquals("execution finish", finish, execution.getFinish());
+ }
+
+ private void checkExecutionValid(ExecutionSpecification execution) {
+ assertNotNull("execution", execution);
+ assertNotNull("start", execution.getStart());
+ assertNotNull("finish", execution.getFinish());
+ }
+
+ @Test
+ public void testReconnectSourceToExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), null);
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), null);
+ //1. create message: execution1.start ----message----> execution2
+ ExecutionSpecificationEndEditPart source = findEndEditPart(execution1, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getTop(), source, SequenceUtil.getAbsoluteBounds(execution2).getCenter(), execution2);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution = (ExecutionSpecification)execution1.resolveSemanticElement();
+ // result: execution1.start == message.sendEvent
+ checkExecutionEnds(umlExecution, (OccurrenceSpecification)umlMsg.getSendEvent(), umlExecution.getFinish());
+
+ //2. reconnect message: execution1 ----message----> execution2
+ reconnectSource(message, execution1, SequenceUtil.getAbsoluteBounds(execution1).getCenter().getTranslated(0, -5));
+ // result: execution1.start != message.sendEvent && execution1.start = executionOccurrenceSpecification
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getSendEvent(), umlExecution.getStart());
+ assertNotSame("should not same: execution finish", umlMsg.getSendEvent(), umlExecution.getFinish());
+
+ //3. reconnect message: execution1.finish ----message----> execution2
+ reconnectSource(message, findEndEditPart(execution1, false), SequenceUtil.getAbsoluteBounds(execution1).getBottom());
+ //result: execution1.finish = message.sendEvent
+ checkExecutionEnds(umlExecution, umlExecution.getStart(), (OccurrenceSpecification)umlMsg.getSendEvent());
+
+ //4. REPEAT: reconnect message : execution1 ----message----> execution2
+ reconnectSource(message, execution1, SequenceUtil.getAbsoluteBounds(execution1).getCenter().getTranslated(0, -5));
+ // result: execution1.start != message.sendEvent && execution1.start = executionOccurrenceSpecification
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getSendEvent(), umlExecution.getStart());
+ assertNotSame("should not same: execution finish", umlMsg.getSendEvent(), umlExecution.getFinish());
+ }
+
+ @Test
+ public void testReconnectTargetToExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), null);
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), null);
+ //1. create message: execution1 ----message----> execution2.start
+ ExecutionSpecificationEndEditPart target = findEndEditPart(execution2, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getCenter(), execution1, SequenceUtil.getAbsoluteBounds(execution2).getTop(), target);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution = (ExecutionSpecification)execution2.resolveSemanticElement();
+ // result: execution2.start == message.receiveEvent
+ checkExecutionEnds(umlExecution, (OccurrenceSpecification)umlMsg.getReceiveEvent(), umlExecution.getFinish());
+
+ //2. reconnect message: execution1 ----message----> execution2
+ reconnectTarget(message, execution2, SequenceUtil.getAbsoluteBounds(execution2).getCenter().getTranslated(0, 5));
+ // result: execution2.start != message.receiveEvent && execution2.start = executionOccurrenceSpecification
+ // result: execution2.finish != message.receiveEvent && execution2.finish = executionOccurrenceSpecification
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getReceiveEvent(), umlExecution.getStart());
+ assertNotSame("should not same: execution finish", umlMsg.getReceiveEvent(), umlExecution.getFinish());
+
+ //3. reconnect message: execution1 ----message----> execution2.finish
+ reconnectTarget(message, findEndEditPart(execution2, false), SequenceUtil.getAbsoluteBounds(execution2).getBottom());
+ //result: execution2.finish = message.receiveEvent
+ checkExecutionEnds(umlExecution, umlExecution.getStart(), (OccurrenceSpecification)umlMsg.getReceiveEvent());
+
+ //4. REPEAT: reconnect message : execution1 ----message----> execution2
+ reconnectTarget(message, execution2, SequenceUtil.getAbsoluteBounds(execution2).getCenter().getTranslated(0, 5));
+ // result: execution2.start != message.receiveEvent && execution2.start = executionOccurrenceSpecification
+ // result: execution2.finish != message.receiveEvent && execution2.finish = executionOccurrenceSpecification
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getReceiveEvent(), umlExecution.getStart());
+ assertNotSame("should not same: execution finish", umlMsg.getReceiveEvent(), umlExecution.getFinish());
+
+ }
+
+ @Test
+ public void testReconnectSourceToChildExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), new Dimension(16, 80));
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), new Dimension(16, 150));
+ AbstractExecutionSpecificationEditPart execution3 = (AbstractExecutionSpecificationEditPart)createNode(UMLElementTypes.ActionExecutionSpecification_3006, execution1.getParent(), SequenceUtil.getAbsoluteBounds(execution1).getCenter(), null);
+ //1. create message: execution1.start ----message----> execution2
+ ExecutionSpecificationEndEditPart source = findEndEditPart(execution1, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getTop(), source, SequenceUtil.getAbsoluteBounds(execution2).getCenter(), execution2);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution = (ExecutionSpecification)execution1.resolveSemanticElement();
+ // result: execution1.start == message.sendEvent
+ checkExecutionEnds(umlExecution, (OccurrenceSpecification)umlMsg.getSendEvent(), umlExecution.getFinish());
+
+ //2. reconnect message: execution3 ----message----> execution2
+ reconnectSource(message, execution3, SequenceUtil.getAbsoluteBounds(execution3).getCenter());
+ //result: execution1.start != message.sendEvent
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getSendEvent(), umlExecution.getStart());
+ }
+
+ @Test
+ public void testReconnectTargetToChildExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), new Dimension(16, 100));
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), new Dimension(16, 80));
+ AbstractExecutionSpecificationEditPart execution3 = (AbstractExecutionSpecificationEditPart)createNode(UMLElementTypes.ActionExecutionSpecification_3006, execution1.getParent(), SequenceUtil.getAbsoluteBounds(execution1).getCenter(), null);
+ //1. create message: execution2 ----message----> execution1.start
+ ExecutionSpecificationEndEditPart target = findEndEditPart(execution1, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution2).getCenter(), execution2, SequenceUtil.getAbsoluteBounds(execution1).getTop(), target);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution = (ExecutionSpecification)execution1.resolveSemanticElement();
+ // result: execution1.start == message.receiveEvent
+ checkExecutionEnds(umlExecution, (OccurrenceSpecification)umlMsg.getReceiveEvent(), umlExecution.getFinish());
+
+ //2. reconnect message: execution2 ----message----> execution3
+ reconnectTarget(message, execution3, SequenceUtil.getAbsoluteBounds(execution3).getCenter());
+ //result: execution1.start != message.receiveEvent
+ checkExecutionValid(umlExecution);
+ assertNotSame("should not same: execution start", umlMsg.getReceiveEvent(), umlExecution.getStart());
+ }
+
+ @Test
+ public void testDeleteMessage() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), null);
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), null);
+ //1. create message: execution1.start ----message----> execution2.start
+ ExecutionSpecificationEndEditPart source = findEndEditPart(execution1, true);
+ ExecutionSpecificationEndEditPart target = findEndEditPart(execution2, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getTop(), source, SequenceUtil.getAbsoluteBounds(execution2).getTop(), target);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution1 = (ExecutionSpecification)execution1.resolveSemanticElement();
+ ExecutionSpecification umlExecution2 = (ExecutionSpecification)execution2.resolveSemanticElement();
+ checkExecutionEnds(umlExecution1, (OccurrenceSpecification)umlMsg.getSendEvent(), umlExecution1.getFinish());
+ checkExecutionEnds(umlExecution2, (OccurrenceSpecification)umlMsg.getReceiveEvent(), umlExecution2.getFinish());
+
+ //2. delete the message
+ GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
+ deleteReq.setEditParts(message);
+ Command command = message.getCommand(deleteReq);
+ assertNotNull("delete command", command);
+ assertTrue("command can be executed", command.canExecute());
+ getDiagramCommandStack().execute(command);
+ checkExecutionValid(umlExecution1);
+ checkExecutionValid(umlExecution2);
+ }
+
+ @Test
+ public void testDeleteSourceExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), null);
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), null);
+ //1. create message: execution1.start ----message----> execution2.start
+ ExecutionSpecificationEndEditPart source = findEndEditPart(execution1, true);
+ ExecutionSpecificationEndEditPart target = findEndEditPart(execution2, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getTop(), source, SequenceUtil.getAbsoluteBounds(execution2).getTop(), target);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution1 = (ExecutionSpecification)execution1.resolveSemanticElement();
+ ExecutionSpecification umlExecution2 = (ExecutionSpecification)execution2.resolveSemanticElement();
+ checkExecutionEnds(umlExecution1, (OccurrenceSpecification)umlMsg.getSendEvent(), umlExecution1.getFinish());
+ checkExecutionEnds(umlExecution2, (OccurrenceSpecification)umlMsg.getReceiveEvent(), umlExecution2.getFinish());
+
+ //2. delete execution1
+ GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
+ deleteReq.setEditParts(execution1);
+ Command command = execution1.getCommand(deleteReq);
+ assertNotNull("delete command", command);
+ assertTrue("command can be executed", command.canExecute());
+ getDiagramCommandStack().execute(command);
+ checkExecutionValid(umlExecution2);
+ }
+
+ @Test
+ public void testDeleteTargetExecution() {
+ AbstractExecutionSpecificationEditPart execution1 = createExecutionSpecificationWithLifeline(new Point(100, 100), null);
+ AbstractExecutionSpecificationEditPart execution2 = createExecutionSpecificationWithLifeline(new Point(300, 100), null);
+ //1. create message: execution1.start ----message----> execution2.start
+ ExecutionSpecificationEndEditPart source = findEndEditPart(execution1, true);
+ ExecutionSpecificationEndEditPart target = findEndEditPart(execution2, true);
+ AbstractMessageEditPart message = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, execution1.getViewer(), SequenceUtil.getAbsoluteBounds(execution1).getTop(), source, SequenceUtil.getAbsoluteBounds(execution2).getTop(), target);
+ assertNotNull("Message", message);
+ Message umlMsg = (Message)message.resolveSemanticElement();
+ ExecutionSpecification umlExecution1 = (ExecutionSpecification)execution1.resolveSemanticElement();
+ ExecutionSpecification umlExecution2 = (ExecutionSpecification)execution2.resolveSemanticElement();
+ checkExecutionEnds(umlExecution1, (OccurrenceSpecification)umlMsg.getSendEvent(), umlExecution1.getFinish());
+ checkExecutionEnds(umlExecution2, (OccurrenceSpecification)umlMsg.getReceiveEvent(), umlExecution2.getFinish());
+
+ //2. delete execution2
+ GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
+ deleteReq.setEditParts(execution2);
+ Command command = execution2.getCommand(deleteReq);
+ assertNotNull("delete command", command);
+ assertTrue("command can be executed", command.canExecute());
+ getDiagramCommandStack().execute(command);
+ checkExecutionValid(umlExecution1);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java
index 7edb464079d..b10eaec987f 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGateNameOnCombinedFragment.java
@@ -13,15 +13,29 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.tests.bug.m7;
+import java.util.List;
+
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageFigure;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GateHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.uml2.uml.CombinedFragment;
import org.eclipse.uml2.uml.Gate;
@@ -109,4 +123,148 @@ public class TestGateNameOnCombinedFragment extends AbstractNodeTest {
Message message = (Message)messageEditPart.resolveSemanticElement();
assertEquals("Gate name", gateNamePrefix + message.getLabel(), gate.getLabel());
}
+
+ @Test
+ public void testUncoveredLifeline2CombinedFragmentGate() {
+ testFixedGateName("Gate0", false, true);
+ }
+
+
+ @Test
+ public void testCoveredLifeline2CombinedFragmentGate() {
+ testFixedGateName("Gate1", true, true);
+ }
+
+ @Test
+ public void testCombinedFragmentGate2CoveredLifeline() {
+ testFixedGateName("Gate2", true, false);
+ }
+
+ @Test
+ public void testCombinedFragmentGate2UncoveredLifeline() {
+ testFixedGateName("Gate3", false, false);
+ }
+
+ private GateEditPart createGate(EditPart parent, Point location) {
+ CreateRequest request = new CreateRequest(RequestConstants.REQ_CREATE);
+ request.setFactory(new CreationFactory() {
+
+ public Object getObjectType() {
+ return GateEditPart.GATE_TYPE;
+ }
+
+ public Object getNewObject() {
+ return GateEditPart.GATE_TYPE;
+ }
+ });
+ request.setLocation(location);
+ Command command = parent.getCommand(request);
+ assertNotNull("create gate command", command);
+ assertTrue("executable of create gate command", command.canExecute());
+ getDiagramCommandStack().execute(command);
+ waitForComplete();
+ GateEditPart gateEditPart = getPrimaryGateEditPart(parent);
+ assertNotNull("created gate", gateEditPart);
+ return gateEditPart;
+ }
+
+ protected GateEditPart getPrimaryGateEditPart(EditPart parent) {
+ @SuppressWarnings("rawtypes")
+ List children = parent.getChildren();
+ for(int i = children.size() - 1; i >= 0; i--) {
+ Object child = children.get(i);
+ if(child instanceof GateEditPart) {
+ GateEditPart gateEp = (GateEditPart)child;
+ Gate gate = (Gate)gateEp.resolveSemanticElement();
+ if(!(GateHelper.isInnerCFGate(gate))) {
+ return gateEp;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected EditPart createLink(IElementType elementType, EditPartViewer currentViewer, Point startLocation, EditPart sourceEditPart, Point endLocation, EditPart targetEditPart) {
+ final EditPart linkEditPart = super.createLink(elementType, currentViewer, startLocation, sourceEditPart, endLocation, targetEditPart);
+ if(linkEditPart instanceof AbstractMessageEditPart) {
+ currentViewer.setSelection(new StructuredSelection(linkEditPart));
+ waitForComplete();
+ performFirstDirectEdit((AbstractMessageEditPart)linkEditPart);
+ }
+ return linkEditPart;
+ }
+
+ /**
+ * Emulate a direct edit after creation like use the palette tool.
+ */
+ @SuppressWarnings({ "unchecked" })
+ private void performFirstDirectEdit(AbstractMessageEditPart messageEditPart) {
+ MessageFigure primaryShape = messageEditPart.getPrimaryShape();
+ WrappingLabel label = primaryShape.getMessageLabelFigure();
+ DirectEditRequest req = new DirectEditRequest();
+ Rectangle b = label.getBounds().getCopy();
+ label.translateToAbsolute(b);
+ req.setLocation(b.getCenter());
+ req.getExtendedData().put(SequenceRequestConstant.DIRECT_EDIT_AFTER_CREATION, true);
+ messageEditPart.performRequest(req);
+
+ waitForComplete();
+
+ //Deactive the Popup Editor.
+ messageEditPart.getViewer().getControl().setFocus();
+ waitForComplete();
+ }
+
+ private void testFixedGateName(String gateName, boolean lifelineCovered, boolean messageFromLifeline2Gate) {
+ //1. Create CombinedFragment
+ CombinedFragmentEditPart cfEditPart = (CombinedFragmentEditPart)createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(100, 200), null);
+ assertNotNull("CombinedFragment creation", cfEditPart);
+ //1.1 Create Gate on CombinedFragment
+ Rectangle cfBounds = SequenceUtil.getAbsoluteBounds(cfEditPart);
+ GateEditPart gateEditPart = createGate(cfEditPart, new Point(cfBounds.right() - 1, cfBounds.y + cfBounds.height / 2));
+ assertNotNull("Gate on CombinedFragment creation", gateEditPart);
+
+ Gate gate = (Gate)((GateEditPart)gateEditPart).resolveSemanticElement();
+ changeName(getEditingDomain(), gate, gateName);
+ assertEquals("Check gate name when creation", gateName, gate.getLabel());
+ //2. Create Lifeline
+ //Create a Lifeline which is covered by the CombinedFragment
+ Point lifelineLocation = new Point(0, 100);
+ if(lifelineCovered) {
+ lifelineLocation.x = cfBounds.getCenter().x;
+ } else {
+ lifelineLocation.x = cfBounds.getRight().x + 100;
+ }
+ LifelineEditPart lifelineEp = (LifelineEditPart)createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), lifelineLocation, null);
+ assertNotNull("Lifeline Creation", lifelineEp);
+
+ //3. Check covered.
+ CombinedFragment combinedFragment = (CombinedFragment)cfEditPart.resolveSemanticElement();
+ Lifeline lifeline = (Lifeline)lifelineEp.resolveSemanticElement();
+ if(lifelineCovered) {
+ assertTrue("lifeline is covered by combinedFragment", lifeline.getCoveredBys().contains(combinedFragment));
+ } else {
+ assertTrue("lifeline is not covered by combinedFragment", !lifeline.getCoveredBys().contains(combinedFragment));
+ }
+
+ //4. Create Message between Lifeline and CombinedFragment.
+ EditPart source = null, target = null;
+ Point startLocation = null, targetLocation = null;
+ if(messageFromLifeline2Gate) {
+ source = lifelineEp;
+ target = gateEditPart;
+ targetLocation = SequenceUtil.getAbsoluteBounds(gateEditPart).getRight().getCopy();
+ startLocation = SequenceUtil.getAbsoluteBounds(lifelineEp).getCenter().setY(targetLocation.y);
+ } else {
+ source = gateEditPart;
+ startLocation = SequenceUtil.getAbsoluteBounds(gateEditPart).getRight().getCopy();
+ target = lifelineEp;
+ targetLocation = SequenceUtil.getAbsoluteBounds(lifelineEp).getCenter().setY(startLocation.y);
+ }
+ AbstractMessageEditPart messageEditPart = (AbstractMessageEditPart)createLink(UMLElementTypes.Message_4004, cfEditPart.getViewer(), startLocation, source, targetLocation, target);
+ assertNotNull("Message creation between Lifeline and Gate of CombinedFragment", messageEditPart);
+
+ //5. Check Gate name
+ assertEquals("Check gate name after message creation", gateName, gate.getLabel());
+ }
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGraphicalGate_389531.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGraphicalGate_389531.java
index 369340cd67d..76d4c0c65a9 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGraphicalGate_389531.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/m7/TestGraphicalGate_389531.java
@@ -64,7 +64,7 @@ public class TestGraphicalGate_389531 extends AbstractNodeTest {
protected String getFileName() {
return ISequenceDiagramTestsConstants.FILE_NAME;
}
-
+
private GateEditPart createGate(EditPart parent, Point location) {
CreateRequest request = new CreateRequest(RequestConstants.REQ_CREATE);
request.setFactory(new CreationFactory() {
@@ -368,7 +368,8 @@ public class TestGraphicalGate_389531 extends AbstractNodeTest {
Gate gate2 = (Gate)message2.getReceiveEvent();
GateEditPart gate2EditPart = getGateEditPart(interaction, gate2);
assertNotNull("Gate created", gate2EditPart);
- assertEquals("Gate name", "out_" + message2.getName(), getGateName(gate2EditPart));
+ //the name of gate on Interaction will not be changed.
+ assertEquals("Gate name", gate2.getName(), getGateName(gate2EditPart));
}
/**

Back to the top