ImmoXmlDocument extends XmlConvertableDocument<Immoxml, ImmoXmlVersion> { @Override public Immoxml toObject() throws JAXBException { this.upgradeToLatestVersion(); return (Immoxml) ImmoXmlUtils.createUnmarshaller().unmarshal(this.getDocument()); } ImmoXmlDocument(Document document); @Override ImmoXmlVersion getDocumentVersion(); @Override ImmoXmlVersion getLatestVersion(); static boolean isReadable(Document doc); static ImmoXmlDocument newDocument(); static ImmoXmlDocument newDocument(Immoxml immoxml); @Override void setDocumentVersion(ImmoXmlVersion version); @Override Immoxml toObject();  }
@Test @SuppressWarnings("Duplicates") public void testToObject() { try { String version = ImmoXmlUtils.VERSION.toReadableVersion(); ImmoXmlDocument doc = new ImmoXmlDocument(buildExampleDocument(version)); Assert.assertEquals(version, ImmoXmlUtils.VERSION, doc.getDocumentVersion()); Immoxml obj = doc.toObject(); Assert.assertNotNull( "Created object for transfer document.", obj); Assert.assertEquals( "Matching version between document and object.", doc.getDocumentVersion().toReadableVersion(), obj.getUebertragung().getVersion()); } catch (Exception ex) { LOGGER.error("Test of ImmoXmlDocument.toObject failed!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); Assert.fail("Test of ImmoXmlDocument.toObject failed!"); } }