@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 BoxDeleteFeature(session, fileid).delete(Collections.singletonList(renamed), callback, delete);
            }
            final String id = fileid.getFileId(file);
            if(file.isDirectory()) {
                final Folder result = new FoldersApi(new BoxApiClient(session.getClient())).putFoldersId(
                        id, new FoldersFolderIdBody()
                                .name(renamed.getName())
                                .parent(new FoldersfolderIdParent()
                                        .id(fileid.getFileId(renamed.getParent()))),
                        null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
                fileid.cache(file, null);
                fileid.cache(renamed, id);
                return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
            }
            final File result = new FilesApi(new BoxApiClient(session.getClient())).putFilesId(
                    id, new FilesFileIdBody()
                            .name(renamed.getName())
                            .parent(new FilesfileIdParent()
                                    .id(fileid.getFileId(renamed.getParent()))),
                    null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
            fileid.cache(file, null);
            fileid.cache(renamed, id);
            return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
        }
        catch(ApiException e) {
            throw new BoxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);
        }
    }
@Test
    public void testMove() throws Exception {
        final BoxFileidProvider fileid = new BoxFileidProvider(session);
        final Path test = new BoxTouchFeature(session, fileid).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        assertNotNull(test.attributes().getFileId());
        assertEquals(0L, test.attributes().getSize());
        assertNotEquals(-1L, test.attributes().getModificationDate());
        final Path target = new BoxMoveFeature(session, fileid).move(test,
                new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
        assertFalse(new BoxFindFeature(session, fileid).find(new Path(test).withAttributes(PathAttributes.EMPTY)));
        assertTrue(new BoxFindFeature(session, fileid).find(target));
        assertEquals(test.attributes().getModificationDate(), target.attributes().getModificationDate());
        assertEquals(test.attributes().getChecksum(), target.attributes().getChecksum());
        assertEquals(Comparison.equal, session.getHost().getProtocol().getFeature(ComparisonService.class).compare(Path.Type.file, target.attributes(), new BoxAttributesFinderFeature(session, fileid).find(target)));
        new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }