OpenImmo_1_2_3 extends XmlConverter<OpenImmoDocument, OpenImmoVersion> { protected void downgradeDachformElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dachform[@FLACHDACH or @PYRAMIDENDACH]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; node.removeAttribute("FLACHDACH"); node.removeAttribute("PYRAMIDENDACH"); } }  @Override OpenImmoVersion getVersion(); @Override void downgradeToPreviousVersion(OpenImmoDocument doc); @Override void upgradeFromPreviousVersion(OpenImmoDocument doc);  }
@Test public void testDowngradeDachformElements() { try { Document doc = buildTransferDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dachform[@FLACHDACH or @PYRAMIDENDACH]", doc); Assert.assertEquals( "3 convertable <dachform> elements available before conversion.", 3, count); new OpenImmo_1_2_3().downgradeDachformElements(doc); count = XmlUtils.countNodes( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dachform[@FLACHDACH or @PYRAMIDENDACH]", doc); Assert.assertEquals( "0 convertable <dachform> elements available after conversion.", 0, count); } catch (Exception ex) { LOGGER.error("Test of OpenImmo_1_2_3.downgradeDachformElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of OpenImmo_1_2_3.downgradeDachformElements failed!"); } }