ImmobiliareItDocument extends XmlConvertableDocument<Feed, ImmobiliareItVersion> { @Override public void setDocumentVersion(ImmobiliareItVersion version) { try { Document doc = this.getDocument(); Element node = (Element) XmlUtils .newXPath("/io:feed/io:version", doc) .selectSingleNode(doc); if (node == null) { Element parentNode = (Element) XmlUtils .newXPath("/io:feed", doc) .selectSingleNode(doc); if (parentNode == null) { LOGGER.warn("Can't find a <feed> element in the document!"); return; } node = doc.createElement("version"); parentNode.insertBefore(node, parentNode.getFirstChild()); } node.setTextContent(version.toReadableVersion()); } catch (JaxenException ex) { LOGGER.error("Can't evaluate XPath expression!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); } } ImmobiliareItDocument(Document document); @Override ImmobiliareItVersion getDocumentVersion(); @Override ImmobiliareItVersion getLatestVersion(); static boolean isReadable(Document doc); static ImmobiliareItDocument newDocument(); static ImmobiliareItDocument newDocument(Feed feed); @Override void setDocumentVersion(ImmobiliareItVersion version); @Override Feed toObject();  }
@Test @SuppressWarnings("Duplicates") public void testSetDocumentVersion() { try { ImmobiliareItDocument doc = new ImmobiliareItDocument(buildExampleDocument("")); doc.setDocumentVersion(ImmobiliareItVersion.V2_5); Assert.assertEquals("2.5", ImmobiliareItVersion.V2_5, doc.getDocumentVersion()); } catch (Exception ex) { LOGGER.error("Test of ImmobiliareItDocument.setDocumentVersion failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of ImmobiliareItDocument.setDocumentVersion failed!"); } }