Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2015-07-10 04:57:05 -0400
committervincent lorenzo2018-09-20 10:45:57 -0400
commita907519e5cc2cad72eae532a1424a13762a2d201 (patch)
tree8002af4546020bfbcf269925b0c21a0da0df174b
parente3c63a073b200296255bf5f303bd6668f60bb265 (diff)
downloadorg.eclipse.papyrus-a907519e5cc2cad72eae532a1424a13762a2d201.tar.gz
org.eclipse.papyrus-a907519e5cc2cad72eae532a1424a13762a2d201.tar.xz
org.eclipse.papyrus-a907519e5cc2cad72eae532a1424a13762a2d201.zip
Bug 472342: [Stereotype Display] Provide JUnit Tests for Link
https://bugs.eclipse.org/bugs/show_bug.cgi?id=472342 - Test Apply and unapply stereotype for Link Change-Id: If807a09fac08c008b34a0d4dc48a55a16ffb8918 Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net> Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/OperationFigure.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/PropertyFigure.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java6
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AbstractAppliedStereotypeDisplayTest.java90
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayCompartmentClassDiagramTest.java50
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayLinkClassDiagramTest.java97
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayNodeClassDiagramTest.java55
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java7
8 files changed, 238 insertions, 101 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/OperationFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/OperationFigure.java
index 58e0e540259..9349cbc34a4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/OperationFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/OperationFigure.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
+ * Copyright (c) 2016, 2018 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,17 +10,18 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.clazz.custom.figure;
-public class OperationFigure extends org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel {
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
- static final org.eclipse.swt.graphics.Font THIS_FONT = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), "Arial", 10, org.eclipse.swt.SWT.NORMAL);
+public class OperationFigure extends PapyrusWrappingLabel {
- public OperationFigure() {
- this.setText("");
+ static final org.eclipse.swt.graphics.Font THIS_FONT = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), "Arial", 10, org.eclipse.swt.SWT.NORMAL); //$NON-NLS-1$
- this.setFont(THIS_FONT);
+ public OperationFigure() {
+ setText(""); //$NON-NLS-1$
+ setFont(THIS_FONT);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/PropertyFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/PropertyFigure.java
index 7fe945da976..60ae964d397 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/PropertyFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/figure/PropertyFigure.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
+ * Copyright (c) 2016, 2018 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,18 +10,19 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.clazz.custom.figure;
-public class PropertyFigure extends org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel {
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
- static final org.eclipse.swt.graphics.Font THIS_FONT = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), "Arial", 10, org.eclipse.swt.SWT.NORMAL);
+public class PropertyFigure extends PapyrusWrappingLabel {
- public PropertyFigure() {
- this.setText("");
+ static final org.eclipse.swt.graphics.Font THIS_FONT = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), "Arial", 10, org.eclipse.swt.SWT.NORMAL); //$NON-NLS-1$
- this.setFont(THIS_FONT);
+ public PropertyFigure() {
+ setText(""); //$NON-NLS-1$
+ setFont(THIS_FONT);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
index 8a9ccc3dd19..87faf887da9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2018 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
@@ -80,7 +80,7 @@ public class AppliedStereotypeLinkLabelDisplayEditPolicy extends AppliedStereoty
// if the string is not empty, then, the figure has to display it. Else,
// it displays nothing
if (figure instanceof IPapyrusUMLElementFigure) {
- ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay.equals("") ? stereotypesToDisplay : "\n" + stereotypesToDisplay), imageToDisplay);
+ ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + stereotypesToDisplay, imageToDisplay);
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AbstractAppliedStereotypeDisplayTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AbstractAppliedStereotypeDisplayTest.java
index 2978585a1b0..11e25384532 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AbstractAppliedStereotypeDisplayTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AbstractAppliedStereotypeDisplayTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2015, 2018 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- *
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display;
@@ -18,22 +18,15 @@ package org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display;
import java.util.Collection;
import java.util.List;
-import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.DiagramUtils;
import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
-import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
import org.eclipse.papyrus.uml.tools.commands.UnapplyStereotypeCommand;
@@ -48,9 +41,9 @@ import org.junit.Before;
import org.junit.Rule;
/**
- *
+ *
* This Abstract class has to be extended to test application and unapplication of stereotypes.
- *
+ *
* @author Céline JANSSENS
*
*/
@@ -264,10 +257,17 @@ public abstract class AbstractAppliedStereotypeDisplayTest extends AbstractPapyr
}
+ /**
+ * Test the Label of the element
+ *
+ * @param expectedLabel
+ * Expected text of the Label
+ */
+ protected abstract void testLabel(String expectedLabel);
/**
* Unapply and check the applied stereotypes
- *
+ *
* @param stereoList
* The collection of the Stereotypes to unapply.
*/
@@ -288,7 +288,7 @@ public abstract class AbstractAppliedStereotypeDisplayTest extends AbstractPapyr
/**
* Apply and check the applied stereotype
- *
+ *
* @param stereoList
* The collection of the Stereotypes to apply.
*/
@@ -307,60 +307,12 @@ public abstract class AbstractAppliedStereotypeDisplayTest extends AbstractPapyr
}
/**
- * Tests the Content of Named Node Label
- *
- * @param expectedLabel
- * The expected label Text
- */
- protected void testNodeLabelContent(final String expectedLabel) {
- // Check the Label content
- Assert.assertNotNull(editPart);
- Assert.assertTrue(editPart instanceof IPapyrusEditPart);
- IPapyrusEditPart pep = (IPapyrusEditPart) editPart;
- Assert.assertTrue(pep.getPrimaryShape() instanceof NodeNamedElementFigure);
- PapyrusWrappingLabel label = ((NodeNamedElementFigure) pep.getPrimaryShape()).getStereotypesLabel();
-
- if (null == expectedLabel) {
- Assert.assertNull("Label stereotype should be null", label);
- } else {
- Assert.assertNotNull("The Label Stereotype should not be null ", label);
- String labelText = label.getText();
- Assert.assertEquals("The label content is not the one expected", expectedLabel, labelText);
-
- }
-
- }
-
-
- /**
- * Test the Label of a UML Compartment element (Such as Operation , property or Enumeration Literal)
- *
- * @param expectedLabel
- * The expected Label
- *
- */
- protected void testCompartmentLabelContent(final String expectedLabel) {
- // Check the Label content
- Assert.assertNotNull(editPart);
- Assert.assertTrue(editPart instanceof UMLCompartmentEditPart);
- IFigure labelFigure = ((GraphicalEditPart) editPart).getFigure();
-
- Assert.assertTrue("Figure should be a PapyrusWrappingLabel", labelFigure instanceof WrappingLabel);
- String label = ((WrappingLabel) labelFigure).getText();
-
- Assert.assertNotNull("The label of the figure is null",label);
- Assert.assertTrue("The label content is not the one expected", label.startsWith(expectedLabel));
-
- }
-
-
- /**
* Test if there is more than the expected number of Comment View into the Diagram.
* This is to detect the Orphan Comment view.
- *
+ *
* @param expectedNumberOfCommentView
* The expected number of Comment View into the entire diagram
- *
+ *
*/
protected void testOrphanComment(final int expectedNumberOfCommentView) {
List<View> listOfAllComment = testHelper.getAllComment(mainDiagram);
@@ -397,7 +349,7 @@ public abstract class AbstractAppliedStereotypeDisplayTest extends AbstractPapyr
/**
* Set the different elements required for the specific test. ( Class, Enumeration, Package, ...)
- *
+ *
* @param objectName
* The name of the object to be retrieved
* @param classType
@@ -426,21 +378,21 @@ public abstract class AbstractAppliedStereotypeDisplayTest extends AbstractPapyr
}
/**
- *
+ *
* @param stereotypeName
* the name of the stereotype
* @return
* the name of the stereotype between << and >>
*/
- protected final String getStereotypeNameWithItsDelimiters(final String ... stereotypeName ) {
+ protected final String getStereotypeNameWithItsDelimiters(final String... stereotypeName) {
final StringBuilder builder = new StringBuilder(String.valueOf(Activator.ST_LEFT));
- for(int i=0;i<stereotypeName.length;i++) {
- if(i!=0) {
+ for (int i = 0; i < stereotypeName.length; i++) {
+ if (i != 0) {
builder.append(", ");
}
builder.append(stereotypeName[i]);
}
-
+
builder.append(String.valueOf(Activator.ST_RIGHT));
return builder.toString();
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayCompartmentClassDiagramTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayCompartmentClassDiagramTest.java
index db2db726745..aac50434b6a 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayCompartmentClassDiagramTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayCompartmentClassDiagramTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
+ * Copyright (c) 2015, 2018 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,20 +10,25 @@
*
* Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- *
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display;
import java.util.Arrays;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.junit.Assert;
import org.junit.Test;
/**
* This Class Tests the application of stereotypes for the UML Compartment editPart into the Class Diagram
- *
+ *
* @author Céline JANSSENS
*
*/
@@ -44,7 +49,7 @@ public class AppliedStereotypeDisplayCompartmentClassDiagramTest extends Abstrac
// Apply 1 stereotypes and test structure and Label content
applyStereotype(Arrays.asList(stereotypeA));
testStructure(1, 0, 1, 0);
- testCompartmentLabelContent(getStereotypeNameWithItsDelimiters(STEREO_A));
+ testLabel(String.valueOf("\u00AB") + "stereoA" + String.valueOf("\u00BB"));
testOrphanComment(0);
// UnApply 1 stereotype and test structure and Label content
@@ -55,6 +60,29 @@ public class AppliedStereotypeDisplayCompartmentClassDiagramTest extends Abstrac
}
+
+ /**
+ * Test the Label of a UML Compartment element (Such as Operation , property or Enumeration Literal)
+ *
+ * @param expectedLabel
+ * The expected Label
+ *
+ */
+ protected void testCompartmentLabelContent(String expectedLabel) {
+ // Check the Label content
+ Assert.assertNotNull(editPart);
+ Assert.assertTrue(editPart instanceof UMLCompartmentEditPart);
+ String label = null;
+ IFigure labelFigure = ((GraphicalEditPart) editPart).getFigure();
+
+ Assert.assertTrue("Figure should be a PapyrusWrappingLabel", labelFigure instanceof WrappingLabel);
+ label = ((WrappingLabel) labelFigure).getText();
+
+ Assert.assertNotNull(label);
+ Assert.assertTrue("The label content is not the one expected", label.startsWith(expectedLabel));
+
+ }
+
/**
* Test the apply and unapply stereotype on a Interface
*/
@@ -78,6 +106,18 @@ public class AppliedStereotypeDisplayCompartmentClassDiagramTest extends Abstrac
}
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AbstractAppliedStereotypeDisplayTest#testLabel(java.lang.String)
+ *
+ * @param expectedLabel
+ * The Expected text for this Label
+ */
+ @Override
+ protected void testLabel(String expectedLabel) {
+ testCompartmentLabelContent(expectedLabel);
+
+ }
+
/**
* Test the apply and unapply stereotype on a property of a class
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayLinkClassDiagramTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayLinkClassDiagramTest.java
new file mode 100644
index 00000000000..4617e34ff6f
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayLinkClassDiagramTest.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2015, 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display;
+
+import java.util.Arrays;
+
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure;
+import org.eclipse.uml2.uml.Association;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * This Class tests the application and unapplication of stereotype on Links
+ *
+ * @author Céline JANSSENS
+ *
+ */
+@SuppressWarnings("nls")
+@PluginResource("/resources/StereotypeDisplay/StereotypeDisplayClassDiagramModel.di")
+public class AppliedStereotypeDisplayLinkClassDiagramTest extends AbstractAppliedStereotypeDisplayTest {
+
+ @Test
+ public void testApplyStereotypeOnLink() {
+
+ setElementAndTest(ASSOCIATION_NAME, Association.class);
+
+ // Apply 1 stereotypes and test structure and Label content
+ applyStereotype(Arrays.asList(stereotypeA));
+ testStructure(1, 0, 0, 1);
+ testLinkLabelContent(String.valueOf("\u00AB") + "stereoA" + String.valueOf("\u00BB"));
+ testOrphanComment(1);
+
+ // UnApply 1 stereotype and test structure and Label content
+ unapplyStereotype(Arrays.asList(stereotypeA));
+ testStructure(0, 0, 0, 0);
+ testLinkLabelContent("");
+ testOrphanComment(0);
+
+ }
+
+ /**
+ * Test the stereotype Link Label Text and compare it to the expected String
+ *
+ * @param string
+ */
+ protected void testLinkLabelContent(String expectedLabel) {
+ // Check the Label content
+ Assert.assertNotNull(editPart);
+ Assert.assertTrue(editPart instanceof UMLConnectionNodeEditPart);
+ Assert.assertTrue(((IPapyrusEditPart) editPart).getPrimaryShape() instanceof UMLEdgeFigure);
+ WrappingLabel label = ((UMLEdgeFigure) ((IPapyrusEditPart) editPart).getPrimaryShape()).getAppliedStereotypeLabel();
+
+ if (expectedLabel == null) {
+ Assert.assertNull("Label stereotype should be null", label);
+ } else {
+ Assert.assertNotNull("The Label Stereotype should not be null ", label);
+ String labelText = label.getText();
+ Assert.assertEquals("The label content is not the one expected", expectedLabel, labelText);
+
+ }
+
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AbstractAppliedStereotypeDisplayTest#testLabel(java.lang.String)
+ *
+ * @param expectedLabel
+ * Expected Text for the Label
+ */
+ @Override
+ protected void testLabel(String expectedLabel) {
+ testLinkLabelContent(expectedLabel);
+
+ }
+
+
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayNodeClassDiagramTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayNodeClassDiagramTest.java
index afbe83bea78..b9fbcd2637c 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayNodeClassDiagramTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/stereotype/display/AppliedStereotypeDisplayNodeClassDiagramTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
+ * Copyright (c) 2015, 2018 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,22 +10,27 @@
*
* Contributors:
* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and Implementation
-* Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 471584 : Stereotype Display Unit Tests
- *
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 471584 : Stereotype Display Unit Tests
+ * Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display;
import java.util.Arrays;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
import org.eclipse.uml2.uml.Enumeration;
+import org.junit.Assert;
import org.junit.Test;
/**
- *
+ *
* This Class tests the Stereotype Display of a Class Diagram
- *
+ *
* @author Céline JANSSENS
*
*/
@@ -135,5 +140,43 @@ public class AppliedStereotypeDisplayNodeClassDiagramTest extends AbstractApplie
}
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AbstractAppliedStereotypeDisplayTest#testLabel(java.lang.String)
+ *
+ * @param expectedLabel
+ * Expected text of the Label
+ */
+ @Override
+ protected void testLabel(final String expectedLabel) {
+ testNodeLabelContent(expectedLabel);
+
+ }
+
+ /**
+ * Tests the Content of Named Node Label
+ *
+ * @param expectedLabel
+ * The expected label Text
+ */
+ protected void testNodeLabelContent(final String expectedLabel) {
+ // Check the Label content
+ Assert.assertNotNull(editPart);
+ Assert.assertTrue(editPart instanceof IPapyrusEditPart);
+ final IFigure figure = ((IPapyrusEditPart) editPart).getPrimaryShape();
+ Assert.assertTrue(figure instanceof NodeNamedElementFigure);
+ PapyrusWrappingLabel label = ((NodeNamedElementFigure) figure).getStereotypesLabel();
+
+ if (expectedLabel == null) {
+ Assert.assertNull("Label stereotype should be null", label);
+ } else {
+ Assert.assertNotNull("The Label Stereotype should not be null ", label);
+ String labelText = label.getText();
+ Assert.assertEquals("The label content is not the one expected", expectedLabel, labelText);
+
+ }
+
+ }
+
+
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
index 7cf200c56aa..ce04574c2bd 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2017 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2017, 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 2.0
@@ -12,7 +12,8 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus - bug 471954
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 507488
- * Micka�l ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 518645
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 518645
+ Celine Janssens (All4Tec) celine.janssens@all4tec.net - Bug 472342
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.tests.tests;
@@ -25,6 +26,7 @@ import org.eclipse.papyrus.uml.diagram.common.tests.parser.HTMLCornerBentFigureT
import org.eclipse.papyrus.uml.diagram.common.tests.parser.MultiplicityStringFormatterTestCase;
import org.eclipse.papyrus.uml.diagram.common.tests.parser.ValueSpecificationUtilTestCase;
import org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AppliedStereotypeDisplayCompartmentClassDiagramTest;
+import org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AppliedStereotypeDisplayLinkClassDiagramTest;
import org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AppliedStereotypeDisplayNodeClassDiagramTest;
import org.eclipse.papyrus.uml.diagram.common.tests.stereotype.display.AppliedStereotypeDisplayStructureTest;
import org.junit.runner.RunWith;
@@ -35,6 +37,7 @@ import org.junit.runners.Suite.SuiteClasses;
AppliedStereotypeDisplayStructureTest.class,
AppliedStereotypeDisplayNodeClassDiagramTest.class,
AppliedStereotypeDisplayCompartmentClassDiagramTest.class,
+ AppliedStereotypeDisplayLinkClassDiagramTest.class,
CommonBendpointsTest.class,
HTMLCleanerTestCase.class,
HTMLCornerBentFigureTestCase.class,

Back to the top