OpenImmo_1_2_6 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeAusblickElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:infrastruktur/io:ausblick[@blick]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("blick")); if ("MEER".equalsIgnoreCase(value)) node.setAttribute("blick", "SEE"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeAusblickElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:infrastruktur/io:ausblick[@blick='SEE']", doc); Assert.assertEquals( "1 <ausblick blick=\"SEE\"> element available before conversion.", 1, count); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:infrastruktur/io:ausblick[@blick='MEER']", doc); Assert.assertEquals( "1 <ausblick blick=\"MEER\"> element available before conversion.", 1, count); new OpenImmo_1_2_6().downgradeAusblickElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:infrastruktur/io:ausblick[@blick='SEE']", doc); Assert.assertEquals( "2 <ausblick blick=\"SEE\"> elements available after conversion.", 2, count); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:infrastruktur/io:ausblick[@blick='MEER']", doc); Assert.assertEquals( "0 <ausblick blick=\"MEER\"> elements available after conversion.", 0, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_6.downgradeAusblickElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_6.downgradeAusblickElements failed!"); } }