@Override
    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException {
        // Must split otherwise 413 Request Entity Too Large is returned
        for(List<Path> partition : new Partition<>(new ArrayList<>(files.keySet()),
                new HostPreferences(session.getHost()).getInteger("googledrive.delete.multiple.partition"))) {
            final BatchRequest batch = session.getClient().batch();
            final List<BackgroundException> failures = new CopyOnWriteArrayList<>();
            for(Path f : partition) {
                try {
                    if(new SimplePathPredicate(DriveHomeFinderService.SHARED_DRIVES_NAME).test(f.getParent())) {
                        session.getClient().teamdrives().delete(fileid.getFileId(f))
                                .queue(batch, new DeleteBatchCallback<>(f, failures, callback));
                    }
                    else {
                        if(f.attributes().isHidden()) {
                            log.warn(String.format("Delete file %s already in trash", f));
                            new DriveBatchDeleteFeature(session, fileid).queue(f, batch, callback, failures);
                            continue;
                        }
                        final File properties = new File();
                        properties.setTrashed(true);
                        session.getClient().files().update(fileid.getFileId(f), properties)
                                .setSupportsAllDrives(new HostPreferences(session.getHost()).getBoolean("googledrive.teamdrive.enable"))
                                .queue(batch, new DeleteBatchCallback<>(f, failures, callback));
                    }
                }
                catch(IOException e) {
                    throw new DriveExceptionMappingService(fileid).map("Cannot delete {0}", e, f);
                }
            }
            if(!partition.isEmpty()) {
                try {
                    batch.execute();
                }
                catch(IOException e) {
                    throw new DriveExceptionMappingService(fileid).map(e);
                }
                for(BackgroundException e : failures) {
                    throw e;
                }
            }
        }
    }
@Test(expected = NotfoundException.class)
    public void testDeleteNotFound() throws Exception {
        final Path test = new Path(DriveHomeFinderService.MYDRIVE_FOLDER, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
        new DriveBatchTrashFeature(session, new DriveFileIdProvider(session)).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }