@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());
  }
  @BeforeClass
  public static void setUpChild() throws IOException, InputOutputException {

    // create some test files and dirs to move

    // -- testDir1 // mv to targetDir
    //  | |
    //  | |--- myFile.txt
    //  |
    //  - testDir2
    //  | |
    //  | |--- myFile2.txt // mv to targetDir
    //  | |--- myFile3.txt // mv to targetDir after creating conflict manually
    //  |
    //  - targetDir
    //  |
    //  - dirToDelete
    //  | |
    //  | |--- fileToDeleteInDir.txt
    //  |
    //  |--- fileToDelete.txt

    Files.createDirectory(ROOT_TEST_DIR1.resolve(TEST_DIR_1));
    Files.createDirectory(ROOT_TEST_DIR2.resolve(TEST_DIR_1));

    Files.createDirectory(ROOT_TEST_DIR1.resolve(TEST_DIR_3));
    Files.createDirectory(ROOT_TEST_DIR2.resolve(TEST_DIR_3));

    Files.createDirectory(ROOT_TEST_DIR1.resolve(TEST_DIR_2));
    Files.createDirectory(ROOT_TEST_DIR2.resolve(TEST_DIR_2));

    Files.createFile(ROOT_TEST_DIR1.resolve(TEST_FILE_1));
    Files.createFile(ROOT_TEST_DIR2.resolve(TEST_FILE_1));

    Files.createFile(ROOT_TEST_DIR1.resolve(TEST_FILE_2));
    Files.createFile(ROOT_TEST_DIR2.resolve(TEST_FILE_2));

    Files.createFile(ROOT_TEST_DIR1.resolve(TEST_FILE_3));
    Files.createFile(ROOT_TEST_DIR2.resolve(TEST_FILE_3));

    Files.createFile(ROOT_TEST_DIR1.resolve(TEST_FILE_4));
    Files.createFile(ROOT_TEST_DIR2.resolve(TEST_FILE_4));

    Files.createFile(ROOT_TEST_DIR1.resolve(TEST_FILE_5));
    Files.createFile(ROOT_TEST_DIR2.resolve(TEST_FILE_5));

    // create directory to where the files should be moved
    Files.createDirectory(ROOT_TEST_DIR1.resolve(TARGET_DIR));
    Files.createDirectory(ROOT_TEST_DIR2.resolve(TARGET_DIR));

    // force recreation of object store
    OBJECT_STORE_1.sync();
    OBJECT_STORE_2.sync();

    // do not start the event aggregator but manually sync the event
    PathObject pathObject =
        OBJECT_STORE_1.getObjectManager().getObjectForPath(TEST_DIR_1.toString());

    moveDirEvent =
        new MoveEvent(
            TEST_DIR_1,
            TARGET_DIR,
            TARGET_DIR.getFileName().toString(),
            pathObject
                .getVersions()
                .get(Math.max(pathObject.getVersions().size() - 1, 0))
                .getHash(),
            System.currentTimeMillis());

    PathObject fileObject =
        OBJECT_STORE_1.getObjectManager().getObjectForPath(TEST_FILE_2.toString());

    moveFileEvent =
        new MoveEvent(
            TEST_FILE_2,
            TARGET_DIR.resolve(TEST_FILE_2.getFileName().toString()),
            TEST_FILE_2.getFileName().toString(),
            fileObject
                .getVersions()
                .get(Math.max(fileObject.getVersions().size() - 1, 0))
                .getHash(),
            System.currentTimeMillis());

    moveConflictFileEvent =
        new MoveEvent(
            TEST_FILE_3,
            TARGET_DIR.resolve(TEST_FILE_3.getFileName().toString()),
            TEST_FILE_3.getFileName().toString(),
            fileObject
                .getVersions()
                .get(Math.max(fileObject.getVersions().size() - 1, 0))
                .getHash(),
            System.currentTimeMillis());
  }