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