@Override
    public Path move(final Path file, final Path target, final TransferStatus status, final Delete.Callback delete, final ConnectionCallback callback) throws BackgroundException {
        try {
            final BrickApiClient client = new BrickApiClient(session);
            if(status.isExists()) {
                if(!new CaseInsensitivePathPredicate(file).test(target)) {
                    if(log.isWarnEnabled()) {
                        log.warn(String.format("Delete file %s to be replaced with %s", target, file));
                    }
                    new BrickDeleteFeature(session).delete(Collections.singletonList(target), callback, delete);
                }
            }
            final FileActionEntity entity = new FileActionsApi(client)
                    .move(new MovePathBody().destination(StringUtils.removeStart(target.getAbsolute(), String.valueOf(Path.DELIMITER))),
                            StringUtils.removeStart(file.getAbsolute(), String.valueOf(Path.DELIMITER)));
            if(entity.getFileMigrationId() != null) {
                this.poll(client, entity);
            }
            return target.withAttributes(file.attributes());
        }
        catch(ApiException e) {
            throw new BrickExceptionMappingService().map("Cannot rename {0}", e, file);
        }
    }
@Test
    public void testRename() throws Exception {
        final Path test = new BrickTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(),
                new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.file)), new TransferStatus());
        final Path target = new BrickMoveFeature(session).move(test, new Path(new DefaultHomeFinderService(session).find(),
                new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
        assertFalse(new BrickFindFeature(session).find(test));
        assertTrue(new BrickFindFeature(session).find(target));
        assertEquals(test.attributes(), target.attributes());
        new BrickDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }