Attempt to fix failing unit tests
diff --git a/org.eclipse.rmf.reqif10.serialization/src/org/eclipse/rmf/reqif10/serialization/ReqIF10ResourceImpl.java b/org.eclipse.rmf.reqif10.serialization/src/org/eclipse/rmf/reqif10/serialization/ReqIF10ResourceImpl.java
index b353961..a089ef9 100644
--- a/org.eclipse.rmf.reqif10.serialization/src/org/eclipse/rmf/reqif10/serialization/ReqIF10ResourceImpl.java
+++ b/org.eclipse.rmf.reqif10.serialization/src/org/eclipse/rmf/reqif10/serialization/ReqIF10ResourceImpl.java
@@ -26,10 +26,6 @@
import org.eclipse.rmf.serialization.XMLPersistenceMappingResourceImpl;
public class ReqIF10ResourceImpl extends XMLPersistenceMappingResourceImpl {
- /**
- * Indicate if we must not replace the id or not
- */
- private boolean keepID = false;
public ReqIF10ResourceImpl() {
super();
@@ -58,25 +54,7 @@
// ========= default load options ===================
Map<Object, Object> loadOptions = getDefaultLoadOptions();
loadOptions.put(XMLResource.OPTION_XML_MAP, optionsMap);
- }
-
- /**
- * Set the new value of keep id
- *
- * @param keepID
- * : The new value of keep id
- */
- public void setKeepID(boolean keepID) {
- this.keepID = keepID;
- }
-
- /**
- * Return whether the flag of keeping the id is on or off
- *
- * @return The value of the flag of keeping the id
- */
- public boolean isKeepID() {
- return keepID;
+
}
/**
@@ -113,18 +91,20 @@
* java.lang.String)
*/
@Override
- public void setID(final EObject eObject, final String id) {
+ public void setID(final EObject eObject, String id) {
final EAttribute idAttribute = eObject.eClass().getEIDAttribute();
+ if (idAttribute != null) {
+ Object currentId = eObject.eGet(idAttribute);
+ if (currentId instanceof String) id = (String)currentId;
+ }
String idToSet = id;
if ((idAttribute != null) && (idToSet != null)) {
- if (isKeepID()) {
Object existingID = eObject.eGet(idAttribute);
if ((existingID != null)
&& (false == existingID.toString().trim().isEmpty())) {
idToSet = existingID.toString();
}
- }
- // We must not keep the existing id, so we overrite it
+ // We must not keep the existing id, so we override it
if (idToSet.equals(id)) {
eObject.eSet(idAttribute, id);
}
diff --git a/org.eclipse.rmf.tests.reqif10.serialization/src/org/eclipse/rmf/tests/reqif10/serialization/uc003/tc18xx/TC18xxHISExchangeProcessTests.java b/org.eclipse.rmf.tests.reqif10.serialization/src/org/eclipse/rmf/tests/reqif10/serialization/uc003/tc18xx/TC18xxHISExchangeProcessTests.java
index 40150fe..ecc6a0a 100644
--- a/org.eclipse.rmf.tests.reqif10.serialization/src/org/eclipse/rmf/tests/reqif10/serialization/uc003/tc18xx/TC18xxHISExchangeProcessTests.java
+++ b/org.eclipse.rmf.tests.reqif10.serialization/src/org/eclipse/rmf/tests/reqif10/serialization/uc003/tc18xx/TC18xxHISExchangeProcessTests.java
@@ -34,7 +34,6 @@
import org.eclipse.rmf.reqif10.SpecObject;
import org.eclipse.rmf.reqif10.Specification;
import org.eclipse.rmf.reqif10.XhtmlContent;
-import org.eclipse.rmf.reqif10.serialization.ReqIF10ResourceImpl;
import org.eclipse.rmf.reqif10.xhtml.XhtmlPType;
import org.eclipse.rmf.tests.reqif10.serialization.util.AbstractTestCase;
import org.eclipse.rmf.tests.reqif10.serialization.util.CommonSystemAttributes;
@@ -62,12 +61,15 @@
tc1801ReqIF = new TC1801HISExchangeProcessModelBuilder(loadReqIFFile(TC1800_FILENAME)).getReqIF();
doSaveReqIFFile(tc1801ReqIF, TC1801_FILENAME);
+ tc1801ReqIF = loadReqIFFile(TC1801_FILENAME); // Ensure all references to the old filename are gone
tc1802ReqIF = new TC1802HISExchangeProcessModelBuilder(loadReqIFFile(TC1801_FILENAME)).getReqIF();
doSaveReqIFFile(tc1802ReqIF, TC1802_FILENAME);
+ tc1802ReqIF = loadReqIFFile(TC1802_FILENAME); // Ensure all references to the old filename are gone
tc1803ReqIF = new TC1803HISExchangeProcessModelBuilder(loadReqIFFile(TC1802_FILENAME)).getReqIF();
doSaveReqIFFile(tc1803ReqIF, TC1803_FILENAME);
+ tc1803ReqIF = loadReqIFFile(TC1803_FILENAME); // Ensure all references to the old filename are gone
}
@Test
@@ -273,13 +275,8 @@
protected static void doSaveReqIFFile(EObject reqif, String fileName) throws IOException {
URI emfURI = createEMFURI(fileName);
Resource resource = getXMLPersistenceMappingResourceSet().createResource(emfURI);
- if (resource instanceof ReqIF10ResourceImpl) {
- ((ReqIF10ResourceImpl) resource).setKeepID(true);
- }
resource.getContents().add(reqif);
resource.save(getSaveOptions());
- if (resource instanceof ReqIF10ResourceImpl) {
- ((ReqIF10ResourceImpl) resource).setKeepID(false);
- }
}
+
}