.println("Running TestAPIM.testModifyDatastreamByReference...");
List<String> testDsIds = setUpDatastreamModificationTest(DEMO_14, "MODREF", "M", 1);
int numNonAudits = getNumberNonAuditDatastreams(DEMO_14);
String testDsId = testDsIds.get(0);
assertEquals("MODREFDSM1", testDsId);
Datastream origManagedContent =
apim.getDatastream("fedora-system:ContentModel-3.0", "DC", null);
long managedContentSize = origManagedContent.getSize();
String [] altIds = new String[1];
altIds[0] = "Datastream 1 Modified Alternate ID";
String datastreamId =
apim.modifyDatastreamByReference(DEMO_14,
testDsId,
TypeUtility
.convertStringtoAOS(altIds),
"Modified M-type Datastream",
"text/xml",
"info:newMyFormatURI/Mtype/stuff#junk",
getBaseURL()
+ "/get/fedora-system:ContentModel-3.0/DC",
null,
null,
"modified datastream",
false);
// test that datastream was modified
byte [] objectXML =
TypeUtility.convertDataHandlerToBytes(apim
.getObjectXML(DEMO_14));
assertTrue(objectXML.length > 0);
String xmlIn = new String(objectXML, "UTF-8");
Document doc = XMLUnit.buildControlDocument(xmlIn);
//System.out.println("***** Testcase: TestAPIM.testModifyDatastreamByReference NEWDS1\n"+xmlIn);
assertXpathExists("foxml:digitalObject[@PID='demo:14']", doc);
assertXpathExists("//foxml:datastream[@ID='MODREFDSM1' and @CONTROL_GROUP='M' and @STATE='A']",
doc);
assertXpathExists("//foxml:datastreamVersion[@ID='MODREFDSM1.1' and @MIMETYPE='text/xml' and @LABEL='Modified M-type Datastream' and @ALT_IDS='Datastream 1 Modified Alternate ID' and @FORMAT_URI='info:newMyFormatURI/Mtype/stuff#junk']",
doc);
assertXpathExists("//audit:auditTrail/audit:record[last()]/audit:action['modifyDatastreamByReference']",
doc);
assertXpathEvaluatesTo(Integer.toString(numNonAudits),
"count(//foxml:datastream[@ID!='AUDIT'])",
doc);
// check size
assertXpathExists("//foxml:datastreamVersion[@ID='MODREFDSM1.0' and @SIZE='"
+ managedContentSize + "']",
doc);
// check size in getDatastreamDissemination
Datastream ds1 = apim.getDatastream(DEMO_14, "MODREFDSM1", null);
assertEquals(managedContentSize, ds1.getSize());
// test modifyDatastreamByReference RELS-EXT, RELS-INT triggers validation for managed content datastreams
// add RELS-EXT from some other object as that will be invalid for this object
// using demo:SmileyBeerGlass_M (managed content version of SmileyBeerGlass)
// TODO: DC also