OpenImmo_1_2_5 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void removeKontaktpersonChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:position |" + "/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:immobilientreuhaenderid |" + "/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:foto", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override @SuppressWarnings("Duplicates") void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testRemoveKontaktpersonChildElements() { String[] elements = new String[]{ "position", "immobilientreuhaenderid", "foto" }; try { Document doc = buildTransferDocumentForDowngrade(); int count; for (String element : elements) { count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:" + element, doc); Assert.assertEquals( "1 convertable <" + element + "> element available before conversion.", 1, count); } new OpenImmo_1_2_5().removeKontaktpersonChildElements(doc); for (String element : elements) { count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:" + element, doc); Assert.assertEquals( "0 convertable <" + element + "> elements available after conversion.", 0, count); } } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_5.removeKontaktpersonChildElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_5.removeKontaktpersonChildElements failed!"); } }