@Test
public void testUploadDedup() throws Exception {

    // Testing the de-duping works.
    Collection<File> files = generateFiles(1, 1, 1);
    File file = files.iterator().next();
    AbstractBackupPath abstractBackupPath = getDummyPath(file.toPath());
    // 1. Give same file to upload x times. Only one request will be entertained.
    int size = 10;
    ExecutorService threads = Executors.newFixedThreadPool(size);
    List<Callable<Boolean>> torun = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        torun.add(
                () -> {
                    myFileSystem.uploadFile(
                            file.toPath(), file.toPath(), abstractBackupPath, 2, true);
                    return Boolean.TRUE;
                });
    }
    // all tasks executed in different threads, at 'once'.
    List<Future<Boolean>> futures = threads.invokeAll(torun);
    // no more need for the threadpool
    threads.shutdown();
    for (Future future : futures) {
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            // Do nothing.
        }
    }
    // 2. Verify the success metric for upload is not same as size, i.e. some amount of
    // de-duping happened.
    Assert.assertNotEquals(size, (int) backupMetrics.getValidUploads().actualCount());
}