@Override
    public void restore(final Path file, final LoginCallback prompt) throws BackgroundException {
        final String nodeId = fileid.getFileId(file);
        try {
            new CoreRestControllerApi(session.getClient()).revertNode(nodeId);
            this.fileid.cache(file, null);
        }
        catch(ApiException e) {
            throw new DeepboxExceptionMappingService(fileid).map(e);
        }
    }
@Test
    public void restoreDirectory() throws Exception {
        final DeepboxIdProvider fileid = new DeepboxIdProvider(session);
        final Path documents = new Path("/ORG 4 - DeepBox Desktop App/ORG3:Box1/Documents/", EnumSet.of(Path.Type.directory, Path.Type.volume));
        final Path trash = new Path("/ORG 4 - DeepBox Desktop App/ORG3:Box1/Trash/", EnumSet.of(Path.Type.directory, Path.Type.volume));
        final Path folder = new Path(documents, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));

        final Path subfolderWithContent = new Path(folder, new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.directory));
        final Path file = new Path(subfolderWithContent, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        final Path folderInTrash = new Path(trash, folder.getName(), folder.getType());
        final Path subfolderWithContentInTrash = new Path(folderInTrash, subfolderWithContent.getName(), EnumSet.of(Path.Type.directory));
        final Path fileInTrash = new Path(subfolderWithContentInTrash, file.getName(), EnumSet.of(Path.Type.file));

        new DeepboxDirectoryFeature(session, fileid).mkdir(folder, new TransferStatus());
        final String folderId = new DeepboxAttributesFinderFeature(session, fileid).find(folder).getFileId();
        assertTrue(new DeepboxFindFeature(session, fileid).find(folder));
        new CoreRestControllerApi(session.getClient()).getNodeInfo(folderId, null, null, null); // assert no fail

        final String subFolderId = new DeepboxDirectoryFeature(session, fileid).mkdir(subfolderWithContent, new TransferStatus()).attributes().getFileId();
        assertTrue(new DeepboxFindFeature(session, fileid).find(subfolderWithContent));

        new DeepboxTouchFeature(session, fileid).touch(file, new TransferStatus());
        final String nodeId = new DeepboxAttributesFinderFeature(session, fileid).find(file).getFileId();
        assertTrue(new DeepboxFindFeature(session, fileid).find(folder.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(subfolderWithContent.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(file));
        assertFalse(new DeepboxFindFeature(session, fileid).find(folderInTrash.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(subfolderWithContentInTrash.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(fileInTrash.withAttributes(new PathAttributes())));

        new DeepboxTrashFeature(session, fileid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());

        assertThrows(NotfoundException.class, () -> fileid.getFileId(folder.withAttributes(new PathAttributes())));
        assertThrows(NotfoundException.class, () -> fileid.getFileId(subfolderWithContent.withAttributes(new PathAttributes())));
        assertThrows(NotfoundException.class, () -> fileid.getFileId(file.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(folder.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(subfolderWithContent.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(file.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(folderInTrash.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(subfolderWithContentInTrash.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(fileInTrash.withAttributes(new PathAttributes())));
        assertEquals(folderId, new DeepboxAttributesFinderFeature(session, fileid).find(folderInTrash.withAttributes(new PathAttributes())).getFileId());
        assertEquals(subFolderId, new DeepboxAttributesFinderFeature(session, fileid).find(subfolderWithContentInTrash.withAttributes(new PathAttributes())).getFileId());
        assertEquals(nodeId, new DeepboxAttributesFinderFeature(session, fileid).find(fileInTrash.withAttributes(new PathAttributes())).getFileId());

        final DeepboxRestoreFeature restore = new DeepboxRestoreFeature(session, fileid);
        restore.restore(folderInTrash, new DisabledLoginCallback());
        assertTrue(new DeepboxFindFeature(session, fileid).find(folder.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(subfolderWithContent.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(file.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(folderInTrash.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(subfolderWithContentInTrash.withAttributes(new PathAttributes())));
        assertFalse(new DeepboxFindFeature(session, fileid).find(fileInTrash.withAttributes(new PathAttributes())));
        assertEquals(folderId, new DeepboxAttributesFinderFeature(session, fileid).find(folder.withAttributes(new PathAttributes())).getFileId());
        assertEquals(subFolderId, new DeepboxAttributesFinderFeature(session, fileid).find(subfolderWithContent.withAttributes(new PathAttributes())).getFileId());
        assertEquals(nodeId, new DeepboxAttributesFinderFeature(session, fileid).find(file.withAttributes(new PathAttributes())).getFileId());

        new DeepboxDeleteFeature(session, fileid).delete(Collections.singletonList(folder.withAttributes(new PathAttributes())), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }