OpenImmo_1_2_7 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeSummemietenettoElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:summemietenetto[@summemieteust]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("summemieteust")); if (value != null) node.setAttribute("sonstigemieteust", value); node.removeAttribute("summemieteust"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeSummemietenettoElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:summemietenetto[@summemieteust]", doc); Assert.assertEquals( "2 convertable <summemietenetto> elements available before conversion.", 2, count); new OpenImmo_1_2_7().downgradeSummemietenettoElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:summemietenetto[@summemieteust]", doc); Assert.assertEquals( "0 convertable <summemietenetto> elements available after conversion.", 0, count); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:summemietenetto[@sonstigemieteust]", doc); Assert.assertEquals( "2 converted <summemietenetto> elements available after conversion.", 2, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_7.downgradeSummemietenettoElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_7.downgradeSummemietenettoElements failed!"); } }