OpenImmo_1_2_6 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void removeFlaechenChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:kubatur | " + "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:ausnuetzungsziffer | " + "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:flaechevon | " + "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:flaechebis", 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 void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testRemoveFlaechenChildElements() { String[] elements = new String[]{ "kubatur", "ausnuetzungsziffer", "flaechevon", "flaechebis" }; try { Document doc = buildTransferDocumentForDowngrade(); int count; for (String element : elements) { count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:" + element, doc); Assert.assertEquals( "1 convertable <" + element + "> element available before conversion.", 1, count); } new OpenImmo_1_2_6().removeFlaechenChildElements(doc); for (String element : elements) { count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:" + element, doc); Assert.assertEquals( "0 convertable <" + element + "> elements available after conversion.", 0, count); } } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_6.removeFlaechenChildElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_6.removeFlaechenChildElements failed!"); } }