Kyero_3 extends XmlConverter<KyeroDocument, KyeroVersion> { protected void removeEnergyRatingElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:root/io:property/io:energy_rating", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }  @Override KyeroVersion getVersion(); @Override void downgradeToPreviousVersion(KyeroDocument doc); @Override void upgradeFromPreviousVersion(KyeroDocument doc);  }
@Test public void testRemoveEnergyRatingElements() { try { Document doc = buildDocumentForDowngrade(); int count; count = XmlUtils.countNodes( "/io:root/io:property/io:energy_rating", doc); Assert.assertEquals( "3 <energy_rating> elements available before conversion.", 3, count); new Kyero_3().removeEnergyRatingElements(doc); count = XmlUtils.countNodes( "/io:root/io:property/io:energy_rating", doc); Assert.assertEquals( "0 <energy_rating> elements available after conversion.", 0, count); } catch (Exception ex) { LOGGER.error("Test of Kyero_3.removeEnergyRatingElements failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of Kyero_3.removeEnergyRatingElements failed!"); } }