@Override
    public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback delete, final ConnectionCallback callback) throws BackgroundException {
        try {
            if(status.isExists()) {
                if(log.isWarnEnabled()) {
                    log.warn(String.format("Delete file %s to be replaced with %s", renamed, file));
                }
                new DeepboxTrashFeature(session, fileid).delete(Collections.singletonList(renamed), callback, delete);
            }
            final String sourceId = fileid.getFileId(file);
            final NodeMove nodeMove = new NodeMove();
            final String targetParentId = fileid.getFileId(renamed.getParent());
            nodeMove.setTargetParentNodeId(targetParentId);
            new CoreRestControllerApi(session.getClient()).moveNode(nodeMove, sourceId);
            final NodeUpdate nodeUpdate = new NodeUpdate();
            nodeUpdate.setName(renamed.getName());
            new CoreRestControllerApi(session.getClient()).updateNode(nodeUpdate, sourceId);
            fileid.cache(file, null);
            fileid.cache(renamed, sourceId);
            return renamed.withAttributes(file.attributes().withFileId(sourceId));
        }
        catch(ApiException e) {
            throw new DeepboxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);
        }
    }
@Test
    public void testMoveOverrideFolder() 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 test = new DeepboxDirectoryFeature(session, fileid).mkdir(
                new Path(documents, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path target = new DeepboxDirectoryFeature(session, fileid).mkdir(
                new Path(documents, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path targetInTrash = new Path(trash, target.getName(), target.getType());

        final PathAttributes originalTestAttributes = new DeepboxAttributesFinderFeature(session, fileid).find(test);
        final PathAttributes originalTargetAttributes = new DeepboxAttributesFinderFeature(session, fileid).find(target);

        new DeepboxMoveFeature(session, fileid).move(test, target, new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback());
        assertFalse(new DeepboxFindFeature(session, fileid).find(test.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(target.withAttributes(new PathAttributes())));
        assertTrue(new DeepboxFindFeature(session, fileid).find(targetInTrash));

        final PathAttributes overriddenTargetAttributes = new DeepboxAttributesFinderFeature(session, fileid).find(target.withAttributes(new PathAttributes()));
        assertNotNull(originalTestAttributes.getFileId());
        assertEquals(originalTestAttributes.getFileId(), overriddenTargetAttributes.getFileId());
        assertEquals(originalTestAttributes.getModificationDate(), overriddenTargetAttributes.getModificationDate());
        assertEquals(originalTestAttributes.getChecksum(), overriddenTargetAttributes.getChecksum());

        final PathAttributes trashedTargetAttributes = new DeepboxAttributesFinderFeature(session, fileid).find(targetInTrash.withAttributes(new PathAttributes()));
        assertNotNull(originalTargetAttributes.getFileId());
        assertEquals(originalTargetAttributes.getFileId(), trashedTargetAttributes.getFileId());
        assertEquals(originalTargetAttributes.getModificationDate(), trashedTargetAttributes.getModificationDate());
        assertEquals(originalTargetAttributes.getChecksum(), trashedTargetAttributes.getChecksum());

        new DeepboxDeleteFeature(session, fileid).delete(Collections.singletonList(targetInTrash), new DisabledLoginCallback(), new Delete.DisabledCallback());
        new DeepboxDeleteFeature(session, fileid).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }