@Test
void displayWithConflicts() throws Exception
{

    List<String> previous = readLines("previous.txt");
    List<String> current = readLines("twoContexts.txt");
    List<String> next = readLines("twoContexts_next.txt");
    MergeResult<String> mergeResult = getDiffManager().merge(previous, next, current, null);
    assertEquals(1, mergeResult.getConflicts().size());
    DiffResult<String> diffResult = getDiffManager().diff(previous, next, null);
    List<UnifiedDiffBlock<String, Object>> unifiedDiffBlocks = unifiedDiffDisplayer.display(diffResult);
    assertEquals(2, unifiedDiffBlocks.size());
    assertFalse(unifiedDiffBlocks.get(0).isConflicting());
    assertFalse(unifiedDiffBlocks.get(1).isConflicting());
    unifiedDiffBlocks = unifiedDiffDisplayer.display(diffResult, mergeResult.getConflicts());
    // 4 blocks:
    // - first one if the first changes without conflict
    // - second one is a context block
    // - third one is the conflict itself
    // - fourth one is another context block
    // We don't want to put the context inside the conflict to avoid any side effect when using it.
    assertEquals(4, unifiedDiffBlocks.size());
    assertFalse(unifiedDiffBlocks.get(0).isConflicting());
    assertFalse(unifiedDiffBlocks.get(1).isConflicting());
    assertTrue(unifiedDiffBlocks.get(2).isConflicting());
    assertFalse(unifiedDiffBlocks.get(3).isConflicting());
    assertEquals(3, unifiedDiffBlocks.get(1).size());
    assertEquals(2, unifiedDiffBlocks.get(2).size());
    UnifiedDiffConflictElement<String> unifiedDiffConflictElement = unifiedDiffBlocks.get(2).getConflict();
    assertEquals(Collections.singletonList("    //   If k > 2 then fib(k) = fib(k-1) + fib(k-2)."),
        unifiedDiffConflictElement.getPreviousElement());
    assertEquals(Collections.singletonList("    //   if k > 2 then fib(k) = fib(k-1) + fib(k-2)"),
        unifiedDiffConflictElement.getCurrentElement());
    assertEquals(Collections.singletonList("    //   if k > 2 then fib(k) = fib(k-1) + fib(k-2)?"),
        unifiedDiffConflictElement.getNextElement());
}