@Test
  public void testConflict() throws InputOutputException, InterruptedException {
    // first move the file
    STORAGE_ADAPTER_1.move(
        StorageType.FILE,
        new TreePathElement(TEST_FILE_3.toString()),
        new TreePathElement(TARGET_DIR.resolve(TEST_FILE_3.getFileName().toString()).toString()));
    // force recreation of object store
    OBJECT_STORE_1.sync();

    // now adjust the file on client2 to get a different version
    STORAGE_ADAPTER_2.persist(
        StorageType.FILE,
        new TreePathElement(TEST_FILE_3.toString()),
        "Some different content causing a conflict".getBytes());
    STORAGE_ADAPTER_2.move(
        StorageType.FILE,
        new TreePathElement(TEST_FILE_3.toString()),
        new TreePathElement(TARGET_DIR.resolve(TEST_FILE_3.getFileName().toString()).toString()));
    OBJECT_STORE_2.sync();

    UUID exchangeId = UUID.randomUUID();

    FileOfferExchangeHandler conflictFileOfferExchangeHandler =
        new FileOfferExchangeHandler(
            exchangeId,
            CLIENT_DEVICE_1,
            CLIENT_MANAGER_1,
            CLIENT_1,
            OBJECT_STORE_1,
            STORAGE_ADAPTER_1,
            GLOBAL_EVENT_BUS_1,
            moveConflictFileEvent);

    CLIENT_1
        .getObjectDataReplyHandler()
        .addResponseCallbackHandler(exchangeId, conflictFileOfferExchangeHandler);

    Thread conflictFileOfferExchangeHandlerThread = new Thread(conflictFileOfferExchangeHandler);
    conflictFileOfferExchangeHandlerThread.setName("TEST-ConflictFileOfferExchangeHandler");
    conflictFileOfferExchangeHandlerThread.start();

    // wait for completion
    conflictFileOfferExchangeHandler.await();

    CLIENT_1.getObjectDataReplyHandler().removeResponseCallbackHandler(exchangeId);

    assertTrue(
        "FileOfferExchangeHandler should be completed after wait",
        conflictFileOfferExchangeHandler.isCompleted());

    FileOfferExchangeHandlerResult result = conflictFileOfferExchangeHandler.getResult();

    assertEquals("Only one client should have responded", 1, result.getFileOfferResponses().size());
    assertEquals(
        "StatusCode should be equal",
        StatusCode.CONFLICT,
        result.getFileOfferResponses().get(0).getStatusCode());
  }
  @Test
  public void testMoveFile() throws InterruptedException, InputOutputException {

    // first move the file
    STORAGE_ADAPTER_1.move(
        StorageType.FILE,
        new TreePathElement(TEST_FILE_2.toString()),
        new TreePathElement(TARGET_DIR.resolve(TEST_FILE_2.getFileName().toString()).toString()));
    // force recreation of object store
    OBJECT_STORE_1.sync();

    UUID exchangeId = UUID.randomUUID();

    FileOfferExchangeHandler fileOfferExchangeHandler =
        new FileOfferExchangeHandler(
            exchangeId,
            CLIENT_DEVICE_1,
            CLIENT_MANAGER_1,
            CLIENT_1,
            OBJECT_STORE_1,
            STORAGE_ADAPTER_1,
            GLOBAL_EVENT_BUS_1,
            moveFileEvent);

    CLIENT_1
        .getObjectDataReplyHandler()
        .addResponseCallbackHandler(exchangeId, fileOfferExchangeHandler);

    Thread fileOfferExchangeHandlerThread = new Thread(fileOfferExchangeHandler);
    fileOfferExchangeHandlerThread.setName("TEST-FileOfferExchangeHandler");
    fileOfferExchangeHandlerThread.start();

    // wait for completion
    fileOfferExchangeHandler.await();

    CLIENT_1.getObjectDataReplyHandler().removeResponseCallbackHandler(exchangeId);

    assertTrue(
        "FileOfferExchangeHandler should be completed after wait",
        fileOfferExchangeHandler.isCompleted());

    FileOfferExchangeHandlerResult result = fileOfferExchangeHandler.getResult();

    assertEquals("Only one client should have responded", 1, result.getFileOfferResponses().size());
    assertEquals(
        "StatusCode should be equal",
        StatusCode.ACCEPTED,
        result.getFileOfferResponses().get(0).getStatusCode());
  }
  @Test
  public void testDeleteFile() throws InterruptedException {
    deleteFileEvent =
        new DeleteEvent(
            TEST_FILE_5, TEST_FILE_5.getFileName().toString(), null, System.currentTimeMillis());

    UUID exchangeId = UUID.randomUUID();

    FileOfferExchangeHandler deleteFileOfferExchangeHandler =
        new FileOfferExchangeHandler(
            exchangeId,
            CLIENT_DEVICE_1,
            CLIENT_MANAGER_1,
            CLIENT_1,
            OBJECT_STORE_1,
            STORAGE_ADAPTER_1,
            GLOBAL_EVENT_BUS_1,
            deleteFileEvent);

    CLIENT_1
        .getObjectDataReplyHandler()
        .addResponseCallbackHandler(exchangeId, deleteFileOfferExchangeHandler);

    Thread deleteFileOfferExchangeHandlerThread = new Thread(deleteFileOfferExchangeHandler);
    deleteFileOfferExchangeHandlerThread.setName("TEST-DeleteFileOfferExchangeHandler");
    deleteFileOfferExchangeHandlerThread.start();

    // wait for completion
    deleteFileOfferExchangeHandler.await();

    CLIENT_1.getObjectDataReplyHandler().removeResponseCallbackHandler(exchangeId);

    assertTrue(
        "FileOfferExchangeHandler should be completed after wait",
        deleteFileOfferExchangeHandler.isCompleted());

    FileOfferExchangeHandlerResult result = deleteFileOfferExchangeHandler.getResult();

    assertEquals("Only one client should have responded", 1, result.getFileOfferResponses().size());
    assertEquals(
        "StatusCode should be equal",
        StatusCode.ACCEPTED,
        result.getFileOfferResponses().get(0).getStatusCode());
  }