OpenImmo_1_2_2 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeGrundstueckElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:grundstueck[@grundst_typ]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("grundst_typ")); if ("GEWERBEPARK".equalsIgnoreCase(value)) node.removeAttribute("grundst_typ"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override @SuppressWarnings("Duplicates") void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeGrundstueckElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:grundstueck[@grundst_typ='GEWERBEPARK']", doc); Assert.assertEquals( "1 convertable <grundstueck> element available before conversion.", 1, count); new OpenImmo_1_2_2().downgradeGrundstueckElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:grundstueck[@grundst_typ='GEWERBEPARK']", doc); Assert.assertEquals( "0 convertable <grundstueck> elements available after conversion.", 0, count); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:grundstueck", doc); Assert.assertEquals( "1 converted <grundstueck> elements available after conversion.", 1, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_2.downgradeGrundstueckElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_2.downgradeGrundstueckElements failed!"); } }