@Override
    public Path copy(final Path file, final Path target, final TransferStatus status, final ConnectionCallback callback, final StreamListener listener) throws BackgroundException {
        try {
            if(status.isExists()) {
                if(log.isWarnEnabled()) {
                    log.warn(String.format("Delete file %s to be replaced with %s", target, file));
                }
                new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(target), callback, new Delete.DisabledCallback());
            }
            if(file.isDirectory()) {
                return target.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
                        new FoldersApi(new BoxApiClient(session.getClient())).postFoldersIdCopy(
                                fileid.getFileId(file),
                                new FolderIdCopyBody().name(target.getName()).parent(new FoldersfolderIdcopyParent().id(fileid.getFileId(target.getParent()))),
                                BoxAttributesFinderFeature.DEFAULT_FIELDS)
                ));
            }
            return target.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(
                    new FilesApi(new BoxApiClient(session.getClient())).postFilesIdCopy(
                            fileid.getFileId(file),
                            new FileIdCopyBody()
                                    .name(target.getName())
                                    .parent(new FilesfileIdcopyParent().id(fileid.getFileId(target.getParent()))),
                            null, BoxAttributesFinderFeature.DEFAULT_FIELDS)
            ));
        }
        catch(ApiException e) {
            throw new BoxExceptionMappingService(fileid).map("Cannot copy {0}", e, file);
        }
    }
@Test
    public void testCopyOverride() throws Exception {
        final BoxFileidProvider fileid = new BoxFileidProvider(session);
        final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
        new BoxDirectoryFeature(session, fileid).mkdir(folder, new TransferStatus());
        final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        new BoxTouchFeature(session, fileid).touch(test, new TransferStatus());
        final Path copy = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
        final Path existing = new BoxTouchFeature(session, fileid).touch(copy, new TransferStatus());
        new BoxCopyFeature(session, fileid).copy(test, copy, new TransferStatus().exists(true).withRemote(existing.attributes()), new DisabledConnectionCallback(), new DisabledStreamListener());
        final Find find = new DefaultFindFeature(session);
        assertTrue(find.find(test));
        assertTrue(find.find(copy));
        new BoxDeleteFeature(session, fileid).delete(Arrays.asList(test, copy), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }