DatabaseRepresentation { public void revertToRevision(final String resourceName, final int backToRevision) throws JaxRxException, SirixException { Database database = null; Session session = null; NodeWriteTrx wtx = null; boolean abort = false; try { database = Databases.openDatabase(mStoragePath); session = database.getSession(new SessionConfiguration.Builder( resourceName).build()); wtx = session.beginNodeWriteTrx(); wtx.revertTo(backToRevision); wtx.commit(); } catch (final SirixException exce) { abort = true; throw new JaxRxException(exce); } finally { WorkerHelper.closeWTX(abort, wtx, session, database); } } DatabaseRepresentation(final File storagePath); void createResource(final InputStream inputStream,
			final String resourceName); StreamingOutput getResource(final String resourceName,
			final Map<QueryParameter, String> queryParams); StreamingOutput performQueryOnResource(final String resource,
			final String query, final Map<QueryParameter, String> otherParams); StreamingOutput getResourcesNames(); boolean add(final InputStream input, final String resource); void deleteResource(final String resourceName); final boolean shred(final InputStream xmlInput, final String resource); long getLastRevision(final String resourceName); OutputStream getModificHistory(
			final String resourceName, // NOPMD this method needs alls these
			// functions
			final String revisionRange, final boolean nodeid,
			final OutputStream output, final boolean wrap); void revertToRevision(final String resourceName,
			final int backToRevision);  }
@Test public void revertToRevision() throws SirixException, WebApplicationException, IOException, ParserConfigurationException, SAXException, InterruptedException { final NodeIdRepresentation rid = new NodeIdRepresentation( TestHelper.PATHS.PATH1.getFile()); rid.deleteResource(RESOURCENAME, 8); rid.deleteResource(RESOURCENAME, 11); rid.deleteResource(RESOURCENAME, 14); assertEquals(ASSEQUALS, 4, sirix.getLastRevision(RESOURCENAME)); sirix.revertToRevision(RESOURCENAME, 1); final StreamingOutput sOutput = rid.getResource(RESOURCENAME, 14, new HashMap<QueryParameter, String>()); final ByteArrayOutputStream output = new ByteArrayOutputStream(); sOutput.write(output); final Document doc = DOMHelper.buildDocument(output); final Node node = doc.getElementsByTagName("continent").item(0); final Attr attribute = (Attr) node.getAttributes().getNamedItem(NAME); final String africaString = attribute.getTextContent(); assertNotNull("check if africa (14) exists in the latest version", africaString); assertEquals(ASSEQUALS, 5, sirix.getLastRevision(RESOURCENAME)); output.close(); }