ImmobiliareItDocument extends XmlConvertableDocument<Feed, ImmobiliareItVersion> { @Override public ImmobiliareItVersion getDocumentVersion() { String version; try { Document doc = this.getDocument(); version = StringUtils.trimToNull(XmlUtils .newXPath("/io:feed/io:version/text()", doc) .stringValueOf(doc)); if (version == null) { LOGGER.warn("Can't find version information in the XML document!"); return null; } } catch (JaxenException ex) { LOGGER.error("Can't evaluate XPath expression!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); return null; } ImmobiliareItVersion v = ImmobiliareItVersion.detectFromString(version); if (v != null) return v; LOGGER.warn("The provided version (" + version + ") is not supported!"); return null; } 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 testGetDocumentVersion() { ImmobiliareItDocument doc; try { doc = new ImmobiliareItDocument(buildExampleDocument("2.5")); Assert.assertEquals("2.5", ImmobiliareItVersion.V2_5, doc.getDocumentVersion()); } catch (Exception ex) { LOGGER.error("Test of ImmobiliareItDocument.getDocumentVersion failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of ImmobiliareItDocument.getDocumentVersion failed!"); } }