@Override
    public void revert(final Path file) throws BackgroundException {
        try {
            new DbxUserFilesRequests(session.getClient(file)).restore(containerService.getKey(file), file.attributes().getVersionId());
        }
        catch(DbxException e) {
            throw new DropboxExceptionMappingService().map("Failure to write attributes of {0}", e, file);
        }
    }
@Test
    public void testRevert() throws Exception {
        final Path directory = new DropboxDirectoryFeature(session).mkdir(
                new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
        final DropboxAttributesFinderFeature f = new DropboxAttributesFinderFeature(session);
        final Path test = new DropboxTouchFeature(session).touch(new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        assertEquals(test.attributes().getVersionId(), new DropboxAttributesFinderFeature(session).find(test).getVersionId());
        final DropboxVersioningFeature feature = new DropboxVersioningFeature(session);
        assertEquals(0, feature.list(test, new DisabledListProgressListener()).size());
        final PathAttributes initialAttributes = new PathAttributes(test.attributes());
        final String initialVersion = test.attributes().getVersionId();
        final byte[] content = RandomUtils.nextBytes(32769);
        final TransferStatus status = new TransferStatus();
        status.setLength(content.length);
        status.setExists(true);
        final DropboxWriteFeature writer = new DropboxWriteFeature(session);
        final StatusOutputStream<Metadata> out = writer.write(test, status, new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
        assertNotEquals(initialVersion, new DropboxAttributesFinderFeature(session).toAttributes(out.getStatus()).getVersionId());
        {
            final AttributedList<Path> versions = feature.list(test.withAttributes(new DropboxAttributesFinderFeature(session).toAttributes(out.getStatus())), new DisabledListProgressListener());
            assertEquals(1, versions.size());
            assertEquals(new Path(test).withAttributes(initialAttributes), versions.get(0));
            assertEquals(initialVersion, versions.get(0).attributes().getVersionId());
        }
        final PathAttributes updated = new DropboxAttributesFinderFeature(session).find(test.withAttributes(new DropboxAttributesFinderFeature(session).toAttributes(out.getStatus())));
        assertNotEquals(initialVersion, updated.getVersionId());
        feature.revert(new Path(test).withAttributes(initialAttributes));
        // Delete versions permanently
        try {
            final List<Path> versions = feature.list(new Path(test).withAttributes(new DropboxAttributesFinderFeature(session).find(test)), new DisabledListProgressListener()).toList();
            assertEquals(2, versions.size());
            assertEquals(status.getResponse().getVersionId(), versions.get(0).attributes().getVersionId());
            assertEquals(initialVersion, versions.get(1).attributes().getVersionId());
            for(Path d : versions) {
                assertFalse(new DropboxThresholdDeleteFeature(session).isSupported(d));
                assertFalse(new DropboxBatchDeleteFeature(session).isSupported(d));
                assertFalse(new DropboxDeleteFeature(session).isSupported(d));
            }
            new DropboxDeleteFeature(session).delete(versions, new DisabledPasswordCallback(), new Delete.DisabledCallback());
            fail();
        }
        catch(InteroperabilityException e) {
            // Expected
        }
        for(Path version : new DropboxListService(session).list(directory, new DisabledListProgressListener())) {
            new DropboxDeleteFeature(session).delete(Collections.singletonList(version), new DisabledLoginCallback(), new Delete.DisabledCallback());
        }
        new DropboxDeleteFeature(session).delete(Collections.singletonList(directory), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }