1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*****************************************************************************
* 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 org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
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.tests.ISequenceDiagramTestsConstants;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.InteractionOperand;
import org.junit.Test;
/**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233
*
* @author Jin Liu (jin.liu@soyatec.com)
*/
public class TestOrderingFragments_403233 extends AbstractNodeTest {
@Override
protected String getProjectName() {
return ISequenceDiagramTestsConstants.PROJECT_NAME;
}
@Override
protected String getFileName() {
return ISequenceDiagramTestsConstants.FILE_NAME;
}
@Test
public void testOrderingAfterCreateExecutions() {
LifelineEditPart lifeline = (LifelineEditPart)createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(200, 100), null);
AbstractExecutionSpecificationEditPart executionPart1 = (AbstractExecutionSpecificationEditPart)createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifeline, getAbsoluteBounds(lifeline).getCenter(), null);
AbstractExecutionSpecificationEditPart executionPart2 = (AbstractExecutionSpecificationEditPart)createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifeline, getAbsoluteBounds(executionPart1).getCenter().getTranslated(0, -100), null);
ExecutionSpecification execution1 = (ExecutionSpecification)executionPart1.resolveSemanticElement();
ExecutionSpecification execution2 = (ExecutionSpecification)executionPart2.resolveSemanticElement();
validOrderWithPosition(execution1, getAbsoluteBounds(executionPart1).y, execution2, getAbsoluteBounds(executionPart2).y);
}
private void validOrderWithPosition(InteractionFragment fragment1, int position1, InteractionFragment fragment2, int position2) {
if(position1 == position2) {
return;
}
assertNotNull("fragment1", fragment1);
assertNotNull("fragment2", fragment2);
EObject container = fragment1.eContainer();
assertEquals("has same container", fragment1.eContainer(), fragment2.eContainer());
EList<InteractionFragment> fragments = null;
if(container instanceof Interaction) {
fragments = ((Interaction)container).getFragments();
} else if(container instanceof InteractionOperand) {
fragments = ((InteractionOperand)container).getFragments();
}
int index1 = fragments.indexOf(fragment1);
int index2 = fragments.indexOf(fragment2);
if(position1 < position2) {
assertTrue("", index1 < index2);
} else if(position1 > position2) {
assertTrue("", index1 > index2);
}
}
}
|