OpenImmo_1_2_0 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void upgradeMieteinnahmenElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist |" + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; node.setAttribute("periode", "JAHR"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testUpgradeMieteinnahmenElements() { try { Document doc = buildTransferDocumentForUpgrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist |" + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll", doc); Assert.assertEquals( "2 convertable <mieteinnahmen_ist> and <mieteinnahmen_soll> elements available after conversion.", 2, count); new OpenImmo_1_2_0().upgradeMieteinnahmenElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist[@periode='JAHR'] |" + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll[@periode='JAHR']", doc); Assert.assertEquals( "2 converted <mieteinnahmen_ist> and <mieteinnahmen_soll> elements available after conversion.", 2, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_0.upgradeMieteinnahmenElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_0.upgradeMieteinnahmenElements failed!"); } }