@Override
    public Path move(final Path file, final Path target, final TransferStatus status, final Delete.Callback delete, final ConnectionCallback callback) throws BackgroundException {
        try {
            final EueApiClient client = new EueApiClient(session);
            if(status.isExists()) {
                if(!new CaseInsensitivePathPredicate(file).test(target)) {
                    if(log.isWarnEnabled()) {
                        log.warn(String.format("Trash file %s to be replaced with %s", target, file));
                    }
                    new EueTrashFeature(session, fileid).delete(Collections.singletonMap(target, status), callback, delete);
                }
            }
            final String resourceId = fileid.getFileId(file);
            if(!new SimplePathPredicate(file.getParent()).test(target.getParent())) {
                final ResourceMoveResponseEntries resourceMoveResponseEntries;
                final String parentResourceId = fileid.getFileId(target.getParent());
                switch(parentResourceId) {
                    case EueResourceIdProvider.ROOT:
                    case EueResourceIdProvider.TRASH:
                        resourceMoveResponseEntries = new MoveChildrenForAliasApiApi(client)
                                .resourceAliasAliasChildrenMovePost(parentResourceId,
                                        Collections.singletonList(String.format("%s/resource/%s",
                                                session.getBasePath(), resourceId)), null, null, null,
                                        "rename", null);
                        break;
                    default:
                        resourceMoveResponseEntries = new MoveChildrenApi(client)
                                .resourceResourceIdChildrenMovePost(parentResourceId,
                                        Collections.singletonList(String.format("%s/resource/%s",
                                                session.getBasePath(), resourceId)), null, null, null,
                                        "rename", null);
                }
                if(null == resourceMoveResponseEntries) {
                    // Move of single file will return 200 status code with empty response body
                }
                else {
                    for(ResourceMoveResponseEntry resourceMoveResponseEntry : resourceMoveResponseEntries.values()) {
                        switch(resourceMoveResponseEntry.getStatusCode()) {
                            case HttpStatus.SC_OK:
                                break;
                            default:
                                log.warn(String.format("Failure %s moving file %s", resourceMoveResponseEntries, file));
                                final ResourceCreationResponseEntryEntity entity = resourceMoveResponseEntry.getEntity();
                                if(null == entity) {
                                    throw new EueExceptionMappingService().map(new ApiException(resourceMoveResponseEntry.getReason(),
                                            null, resourceMoveResponseEntry.getStatusCode(), client.getResponseHeaders()));
                                }
                                throw new EueExceptionMappingService().map(new ApiException(resourceMoveResponseEntry.getEntity().getError(),
                                        null, resourceMoveResponseEntry.getStatusCode(), client.getResponseHeaders()));
                        }
                    }
                }
            }
            if(!StringUtils.equals(file.getName(), target.getName())) {
                final ResourceUpdateModel resourceUpdateModel = new ResourceUpdateModel();
                final ResourceUpdateModelUpdate resourceUpdateModelUpdate = new ResourceUpdateModelUpdate();
                final Uifs uifs = new Uifs();
                uifs.setName(target.getName());
                resourceUpdateModelUpdate.setUifs(uifs);
                resourceUpdateModel.setUpdate(resourceUpdateModelUpdate);
                final ResourceMoveResponseEntries resourceMoveResponseEntries = new UpdateResourceApi(client).resourceResourceIdPatch(resourceId,
                        resourceUpdateModel, null, null, null);
                if(null == resourceMoveResponseEntries) {
                    // Move of single file will return 200 status code with empty response body
                }
                else {
                    for(ResourceMoveResponseEntry resourceMoveResponseEntry : resourceMoveResponseEntries.values()) {
                        switch(resourceMoveResponseEntry.getStatusCode()) {
                            case HttpStatus.SC_CREATED:
                                break;
                            default:
                                log.warn(String.format("Failure %s renaming file %s", resourceMoveResponseEntry, file));
                                throw new EueExceptionMappingService().map(new ApiException(resourceMoveResponseEntry.getReason(),
                                        null, resourceMoveResponseEntry.getStatusCode(), client.getResponseHeaders()));
                        }
                    }
                }
            }
            fileid.cache(file, null);
            return target;
        }
        catch(ApiException e) {
            throw new EueExceptionMappingService().map("Cannot rename {0}", e, file);
        }
    }
@Test
    public void testMoveFile() throws Exception {
        final EueResourceIdProvider fileid = new EueResourceIdProvider(session);
        final Path sourceFolder = new EueDirectoryFeature(session, fileid).mkdir(
                new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path sourceFile = new Path(sourceFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        createFile(fileid, sourceFile, RandomUtils.nextBytes(541));
        final PathAttributes sourceAttr = new EueAttributesFinderFeature(session, fileid).find(sourceFile);
        assertTrue(new EueFindFeature(session, fileid).find(sourceFile));
        final Path targetFolder = new EueDirectoryFeature(session, fileid).mkdir(
                new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path targetFile = new EueMoveFeature(session, fileid).move(sourceFile,
                new Path(targetFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
        assertFalse(new EueFindFeature(session, fileid).find(sourceFile));
        assertTrue(new EueFindFeature(session, fileid).find(targetFile));
        assertFalse(new DefaultFindFeature(session).find(sourceFile));
        assertTrue(new DefaultFindFeature(session).find(targetFile));
        final PathAttributes targetAttributes = new EueAttributesFinderFeature(session, fileid).find(targetFile);
        assertEquals(sourceAttr.getSize(), targetAttributes.getSize());
        assertNotEquals(sourceAttr.getETag(), targetAttributes.getETag());
        assertEquals(sourceAttr.getFileId(), targetAttributes.getFileId());
        new EueDeleteFeature(session, fileid).delete(Arrays.asList(sourceFolder, targetFolder), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }