use of org.jdom2.xpath.XPathBuilder in project mycore by MyCoRe-Org.
the class MCRMODSLinkedMetadataTest method testUpdate.
@Test
public void testUpdate() throws IOException, URISyntaxException, MCRPersistenceException, MCRActiveLinkException, JDOMException, SAXException, MCRAccessException {
MCRObject seriesNew = new MCRObject(getResourceAsURL(seriesID + "-updated.xml").toURI());
MCRMetadataManager.update(seriesNew);
Document bookNew = MCRXMLMetadataManager.instance().retrieveXML(bookID);
XPathBuilder<Element> builder = new XPathBuilder<>("/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:relatedItem/mods:titleInfo/mods:title", Filters.element());
builder.setNamespace(MCRConstants.MODS_NAMESPACE);
XPathExpression<Element> seriesTitlePath = builder.compileWith(XPathFactory.instance());
Element titleElement = seriesTitlePath.evaluateFirst(bookNew);
Assert.assertNotNull("No title element in related item: " + new XMLOutputter(Format.getPrettyFormat()).outputString(bookNew), titleElement);
Assert.assertEquals("Title update from series was not promoted to book of series.", "Updated series title", titleElement.getText());
}
Aggregations