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