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