OpenImmo_1_2_7 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeAnhangElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:anhang[@gruppe] | " + "/io:openimmo/io:anbieter/io:immobilie/io:anhaenge/io:anhang[@gruppe]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("gruppe")); if ("EPASS-SKALA".equalsIgnoreCase(value)) node.removeAttribute("gruppe"); else if ("ANBOBJURL".equalsIgnoreCase(value)) node.removeAttribute("gruppe"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeAnhangElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( " Assert.assertEquals( "4 convertable <anhang> elements available before conversion.", 4, count); new OpenImmo_1_2_7().downgradeAnhangElements(doc); count = XmlUtils.countNodes( " Assert.assertEquals( "0 convertable <anhang> elements available after conversion.", 0, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_7.downgradeAnhangElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_7.downgradeAnhangElements failed!"); } }