Bug 476649 - [SysML 1.4][Test] Add unit test for the class
ConformCreationEditHelperAdvice.java
- add test for ConformCreationEditHelperAdvice
- patch javadoc namspaces in tests
- use assert instead of fail
Change-Id: Ia0a95721f46ace6314cb16db7b16e992c2f88928
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
diff --git a/core/org.eclipse.papyrus.sysml14.service.types.tests/META-INF/MANIFEST.MF b/core/org.eclipse.papyrus.sysml14.service.types.tests/META-INF/MANIFEST.MF
index d75f7a6..a3a6969 100644
--- a/core/org.eclipse.papyrus.sysml14.service.types.tests/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.papyrus.sysml14.service.types.tests/META-INF/MANIFEST.MF
@@ -1,13 +1,14 @@
-Manifest-Version: 1.0
-Fragment-Host: org.eclipse.papyrus.sysml14.service.types;bundle-version="0.8.0"
-Export-Package: org.eclipse.papyrus.sysml14.service.types.tests
-Bundle-Vendor: %providerName
-Bundle-Version: 0.8.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.sysml14.service.types.tests
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Require-Bundle: org.junit,
- org.eclipse.papyrus.infra.services.edit
-
+Manifest-Version: 1.0
+Fragment-Host: org.eclipse.papyrus.sysml14.service.types;bundle-version="0.8.0"
+Export-Package: org.eclipse.papyrus.sysml14.service.types.tests
+Bundle-Vendor: %providerName
+Bundle-Version: 0.8.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.sysml14.service.types.tests
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.junit,
+ org.eclipse.papyrus.infra.services.edit;bundle-version="0.8.0",
+ org.eclipse.papyrus.sysml14.tests;bundle-version="0.8.0"
+
diff --git a/core/org.eclipse.papyrus.sysml14.service.types.tests/src/org/eclipse/papyrus/sysml14/service/types/tests/advice/ConformCreationEditHelperAdviceTest.java b/core/org.eclipse.papyrus.sysml14.service.types.tests/src/org/eclipse/papyrus/sysml14/service/types/tests/advice/ConformCreationEditHelperAdviceTest.java
new file mode 100644
index 0000000..2f843d5
--- /dev/null
+++ b/core/org.eclipse.papyrus.sysml14.service.types.tests/src/org/eclipse/papyrus/sysml14/service/types/tests/advice/ConformCreationEditHelperAdviceTest.java
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ *
+ * 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:
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml14.service.types.tests.advice;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.registries.ElementTypeSetConfigurationRegistry;
+import org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage;
+import org.eclipse.papyrus.sysml14.service.types.advice.ConformCreationEditHelperAdvice;
+import org.eclipse.papyrus.sysml14.service.types.util.SysMLServiceTypeUtil;
+import org.eclipse.papyrus.sysml14.tests.SysMLTestResources;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test class for conform creation
+ *
+ */
+public class ConformCreationEditHelperAdviceTest{
+
+ @BeforeClass
+ public static void loadSysml14Defintion() {
+ ElementTypeSetConfigurationRegistry instance = ElementTypeSetConfigurationRegistry.getInstance();
+ ElementTypeSetConfiguration elementTypeSetConfiguration = instance.getElementTypeSetConfigurations().get("org.eclipse.papyrus.sysml14.service.types.elementTypeSet");
+ Assert.assertNotNull("The SysML 1.4 element type set definition is missing", elementTypeSetConfiguration);
+
+ }
+
+ /**
+ * A Class with the stereotype Viewpoint
+ */
+ private org.eclipse.uml2.uml.Class classStereotypeViewpoint;
+
+ /**
+ * A Class with the stereotype View
+ */
+ private org.eclipse.uml2.uml.Class classStereotypeView;
+
+ @Before
+ public void setUp() {
+ // Prepare test
+ Model model = SysMLTestResources.createSysMLModel(new ResourceSetImpl());
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
+ StereotypeApplicationHelper stereotypeApplicationHelper = StereotypeApplicationHelper.getInstance(null);
+ classStereotypeViewpoint = model.createOwnedClass("classStereotypeViewpoint", false);
+ stereotypeApplicationHelper.applyStereotype(classStereotypeViewpoint, ModelelementsPackage.eINSTANCE.getViewpoint());
+ classStereotypeView = model.createOwnedClass("classStereotypeView", false);
+ stereotypeApplicationHelper.applyStereotype(classStereotypeView, ModelelementsPackage.eINSTANCE.getView());
+ }
+
+
+ /**
+ * Test if the creation of conform following SysML requirements
+ */
+ @Test
+ public void testApproveRequest() {
+ ConformCreationEditHelperAdvice conformCreationEditHelperAdvice = new ConformCreationEditHelperAdvice();
+ IElementType type = ElementTypeRegistry.getInstance().getType(SysMLServiceTypeUtil.ORG_ECLIPSE_PAPYRUS_SYSML14_CONFORM);
+
+ IEditCommandRequest invalidRequest = new CreateRelationshipRequest(type);
+ Assert.assertFalse("Creation should forbiden for a conform not linked to any elements", conformCreationEditHelperAdvice.approveRequest(invalidRequest));
+
+ IEditCommandRequest validRequest = new CreateRelationshipRequest(classStereotypeView, classStereotypeViewpoint, type);
+ Assert.assertTrue("Conform is allow from a View to a Viewpoint", conformCreationEditHelperAdvice.approveRequest(validRequest));
+
+ }
+
+}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/META-INF/MANIFEST.MF b/core/org.eclipse.papyrus.sysml14.tests/META-INF/MANIFEST.MF
index 109d430..eec41d4 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.papyrus.sysml14.tests/META-INF/MANIFEST.MF
@@ -1,27 +1,28 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.papyrus.sysml14.tests;singleton:=true
-Bundle-Version: 0.8.0.qualifier
-Bundle-ClassPath: .
-Bundle-Vendor: %providerName
-Bundle-Description: %pluginDescription
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.emf.ecore;visibility:=reexport,
- org.eclipse.uml2.uml.profile.standard;visibility:=reexport,
- org.eclipse.uml2.types;visibility:=reexport,
- org.eclipse.uml2.uml;visibility:=reexport,
- org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.eclipse.ui;bundle-version="3.107.0",
- org.junit;bundle-version="4.10.0",
- org.eclipse.papyrus.sysml14;bundle-version="0.8.0",
- org.eclipse.papyrus.junit.framework;bundle-version="1.1.0",
- org.eclipse.papyrus.junit.utils;bundle-version="1.1.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.1.0",
- org.eclipse.gmf.runtime.emf.core;bundle-version="1.7.0",
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.9.0",
- org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.1.0",
- org.eclipse.uml2.uml.resources;bundle-version="5.1.0"
-Bundle-ActivationPolicy: lazy
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.sysml14.tests;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-ClassPath: .
+Bundle-Vendor: %providerName
+Bundle-Description: %pluginDescription
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;visibility:=reexport,
+ org.eclipse.uml2.uml.profile.standard;visibility:=reexport,
+ org.eclipse.uml2.types;visibility:=reexport,
+ org.eclipse.uml2.uml;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.eclipse.ui;bundle-version="3.107.0",
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.papyrus.sysml14;bundle-version="0.8.0",
+ org.eclipse.papyrus.junit.framework;bundle-version="1.1.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="1.1.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.1.0",
+ org.eclipse.gmf.runtime.emf.core;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.9.0",
+ org.eclipse.papyrus.infra.elementtypesconfigurations;bundle-version="1.1.0",
+ org.eclipse.uml2.uml.resources;bundle-version="5.1.0"
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.sysml14.tests
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/SysMLTestResources.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/SysMLTestResources.java
index d129166..6942329 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/SysMLTestResources.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/SysMLTestResources.java
@@ -31,6 +31,7 @@
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.util.UMLUtil;
+// TODO : this class should be "cleaned" and offered as API (official version to programmatically create a SysML model)
public final class SysMLTestResources {
private SysMLTestResources(){}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/deprecatedelements/FlowPortTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/deprecatedelements/FlowPortTest.java
index 5209b3e..45e3864 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/deprecatedelements/FlowPortTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/deprecatedelements/FlowPortTest.java
@@ -14,8 +14,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.deprecatedelements;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.deprecatedelements.DeprecatedelementsFactory;
@@ -33,6 +31,7 @@
import org.eclipse.uml2.uml.util.UMLUtil;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -43,14 +42,14 @@
* <p>
* The following features are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.portandflows.FlowPort#isAtomic()
+ * <li>{@link org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#isAtomic()
* <em>Is Atomic</em>}</li>
* </ul>
* </p>
* <p>
* The following operations are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.portandflows.FlowPort#getIcon()
+ * <li>{@link org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#getIcon()
* <em>Get Icon</em>}</li>
* </ul>
* </p>
@@ -82,9 +81,7 @@
private Model model = null;
/**
- * Returns the fixture for this Flow Port test case. <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
+ * Returns the fixture for this Flow Port test case.
*
*/
protected FlowPort getFixture() {
@@ -92,9 +89,7 @@
}
/**
- * Sets the fixture for this Flow Port test case. <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
+ * Sets the fixture for this Flow Port test case.
*
*/
protected void setFixture(FlowPort fixture) {
@@ -111,9 +106,8 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
- if (model.getAppliedProfiles().isEmpty()) {
- fail("the SysML profil must be applied.");
- }
+
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
// Create classes & interface
c0 = model.createOwnedClass("c0", false);
@@ -147,7 +141,7 @@
}
/**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
*
* @see junit.framework.TestCase#tearDown()
*
@@ -159,32 +153,23 @@
/**
* Tests the '
- * {@link org.eclipse.papyrus.sysml.portandflows.FlowPort#isAtomic()
- * <em>Is Atomic</em>}' feature getter. <!-- begin-user-doc --> <!--
- * end-user-doc -->
+ * {@link org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#isAtomic()
+ * <em>Is Atomic</em>}' feature getter.
*
- * @see org.eclipse.papyrus.sysml.portandflows.FlowPort#isAtomic()
+ * @see org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#isAtomic()
*/
@Test
- public void testIsAtomic() {
- if (!fpDefault.isAtomic()) {
- fail("FlowPort without type is Atomic");
- }
-
- if (!fpOut.isAtomic()) {
- fail("FlowPort type is not a FlowSpecification");
- }
-
- if (fpIn.isAtomic()) {
- fail("FlowPort type is a FlowSpecification");
- }
+ public void testIsAtomic() {
+ Assert.assertTrue("FlowPort without type is Atomic", fpDefault.isAtomic());
+ Assert.assertTrue("FlowPort type is not a FlowSpecification",fpOut.isAtomic());
+ Assert.assertFalse("FlowPort type is a FlowSpecification", fpIn.isAtomic());
}
/**
* Tests the '
- * {@link org.eclipse.papyrus.sysml.portandflows.FlowPort#getIcon() <em>Get Icon</em>}' operation.
+ * {@link org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#getIcon() <em>Get Icon</em>}' operation.
*
- * @see org.eclipse.papyrus.sysml.portandflows.FlowPort#getIcon()
+ * @see org.eclipse.papyrus.sysml14.deprecatedelements.FlowPort#getIcon()
*
*/
@Test
@@ -193,17 +178,10 @@
Image imageIn = s.getIcons().get(FlowDirection.IN.getValue()); // IN
Image imageOut = s.getIcons().get(FlowDirection.OUT.getValue()); // OUT
Image imageInOut = s.getIcons().get(FlowDirection.INOUT.getValue()); // INOUT
-
- if(!fpDefault.getIcon().equals(imageInOut)) {
- fail("A Flow property with an IN direction must have the IN image");
- }
+
+ Assert.assertEquals("A Flow property with an INOUT direction must have the INOUT image",imageInOut,fpDefault.getIcon());
+ Assert.assertEquals("A Flow property with an OUT direction must have the OUT image",imageOut,fpOut.getIcon());
+ Assert.assertEquals("A Flow property with an IN direction must have the IN image",imageIn,fpIn.getIcon());
- if(!fpOut.getIcon().equals(imageOut)) {
- fail("A Flow property with an OUT direction must have the OUT image");
- }
-
- if(!fpIn.getIcon().equals(imageIn)) {
- fail("A Flow property with an INOUT direction must have the INOUT image");
- }
}
}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ElementGroupTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ElementGroupTest.java
index 8555d35..48bf6a8 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ElementGroupTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ElementGroupTest.java
@@ -13,8 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.modelelements;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.modelelements.ElementGroup;
@@ -26,6 +24,7 @@
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -36,9 +35,9 @@
* <p>
* The following features are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.ElementGroupTest#testGetCriterion <em>Criterion</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.ElementGroupTest#testGetSize <em>Size</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.ElementGroupTest#testGetMember <em>Member</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getCriterion <em>Criterion</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getSize <em>Size</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getMember <em>Member</em>}</li>
* </ul>
* </p>
*/
@@ -86,9 +85,8 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
- if(model.getAppliedProfiles().isEmpty()) {
- fail(" the Sysml profil has not be applied.");
- }
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
+
// Create comments & class
defaultComment= model.createOwnedComment();
default_elementgroup = (ElementGroup)StereotypeApplicationHelper.getInstance(null).applyStereotype(defaultComment, ModelelementsPackage.eINSTANCE.getElementGroup());
@@ -110,39 +108,31 @@
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.ElementGroup#getCriterion()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getCriterion()
* <em>criterion</em>}' feature getter.
- * @seeorg.eclipse.papyrus.sysml.modelelements.ElementGroup#getCriterion()
+ * @see org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getCriterion()
*/
@Test
public void testGetCriterion() {
- if(!CRITERION.equals(default_elementgroup.getCriterion())){
- fail("The criterion of Elementgroup is badly computed, it must be equals to the body of the comment");
- }
+ Assert.assertEquals("The criterion of Elementgroup is badly computed, it must be equals to the body of the comment",CRITERION, default_elementgroup.getCriterion());
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.ElementGroup#getSize()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getSize()
* <em>Size</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.ElementGroup#getSize()
+ * @see org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getSize()
*/
@Test
public void testGetSize() {
- if(default_elementgroup.getSize()!=2){
- fail("Size of ElementGroup is badly computed. It must contain two elements");
- }
+ Assert.assertEquals("Size of ElementGroup is badly computed. It must contain two elements",2,default_elementgroup.getSize());
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.ElementGroup#getMember()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getMember()
* <em>Member</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.ElementGroup#getMember()
+ * @see org.eclipse.papyrus.sysml14.modelelements.ElementGroup#getMember()
*/
@Test
public void testGetMember() {
- if(!class1.equals(default_elementgroup.getMember().get(0))){
- fail("Member of elementGroup is badly computed, the content of the list member is not correct");
- }
- if(!class2.equals(default_elementgroup.getMember().get(1))){
- fail("Member of elementGroup is badly computed, the content of the list member is not correct");
- }
+ Assert.assertEquals("Member of elementGroup is badly computed, the content of the list member is not correct",class1,default_elementgroup.getMember().get(0));
+ Assert.assertEquals("Member of elementGroup is badly computed, the content of the list member is not correct",class2,default_elementgroup.getMember().get(1));
}
}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/StakeholderTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/StakeholderTest.java
index 3aef7c0..fae2255 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/StakeholderTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/StakeholderTest.java
@@ -1,134 +1,127 @@
-/*****************************************************************************
- * Copyright (c) 2009, 2014 CEA LIST 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:
- * Patrick Tessier (CEA LIST)Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml14.tests.modelelements;
-
-import static org.junit.Assert.fail;
-
-import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
-import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
-import org.eclipse.papyrus.sysml14.modelelements.ModelelementsFactory;
-import org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage;
-import org.eclipse.papyrus.sysml14.modelelements.Stakeholder;
-import org.eclipse.papyrus.sysml14.tests.SysMLTestResources;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-/**
- * A test case for the model object '<em><b>Stakeholder</b></em>'.
- * See the requirement <b>{@papyrus.req org.eclipse.papyrus.sysml14#Req012}</b>.
- * <p>
- * The following features are tested:
- * <ul>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.StakeholderTest#testGetConcern <em>Concern</em>}</li>
- * </ul>
- * </p>
- */
-public class StakeholderTest extends AbstractPapyrusTest {
-
- private static final String THIS_IS_THE_BODY_OF_COMMENT2 = "this is the body of comment2";
-
- private static final String THIS_IS_THE_BODY_OF_COMMENT1 = "this is the body of comment1";
-
- @Rule
- public final HouseKeeper houseKeeper = new HouseKeeper();
-
- private Stakeholder fixture = null;
-
- private Model model = null;
-
- private Class defaultClass= null;
-
- private Stakeholder default_stakeholder= null;
-
- private Comment comment1= null;
-
- private Comment comment2= null;
-
- /**
- * Returns the fixture for this stakeholder test case.
- */
- protected Stakeholder getFixture() {
- return fixture;
- }
-
- /**
- * Sets the fixture for this stakeholder test case.
- */
- protected void setFixture(Stakeholder fixture) {
- this.fixture = fixture;
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Before
- public void setUp() {
- setFixture(ModelelementsFactory.eINSTANCE.createStakeholder());
-
- // Prepare test
- model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
-
-
- if(model.getAppliedProfiles().isEmpty()) {
- fail(" the profile Sysml has not be applied.");
- }
- // Create classes & interface
- defaultClass = model.createOwnedClass("defaultClass", false);
-
- // Add stakeholder stereotypes
- default_stakeholder = (Stakeholder)StereotypeApplicationHelper.getInstance(null).applyStereotype(defaultClass, ModelelementsPackage.eINSTANCE.getStakeholder());
- comment1=UMLFactory.eINSTANCE.createComment();
- comment1.setBody(THIS_IS_THE_BODY_OF_COMMENT1);
- model.getOwnedComments().add(comment1);
- comment2=UMLFactory.eINSTANCE.createComment();
- comment2.setBody(THIS_IS_THE_BODY_OF_COMMENT2);
- model.getOwnedComments().add(comment2);
- default_stakeholder.getConcernList().add(comment1);
- default_stakeholder.getConcernList().add(comment2);
- }
-
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- @After
- public void tearDown(){
- setFixture(null);
- }
-
- /**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.Stakeholder#getConcern()
- * <em>concern</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.Stakeholder#getConcern()
- */
- @Test
- public void testGetConcern() {
- if(default_stakeholder.getConcern().size()!=2){
- fail("The derived property concern is badly calculated, the size of the list must be 2.");
- }
- if(!THIS_IS_THE_BODY_OF_COMMENT1.equals((default_stakeholder.getConcern().get(0)))){
- fail("The derived property concern is badly calculated, the body of the first comment is not at the first place");
- }
- if(!THIS_IS_THE_BODY_OF_COMMENT2.equals((default_stakeholder.getConcern().get(1)))){
- fail("The derived property concern is badly calculated, the body of the second comment is not à the second place");
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2009, 2014 CEA LIST 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:
+ * Patrick Tessier (CEA LIST)Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml14.tests.modelelements;
+
+
+
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.sysml14.modelelements.ModelelementsFactory;
+import org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage;
+import org.eclipse.papyrus.sysml14.modelelements.Stakeholder;
+import org.eclipse.papyrus.sysml14.tests.SysMLTestResources;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * A test case for the model object '<em><b>Stakeholder</b></em>'.
+ * See the requirement <b>{@papyrus.req org.eclipse.papyrus.sysml14#Req012}</b>.
+ * <p>
+ * The following features are tested:
+ * <ul>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.StakeholderTest#testGetConcern <em>Concern</em>}</li>
+ * </ul>
+ * </p>
+ */
+public class StakeholderTest extends AbstractPapyrusTest {
+
+ private static final String THIS_IS_THE_BODY_OF_COMMENT2 = "this is the body of comment2";
+
+ private static final String THIS_IS_THE_BODY_OF_COMMENT1 = "this is the body of comment1";
+
+ @Rule
+ public final HouseKeeper houseKeeper = new HouseKeeper();
+
+ private Stakeholder fixture = null;
+
+ private Model model = null;
+
+ private Class defaultClass= null;
+
+ private Stakeholder default_stakeholder= null;
+
+ private Comment comment1= null;
+
+ private Comment comment2= null;
+
+ /**
+ * Returns the fixture for this stakeholder test case.
+ */
+ protected Stakeholder getFixture() {
+ return fixture;
+ }
+
+ /**
+ * Sets the fixture for this stakeholder test case.
+ */
+ protected void setFixture(Stakeholder fixture) {
+ this.fixture = fixture;
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Before
+ public void setUp() {
+ setFixture(ModelelementsFactory.eINSTANCE.createStakeholder());
+
+ // Prepare test
+ model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
+
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
+
+ // Create classes & interface
+ defaultClass = model.createOwnedClass("defaultClass", false);
+
+ // Add stakeholder stereotypes
+ default_stakeholder = (Stakeholder)StereotypeApplicationHelper.getInstance(null).applyStereotype(defaultClass, ModelelementsPackage.eINSTANCE.getStakeholder());
+ comment1=UMLFactory.eINSTANCE.createComment();
+ comment1.setBody(THIS_IS_THE_BODY_OF_COMMENT1);
+ model.getOwnedComments().add(comment1);
+ comment2=UMLFactory.eINSTANCE.createComment();
+ comment2.setBody(THIS_IS_THE_BODY_OF_COMMENT2);
+ model.getOwnedComments().add(comment2);
+ default_stakeholder.getConcernList().add(comment1);
+ default_stakeholder.getConcernList().add(comment2);
+ }
+
+ /**
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @After
+ public void tearDown(){
+ setFixture(null);
+ }
+
+ /**
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.Stakeholder#getConcern()
+ * <em>concern</em>}' feature getter.
+ * @see org.eclipse.papyrus.sysml14.modelelements.Stakeholder#getConcern()
+ */
+ @Test
+ public void testGetConcern() {
+ Assert.assertEquals("The derived property concern is badly calculated, the size of the list must be 2.", 2, default_stakeholder.getConcern().size());
+ Assert.assertEquals("The derived property concern is badly calculated, the body of the first comment is not at the first place",THIS_IS_THE_BODY_OF_COMMENT1,default_stakeholder.getConcern().get(0));
+ Assert.assertEquals("The derived property concern is badly calculated, the body of the second comment is not à the second place",THIS_IS_THE_BODY_OF_COMMENT2,default_stakeholder.getConcern().get(1));
+ }
+
+}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewPointTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewPointTest.java
index 3811e89..381eb1e 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewPointTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewPointTest.java
@@ -13,8 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.modelelements;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.modelelements.ModelelementsFactory;
@@ -31,6 +29,7 @@
import org.eclipse.uml2.uml.profile.standard.StandardPackage;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,8 +40,8 @@
* <p>
* The following features are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.ViewPointTest#testGetConcern <em>Concern</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.modelelements.ViewPointTest#testGetGetMethod <em>Method</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.Viewpoint#getConcern <em>Concern</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.modelelements.Viewpoint#getMethod <em>Method</em>}</li>
* </ul>
* </p>
*/
@@ -61,7 +60,7 @@
private Class defaultClass = null;
- private Viewpoint default_viewpoint = null;
+ private Viewpoint defaultViewpoint = null;
private Comment comment1 = null;
@@ -72,7 +71,7 @@
private Behavior ownedBehavior = null;
/**
- * Returns the fixture for this stakeholder test case.
+ * Returns the fixture for this viewpoint test case.
*/
protected Viewpoint getFixture() {
return fixture;
@@ -95,23 +94,22 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
- if(model.getAppliedProfiles().isEmpty()) {
- fail();
- }
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
+
// Create classes & interface
defaultClass = model.createOwnedClass("defaultClass", false);
// Add viewPoint stereotypes
StereotypeApplicationHelper stereotypeApplicationHelper = StereotypeApplicationHelper.getInstance(null);
- default_viewpoint = (Viewpoint)stereotypeApplicationHelper.applyStereotype(defaultClass, ModelelementsPackage.eINSTANCE.getViewpoint());
+ defaultViewpoint = (Viewpoint)stereotypeApplicationHelper.applyStereotype(defaultClass, ModelelementsPackage.eINSTANCE.getViewpoint());
comment1=UMLFactory.eINSTANCE.createComment();
comment1.setBody(THIS_IS_THE_BODY_OF_COMMENT1);
model.getOwnedComments().add(comment1);
comment2=UMLFactory.eINSTANCE.createComment();
comment2.setBody(THIS_IS_THE_BODY_OF_COMMENT2);
model.getOwnedComments().add(comment2);
- default_viewpoint.getConcernList().add(comment1);
- default_viewpoint.getConcernList().add(comment2);
+ defaultViewpoint.getConcernList().add(comment1);
+ defaultViewpoint.getConcernList().add(comment2);
createOperation= UMLFactory.eINSTANCE.createOperation();
createOperation.setName("View");
defaultClass.getOwnedOperations().add(createOperation);
@@ -129,34 +127,24 @@
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.viewpoint#getConcern()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.viewpoint#getConcern()
* <em>concern</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.viewpoint#getConcern()
+ * @see org.eclipse.papyrus.sysml14.modelelements.viewpoint#getConcern()
*/
@Test
public void testGetConcern() {
- if(default_viewpoint.getConcern().size()!=2){
- fail("The derived property concern is badly calculated.The size of the list must 2.");
- }
- if(!THIS_IS_THE_BODY_OF_COMMENT1.equals((default_viewpoint.getConcern().get(0)))){
- fail("The derived property concern is badly calculated. Concern must contain at the first place the body of the first comment");
- }
- if(!THIS_IS_THE_BODY_OF_COMMENT2.equals((default_viewpoint.getConcern().get(1)))){
- fail("The derived property concern is badly calculated. Concern must contain at the second place the body of the second comment");
- }
+ Assert.assertEquals("The derived property concern is badly calculated.The size of the list must 2.", 2, defaultViewpoint.getConcern().size());
+ Assert.assertEquals("The derived property concern is badly calculated. Concern must contain at the first place the body of the first comment",THIS_IS_THE_BODY_OF_COMMENT1,defaultViewpoint.getConcern().get(0));
+ Assert.assertEquals("The derived property concern is badly calculated. Concern must contain at the second place the body of the second comment",THIS_IS_THE_BODY_OF_COMMENT2,defaultViewpoint.getConcern().get(1));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.viewpoint#getBehavior()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.viewpoint#getBehavior()
* <em>behavior</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.viewpoint#getBehavior()
+ * @see org.eclipse.papyrus.sysml14.modelelements.viewpoint#getBehavior()
*/
@Test
public void testGetMethod() {
- if(default_viewpoint.getMethod().size()!=1){
- fail("The derived property method is badly calculated. The size of the list must 1");
- }
- if(!ownedBehavior.equals((default_viewpoint.getMethod().get(0)))){
- fail("The derived property method is badly calculated. The view point must contained in the list");
- }
+ Assert.assertEquals("The derived property method is badly calculated. The size of the list must 1",1,defaultViewpoint.getMethod().size());
+ Assert.assertEquals("The derived property method is badly calculated. The view point must contained in the list",ownedBehavior,defaultViewpoint.getMethod().get(0));
}
}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewTest.java
index 0326824..9e627a0 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/modelelements/ViewTest.java
@@ -13,8 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.modelelements;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.modelelements.ModelelementsFactory;
@@ -28,6 +26,7 @@
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -89,10 +88,7 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
-
- if(model.getAppliedProfiles().isEmpty()) {
- fail();
- }
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
// Create class
default_class = model.createOwnedClass("View1", false);
@@ -127,35 +123,24 @@
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.View#getViewPoint()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.View#getViewPoint()
* <em>View Point</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.View#getViewPoint()
+ * @see org.eclipse.papyrus.sysml14.modelelements.View#getViewPoint()
*/
@Test
public void testGetViewPoint() {
-
- if(default_view.getViewPoint()==null) {
- fail("The derived property viewpoint is baldy computed for View, it must not be null");
- }
-
- if(!default_view.getViewPoint().equals(viewpoint)) {
- fail("The derived property viewpoint is baldy computed for View, it must not be equal to view point");
- }
+ Assert.assertNotNull("The derived property viewpoint is baldy computed for View, it must not be null", default_view.getViewPoint());
+ Assert.assertEquals("The derived property viewpoint is baldy computed for View, it must not be equal to view point",viewpoint, default_view.getViewPoint());
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.modelelements.View#getStakeholder()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.modelelements.View#getStakeholder()
* <em>Stakeholder</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.modelelements.View#getStakeholder()
+ * @see org.eclipse.papyrus.sysml14.modelelements.View#getStakeholder()
*/
@Test
public void testGetStakeholder() {
- if(!(default_view.getStakeholder().size()==1)) {
- fail("The derived property Stakeholder is baldy computed for View, it must not be equal to 1");
- }
-
- if(!default_view.getStakeholder().contains(stakeholder)) {
- fail("The derived property Stakeholder is baldy computed for View, it must not be equal to the stakeholder");
- }
+ Assert.assertEquals("The derived property Stakeholder is baldy computed for View, it must not be equal to 1",1, default_view.getStakeholder().size());
+ Assert.assertTrue("The derived property Stakeholder is baldy computed for View, it must not be equal to the stakeholder",default_view.getStakeholder().contains(stakeholder));
}
}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/portandflows/FlowPropertyTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/portandflows/FlowPropertyTest.java
index f35ecf7..09f9ea8 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/portandflows/FlowPropertyTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/portandflows/FlowPropertyTest.java
@@ -14,8 +14,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.portandflows;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.portandflows.FlowDirection;
@@ -31,6 +29,7 @@
import org.eclipse.uml2.uml.util.UMLUtil;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -40,13 +39,13 @@
* <p>
* The following operations are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.portandflows.FlowProperty#getIcon() <em>Get Icon</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.portandflows.FlowProperty#getIcon() <em>Get Icon</em>}</li>
* </ul>
* </p>
* <p>
* The following operations are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.portandflows.FlowProperty#getIcon()
+ * <li>{@link org.eclipse.papyrus.sysm14.portandflows.FlowProperty#getIcon()
* <em>Get Icon</em>}</li>
* </ul>
* </p>
@@ -92,9 +91,7 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
- if(model.getAppliedProfiles().isEmpty()) {
- fail("the SysML profil must be applied.");
- }
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
// Create interface
i = model.createOwnedInterface("i");
@@ -125,10 +122,10 @@
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.portandflows.FlowProperty#getIcon()
+ * Tests the '{@link org.eclipse.papyrus.sysm14.portandflows.FlowProperty#getIcon()
* <em>Get Icon</em>}' operation.
*
- * @see org.eclipse.papyrus.sysml.portandflows.FlowProperty#getIcon()
+ * @see org.eclipse.papyrus.sysm14.portandflows.FlowProperty#getIcon()
*
*/
@Test
@@ -138,17 +135,9 @@
Image imageOut = s.getIcons().get(FlowDirection.OUT.getValue()); // OUT
Image imageInOut = s.getIcons().get(FlowDirection.INOUT.getValue()); // INOUT
- if(!fpIn.getIcon().equals(imageIn)) {
- fail("A Flow property with an IN direction must have the IN image");
- }
-
- if(!fpOut.getIcon().equals(imageOut)) {
- fail("A Flow property with an OUT direction must have the OUT image");
- }
-
- if(!fpInOut.getIcon().equals(imageInOut)) {
- fail("A Flow property with an INOUT direction must have the INOUT image");
- }
+ Assert.assertEquals("A Flow property with an INOUT direction must have the INOUT image",imageInOut,fpInOut.getIcon());
+ Assert.assertEquals("A Flow property with an OUT direction must have the OUT image",imageOut,fpOut.getIcon());
+ Assert.assertEquals("A Flow property with an IN direction must have the IN image",imageIn,fpIn.getIcon());
}
}
diff --git a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/requirements/RequirementTest.java b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/requirements/RequirementTest.java
index 84ea2b6..764dfc3 100644
--- a/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/requirements/RequirementTest.java
+++ b/core/org.eclipse.papyrus.sysml14.tests/src/org/eclipse/papyrus/sysml14/tests/requirements/RequirementTest.java
@@ -14,8 +14,6 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml14.tests.requirements;
-import static org.junit.Assert.fail;
-
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
import org.eclipse.papyrus.sysml14.requirements.Requirement;
@@ -32,24 +30,25 @@
import org.eclipse.uml2.uml.profile.standard.StandardPackage;
import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
/**
- * <!-- begin-user-doc --> A test case for the model object '<em><b>Requirement</b></em>'. <!--
- * end-user-doc -->
+ * A test case for the model object '<em><b>Requirement</b></em>'.
+ *
* See the requirement org.eclipse.papyrus.sysml14.Req011
* <p>
* The following features are tested:
* <ul>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getDerived() <em>Derived</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getDerivedFrom() <em>Derived From</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getSatisfiedBy() <em>Satisfied By</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getRefinedBy() <em>Refined By</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getTracedTo() <em>Traced To</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getVerifiedBy() <em>Verified By</em>}</li>
- * <li>{@link org.eclipse.papyrus.sysml.requirements.Requirement#getMaster() <em>Master</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getDerived() <em>Derived</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getDerivedFrom() <em>Derived From</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getSatisfiedBy() <em>Satisfied By</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getRefinedBy() <em>Refined By</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getTracedTo() <em>Traced To</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getVerifiedBy() <em>Verified By</em>}</li>
+ * <li>{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getMaster() <em>Master</em>}</li>
* </ul>
* </p>
*
@@ -170,9 +169,7 @@
// Prepare test
model = SysMLTestResources.createSysMLModel(houseKeeper.createResourceSet());
- if(model.getAppliedProfiles().isEmpty()) {
- fail();
- }
+ Assert.assertFalse("the SysML profil must be applied.", model.getAppliedProfiles().isEmpty());
// Create classes & interface
defaultClass = model.createOwnedClass("defaultClass", false);
@@ -371,194 +368,98 @@
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getDerived()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getDerived()
* <em>Derived</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getDerived()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getDerived()
*/
@Test
public void testGetDerived() {
-
- // Isolated requirement : default_req.getDerived() = []
- if(!default_req.getDerived().isEmpty()) {
- fail();
- }
-
- // Verifies : derive1_req.getDerived() = [derived1_req]
- if(!derive1_req.getDerived().contains(derived1_req)) {
- fail();
- }
-
- // Verifies : derive2_req.getDerived() = [derived1_req, derived2_req]
- if(!derive2_req.getDerived().contains(derived1_req)) {
- fail();
- }
-
- if(!derive2_req.getDerived().contains(derived2_req)) {
- fail();
- }
+ Assert.assertTrue("Isolated requirement : default_req.getDerived() = []", default_req.getDerived().isEmpty());
+ Assert.assertTrue("Verifies : derive1_req.getDerived() = [derived1_req]", derive1_req.getDerived().contains(derived1_req));
+ Assert.assertTrue("Verifies : derive2_req.getDerived() = [derived1_req, derived2_req]",derive2_req.getDerived().contains(derived1_req));
+ Assert.assertTrue("Verifies : derive2_req.getDerived() = [derived1_req, derived2_req]",derive2_req.getDerived().contains(derived2_req));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getDerivedFrom()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getDerivedFrom()
* <em>Derived From</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getDerivedFrom()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getDerivedFrom()
*/
@Test
public void testGetDerivedFrom() {
-
- // Isolated requirement : default_req.getDerivedFrom() = []
- if(!default_req.getDerivedFrom().isEmpty()) {
- fail();
- }
-
- // Verifies : derived2_req.getDerivedFrom() = [derive2_req]
- if(!derived2_req.getDerivedFrom().contains(derive2_req)) {
- fail();
- }
-
- // Verifies : derived1_req.getDerivedFrom() = [derive1_req, derive2_req]
- if(!derived1_req.getDerivedFrom().contains(derive1_req)) {
- fail();
- }
- if(!derived1_req.getDerivedFrom().contains(derive2_req)) {
- fail();
- }
+ Assert.assertTrue("Isolated requirement : default_req.getDerivedFrom() = []",default_req.getDerivedFrom().isEmpty());
+ Assert.assertTrue("Verifies : derived2_req.getDerivedFrom() = [derive2_req]",derived2_req.getDerivedFrom().contains(derive2_req));
+ Assert.assertTrue("Verifies : derived1_req.getDerivedFrom() = [derive1_req, derive2_req]",derived1_req.getDerivedFrom().contains(derive1_req));
+ Assert.assertTrue("Verifies : derived1_req.getDerivedFrom() = [derive1_req, derive2_req]",derived1_req.getDerivedFrom().contains(derive2_req));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getMaster()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getMaster()
* <em>Master</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getMaster()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getMaster()
*/
@Test
public void testGetMaster() {
-
- // Isolated requirement : default_req.getMaster() = null
- if(default_req.getMaster() != null) {
- fail();
- }
-
- // Try retrieving Master from Copy requirement
- if(!master_req.equals(copy_req.getMaster())) {
- fail();
- }
+ Assert.assertNull("Isolated requirement : default_req.getMaster() = null", default_req.getMaster());
+ Assert.assertEquals("Try retrieving Master from Copy requirement", master_req, copy_req.getMaster());
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getRefinedBy()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getRefinedBy()
* <em>Refined By</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getRefinedBy()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getRefinedBy()
*/
@Test
public void testGetRefinedBy() {
-
- // Isolated requirement : default_req.getRefinedBy() = []
- if(!default_req.getRefinedBy().isEmpty()) {
- fail();
- }
-
- // Verifies : refined_req.getRefinedBy() = [refiningNE1, refiningNE2]
- if(!refined_req.getRefinedBy().contains(refiningNE1)) {
- fail();
- }
- if(!refined_req.getRefinedBy().contains(refiningNE2)) {
- fail();
- }
+ Assert.assertTrue("Isolated requirement : default_req.getRefinedBy() = []", default_req.getRefinedBy().isEmpty());
+ Assert.assertTrue("Verifies : refined_req.getRefinedBy() = [refiningNE1, refiningNE2]",refined_req.getRefinedBy().contains(refiningNE1));
+ Assert.assertTrue("Verifies : refined_req.getRefinedBy() = [refiningNE1, refiningNE2]",refined_req.getRefinedBy().contains(refiningNE2));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getSatisfiedBy()
- * <em>Satisfied By</em>}' feature getter. <!-- begin-user-doc --> <!-- end-user-doc -->
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getSatisfiedBy()
+ * <em>Satisfied By</em>}' feature getter.
*
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getSatisfiedBy()
- * NOT
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getSatisfiedBy()
*/
@Test
public void testGetSatisfiedBy() {
-
- // Isolated requirement : default_req.getSatisfiedBy() = []
- if(!default_req.getSatisfiedBy().isEmpty()) {
- fail();
- }
-
- // Verifies : satisfied_req.getSatisfiedBy() = [satisfyingNE1, satisfyingNE2]
- if(!satisfied_req.getSatisfiedBy().contains(satisfyingNE1)) {
- fail();
- }
- if(!satisfied_req.getSatisfiedBy().contains(satisfyingNE2)) {
- fail();
- }
+ Assert.assertTrue("Isolated requirement : default_req.getSatisfiedBy() = []",default_req.getSatisfiedBy().isEmpty());
+ Assert.assertTrue("Verifies : satisfied_req.getSatisfiedBy() = [satisfyingNE1, satisfyingNE2]",satisfied_req.getSatisfiedBy().contains(satisfyingNE1));
+ Assert.assertTrue("Verifies : satisfied_req.getSatisfiedBy() = [satisfyingNE1, satisfyingNE2]",satisfied_req.getSatisfiedBy().contains(satisfyingNE2));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getTracedTo()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getTracedTo()
* <em>Traced To</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getTracedTo()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getTracedTo()
*/
@Test
public void testGetTracedTo() {
-
- // Isolated requirement : default_req.getTracedTo = []
- if(!default_req.getTracedTo().isEmpty()) {
- fail();
- }
-
- // DeriveReqt / Verify / Copy inherits from Trace
- // Test getter through Copy (should not be taken into account see bug #352563)
- if(master_req.getTracedTo().contains(copy)) {
- fail();
- }
-
+ Assert.assertTrue("Isolated requirement : default_req.getTracedTo = []",default_req.getTracedTo().isEmpty());
+ // DeriveReqt / Verify / Copy inherits from Trace
+ Assert.assertFalse("Test getter through Copy (should not be taken into account see bug #352563)",master_req.getTracedTo().contains(copy));
// Test getter through DeriveReqt (tracedTo = Clients)
- // derived1 -> [derive1_req, derive2_req] (should not be taken into account see bug #352563)
- // derived2 -> [derive2_req] (should not be taken into account see bug #352563)
- if(derive1_req.getTracedTo().contains(derived1)) {
- fail();
- }
- if(derive2_req.getTracedTo().contains(derived1)) {
- fail();
- }
- if(derive2_req.getTracedTo().contains(derived2)) {
- fail();
- }
-
- // Test getter through Verify (should not be taken into account see bug #352563)
+ Assert.assertFalse("derived1 -> [derive1_req, derive2_req] (should not be taken into account see bug #352563)",derive1_req.getTracedTo().contains(derived1));
+ Assert.assertFalse("derived1 -> [derive1_req, derive2_req] (should not be taken into account see bug #352563)",derive2_req.getTracedTo().contains(derived1));
+ Assert.assertFalse("derived2 -> [derive2_req] (should not be taken into account see bug #352563)",derive2_req.getTracedTo().contains(derived2));
// Should not happen...
-
// Direct test
- if(!trace_req.getTracedTo().contains(traced1)) {
- fail();
- }
- if(!trace_req.getTracedTo().contains(traced2)) {
- fail();
- }
-
+ Assert.assertTrue("Test getter through Verify (should not be taken into account see bug #352563)",trace_req.getTracedTo().contains(traced1));
+ Assert.assertTrue("Test getter through Verify (should not be taken into account see bug #352563)",trace_req.getTracedTo().contains(traced2));
}
/**
- * Tests the '{@link org.eclipse.papyrus.sysml.requirements.Requirement#getVerifiedBy()
+ * Tests the '{@link org.eclipse.papyrus.sysml14.requirements.Requirement#getVerifiedBy()
* <em>Verified By</em>}' feature getter.
- * @see org.eclipse.papyrus.sysml.requirements.Requirement#getVerifiedBy()
+ * @see org.eclipse.papyrus.sysml14.requirements.Requirement#getVerifiedBy()
*/
@Test
public void testGetVerifiedBy() {
-
- // Isolated requirement : default_req.getVerifiedBy() = []
- if(!default_req.getVerifiedBy().isEmpty()) {
- fail();
- }
-
- // Test getVerifiedBy getter for
- // [testCase1, testCase2, verifierNamedElement] -> verified_req
- if(!verified_req.getVerifiedBy().contains(testCase1.getBase_Operation())) {
- fail();
- }
- if(!verified_req.getVerifiedBy().contains(testCase2.getBase_Operation())) {
- fail();
- }
- if(!verified_req.getVerifiedBy().contains(verifierNamedElement)) {
- fail();
- }
+ Assert.assertTrue("Isolated requirement : default_req.getVerifiedBy() = []", default_req.getVerifiedBy().isEmpty());
+ Assert.assertTrue("Test getVerifiedBy getter for [testCase1, testCase2, verifierNamedElement] -> verified_req", verified_req.getVerifiedBy().contains(testCase1.getBase_Operation()));
+ Assert.assertTrue("Test getVerifiedBy getter for [testCase1, testCase2, verifierNamedElement] -> verified_req", verified_req.getVerifiedBy().contains(testCase2.getBase_Operation()));
+ Assert.assertTrue("Test getVerifiedBy getter for [testCase1, testCase2, verifierNamedElement] -> verified_req", verified_req.getVerifiedBy().contains(verifierNamedElement));
}
}
diff --git a/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/deprecatedelements/FlowPortCustomImpl.java b/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/deprecatedelements/FlowPortCustomImpl.java
index 4801ff7..da94846 100644
--- a/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/deprecatedelements/FlowPortCustomImpl.java
+++ b/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/deprecatedelements/FlowPortCustomImpl.java
@@ -63,7 +63,7 @@
* 4 (Other) - FlowPort (default, similar to INOUT)
* @see org.eclipse.papyrus.sysml14.deprecatedelements.internal.impl.FlowPortImpl#getIcon()
*
- * @return
+ * @return the icon depending on the orientation of the FlowPort
*/
@Override
public Image getIcon() {