OpenImmo_1_2_7b extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeEnergiepassJahrgangElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:energiepass/io:jahrgang", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getTextContent()); if (value == null || value.equalsIgnoreCase("bei_besichtigung")) { Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeEnergiepassJahrgangElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:energiepass/io:jahrgang", doc); Assert.assertEquals( "4 <jahrgang> element available before conversion.", 4, count); new OpenImmo_1_2_7b().downgradeEnergiepassJahrgangElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:energiepass/io:jahrgang", doc); Assert.assertEquals( "1 <jahrgang> elements available after conversion.", 1, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_7b.downgradeEnergiepassJahrgangElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_7b.downgradeEnergiepassJahrgangElements failed!"); } }