Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorytanguy2011-07-22 13:43:51 +0000
committerytanguy2011-07-22 13:43:51 +0000
commit490924aa129b405762c9cd3a6704d0f80958e79a (patch)
tree239d7e9abfdb4df79981526e6f2da773317227fb
parentac919e0f4ccdc5ea98cf72bd28ae1d1be82272fa (diff)
downloadorg.eclipse.papyrus-490924aa129b405762c9cd3a6704d0f80958e79a.tar.gz
org.eclipse.papyrus-490924aa129b405762c9cd3a6704d0f80958e79a.tar.xz
org.eclipse.papyrus-490924aa129b405762c9cd3a6704d0f80958e79a.zip
NEW - bug 352563: [SysML Static Profile] Incorrect content for Requirement::/tracedTo derived property
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352563
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementImpl.java5
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementRelatedImpl.java17
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementRelatedTest.java43
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementTest.java16
4 files changed, 60 insertions, 21 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementImpl.java b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementImpl.java
index a10a1ed4fc6..f804a895c60 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementImpl.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementImpl.java
@@ -471,9 +471,10 @@ public class RequirementImpl extends EObjectImpl implements Requirement {
// Find Trace link
while(itDep.hasNext()) {
DirectedRelationship currentDR = itDep.next();
- currentTrace = (Trace)ElementUtil.hasStereotype(currentDR, StandardPackage.eINSTANCE.getTrace());
+ currentTrace = ElementUtil.getStereotypeApplication(currentDR, Trace.class);
- if(currentTrace != null) {
+ // Must be a Trace not a subtype (see bug #352563).
+ if((currentTrace != null) && (currentTrace.eClass() == StandardPackage.eINSTANCE.getTrace())) {
EList<NamedElement> suppliers = currentTrace.getBase_Abstraction().getClients();
tracedTo.addAll(suppliers);
}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementRelatedImpl.java b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementRelatedImpl.java
index b922d6c5123..61e26b4eeec 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementRelatedImpl.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml/src/org/eclipse/papyrus/sysml/requirements/impl/RequirementRelatedImpl.java
@@ -258,25 +258,28 @@ public class RequirementRelatedImpl extends EObjectImpl implements RequirementRe
* @generated NOT
*/
public EList<Requirement> getTracedFrom() {
- // This should return the Requirement clients of any Trace link targeting current
- // RequirementRelated
+
+ // Derived from all requirements that are supplier of a "trace" relationship for
+ // which this element is a client.
+ // "trace" subtypes are not included (see bug #352563).
EList<Requirement> tracedFrom = new BasicEList<Requirement>();
Trace currentTrace = null;
if(getBase_NamedElement() != null) {
// Find Trace link
- EList<DirectedRelationship> relationships = getBase_NamedElement().getTargetDirectedRelationships();
+ EList<DirectedRelationship> relationships = getBase_NamedElement().getSourceDirectedRelationships();
Iterator<DirectedRelationship> itDep = relationships.iterator();
while(itDep.hasNext()) {
DirectedRelationship currentDRelationship = itDep.next();
- currentTrace = (Trace)ElementUtil.hasStereotype(currentDRelationship, StandardPackage.eINSTANCE.getTrace());
+ currentTrace = ElementUtil.getStereotypeApplication(currentDRelationship, Trace.class);
- if(currentTrace != null) {
- EList<NamedElement> clients = currentTrace.getBase_Abstraction().getClients();
+ // Must be a Trace not a subtype (see bug #352563).
+ if((currentTrace != null) && (currentTrace.eClass() == StandardPackage.eINSTANCE.getTrace())) {
+ EList<NamedElement> clients = currentTrace.getBase_Abstraction().getSuppliers();
Iterator<NamedElement> it = clients.iterator();
while(it.hasNext()) {
- Requirement currentRequirement = (Requirement)ElementUtil.hasStereotype(it.next(), RequirementsPackage.eINSTANCE.getRequirement());
+ Requirement currentRequirement = ElementUtil.getStereotypeApplication(it.next(), Requirement.class);
if(currentRequirement != null) {
tracedFrom.add(currentRequirement);
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementRelatedTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementRelatedTest.java
index 50caf9f0a52..8e61ebb74fe 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementRelatedTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementRelatedTest.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.sysml.requirements.tests;
import junit.framework.TestCase;
import junit.textui.TestRunner;
+import org.eclipse.papyrus.sysml.requirements.Copy;
import org.eclipse.papyrus.sysml.requirements.Requirement;
import org.eclipse.papyrus.sysml.requirements.RequirementRelated;
import org.eclipse.papyrus.sysml.requirements.RequirementsFactory;
@@ -65,6 +66,17 @@ public class RequirementRelatedTest extends TestCase {
protected Model model = null;
// ////////////////////////////////////////////////////////////////////
+
+ protected Class copy = null;
+
+ protected Class master = null;
+
+ protected Requirement copy_req = null;
+
+ protected Requirement master_req = null;
+
+ protected RequirementRelated copy_reqR = null;
+
protected Requirement trace1_req = null;
protected Requirement trace2_req = null;
@@ -171,19 +183,36 @@ public class RequirementRelatedTest extends TestCase {
// Add "Trace" (Abstraction)
// trace1, trace2 -> traced
Abstraction t11 = UMLFactory.eINSTANCE.createAbstraction();
- t11.getClients().add(trace1);
- t11.getSuppliers().add(traced);
+ t11.getClients().add(traced);
+ t11.getSuppliers().add(trace1);
model.getPackagedElements().add(t11);
@SuppressWarnings("unused")
Trace t_t11 = (Trace)t11.applyStereotype(t11.getApplicableStereotype(StandardResource.TRACE_ID));
Abstraction t12 = UMLFactory.eINSTANCE.createAbstraction();
- t12.getClients().add(trace2);
- t12.getSuppliers().add(traced);
+ t12.getClients().add(traced);
+ t12.getSuppliers().add(trace2);
model.getPackagedElements().add(t12);
@SuppressWarnings("unused")
Trace t_t12 = (Trace)t12.applyStereotype(t12.getApplicableStereotype(StandardResource.TRACE_ID));
+ master = model.createOwnedClass("master", false);
+ master_req = (Requirement)master.applyStereotype(master.getApplicableStereotype(SysmlResource.REQUIREMENT_ID));
+
+ copy = model.createOwnedClass("copy", false);
+ copy_req = (Requirement)copy.applyStereotype(copy.getApplicableStereotype(SysmlResource.REQUIREMENT_ID));
+ copy_reqR = (RequirementRelated)copy.applyStereotype(copy.getApplicableStereotype(SysmlResource.REQUIREMENT_RELATED_ID));
+
+ // Add "copy" (Abstraction) between master and copy
+ // copy -> master
+ Abstraction c_m = UMLFactory.eINSTANCE.createAbstraction();
+ c_m.getClients().add(copy);
+ c_m.getSuppliers().add(master);
+ model.getPackagedElements().add(c_m);
+ @SuppressWarnings("unused")
+ Copy copy_c_m = (Copy)c_m.applyStereotype(c_m.getApplicableStereotype(SysmlResource.COPY_ID));
+
+
// ////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
@@ -355,6 +384,12 @@ public class RequirementRelatedTest extends TestCase {
if(!traced_reqR.getTracedFrom().contains(trace2_req)) {
fail();
}
+
+ // Should not include Trace subtypes clients
+ // Test getter through Copy (should not be taken into account see bug #352563)
+ if(copy_reqR.getTracedFrom().contains(master)) {
+ fail();
+ }
}
/**
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementTest.java
index b73090af569..e9fb147f6bc 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/src/org/eclipse/papyrus/sysml/requirements/tests/RequirementTest.java
@@ -552,25 +552,25 @@ public class RequirementTest extends TestCase {
}
// DeriveReqt / Verify / Copy inherits from Trace
- // Test getter through Copy
- if(!master_req.getTracedTo().contains(copy)) {
+ // Test getter through Copy (should not be taken into account see bug #352563)
+ if(master_req.getTracedTo().contains(copy)) {
fail();
}
// Test getter through DeriveReqt (tracedTo = Clients)
- // derived1 -> [derive1_req, derive2_req]
- // derived2 -> [derive2_req]
- if(!derive1_req.getTracedTo().contains(derived1)) {
+ // 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)) {
+ if(derive2_req.getTracedTo().contains(derived1)) {
fail();
}
- if(!derive2_req.getTracedTo().contains(derived2)) {
+ if(derive2_req.getTracedTo().contains(derived2)) {
fail();
}
- // Test getter through Verify
+ // Test getter through Verify (should not be taken into account see bug #352563)
// Should not happen...
// Direct test

Back to the top