@Test
void mergeCharOnConflicts() throws Exception
{

    MergeResult<Character> result;
    Conflict<Character> conflict;
    MergeConfiguration<Character> mergeConfiguration;
    List<Character> emptyList = Collections.emptyList();
    List<Character> onlyA = toCharacters("a");
    List<Character> onlyB = toCharacters("b");
    List<Character> onlyC = toCharacters("c");
    // New empty
    mergeConfiguration = null;
    result = this.diffManager.merge(onlyA, emptyList, onlyB, mergeConfiguration);
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, onlyA, onlyB,
        Type.CHANGE, 0, 0, onlyA, emptyList);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyB, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager.merge(onlyA, emptyList, onlyB, mergeConfiguration);
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyB, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager.merge(onlyA, emptyList, onlyB, mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyA, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager.merge(onlyA, emptyList, onlyB, mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(emptyList, result.getMerged());
    // Current and new at the same place
    mergeConfiguration = null;
    result = this.diffManager.merge(onlyA, onlyB, onlyC, mergeConfiguration);
    conflict = createConflict(0, 'a', 'c', 'b');
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyC, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager.merge(onlyA, onlyB, onlyC, mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyC, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager.merge(onlyA, onlyB, onlyC, mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyA, result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager.merge(onlyA, onlyB, onlyC, mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(onlyB, result.getMerged());
    // Current and new in conflict at different indices
    mergeConfiguration = null;
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('a', 'b'), Arrays.asList('a', 'z'),
        Type.CHANGE, 0, 0, Arrays.asList('a', 'b'), Arrays.asList('y', 'y'));
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("yycd"), toCharacters("azzd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("azzd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("yycd"), toCharacters("azzd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("azzd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("yycd"), toCharacters("azzd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("abcd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("yycd"), toCharacters("azzd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("yycd", toString(result.getMerged()));
    // Current and new in conflict at different indices
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('a', 'b'), Arrays.asList('y', 'y'),
        Type.CHANGE, 0, 0, Arrays.asList('a', 'b'), Arrays.asList('a', 'z'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("azzd"), toCharacters("yycd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("yycd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("azzd"), toCharacters("yycd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("yycd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("azzd"), toCharacters("yycd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("abcd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("abcd"), toCharacters("azzd"), toCharacters("yycd"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("azzd", toString(result.getMerged()));
    // New overlapping current
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('d', 'd', 'd', 'd'),
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('a', 'r', 'r', 'b'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("arrbcc"), toCharacters("ddddcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("ddddcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("arrbcc"), toCharacters("ddddcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("ddddcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("arrbcc"), toCharacters("ddddcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("aabbcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("arrbcc"), toCharacters("ddddcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("arrbcc", toString(result.getMerged()));
    // current overlapping new
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('a', 'r', 'r', 'b'),
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('d', 'd', 'd', 'd'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("ddddcc"), toCharacters("arrbcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("arrbcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("ddddcc"), toCharacters("arrbcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("arrbcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("ddddcc"), toCharacters("arrbcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("aabbcc", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("aabbcc"), toCharacters("ddddcc"), toCharacters("arrbcc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals("ddddcc", toString(result.getMerged()));
    // Multiple conflicts
    conflict = createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('a', 'r', 'r', 'b'),
        Type.CHANGE, 0, 0, Arrays.asList('a', 'a', 'b', 'b'), Arrays.asList('d', 'd', 'd', 'd'));
    Conflict<Character> conflict1 = createConflict(7,
        Type.CHANGE, 7, 7, Arrays.asList('a', 'b'), Arrays.asList('y', 'y'),
        Type.CHANGE, 7, 7, Arrays.asList('a', 'b'), Arrays.asList('a', 'z'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("aabbcc abcd"), toCharacters("ddddcc azzd"), toCharacters("arrbcc yycd"),
            mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    List<LogEvent> logConflicts = new ArrayList<>(result.getLog().getLogs(LogLevel.ERROR));
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("arrbcc yycd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("aabbcc abcd"), toCharacters("ddddcc azzd"), toCharacters("arrbcc yycd"),
            mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(logConflicts, result.getLog().getLogs(LogLevel.ERROR));
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("arrbcc yycd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("aabbcc abcd"), toCharacters("ddddcc azzd"), toCharacters("arrbcc yycd"),
            mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(logConflicts, result.getLog().getLogs(LogLevel.ERROR));
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("aabbcc abcd", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("aabbcc abcd"), toCharacters("ddddcc azzd"), toCharacters("arrbcc yycd"),
            mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(logConflicts, result.getLog().getLogs(LogLevel.ERROR));
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("ddddcc azzd", toString(result.getMerged()));
    // Another multiple conflicts
    conflict = createConflict(2,
        Type.CHANGE, 2, 2, Arrays.asList('c'), Arrays.asList('c', 'd'),
        Type.CHANGE, 2, 2, Arrays.asList('c'), Arrays.asList('d'));
    conflict1 = createConflict(4,
        Type.CHANGE, 4, 4, Arrays.asList('f'), Collections.emptyList(),
        Type.CHANGE, 4, 4, Arrays.asList('f'), Arrays.asList('f'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("abcefhik"), toCharacters("abdefgijk"), toCharacters("abcdehijk"), mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("abcdehijk", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("abcefhik"), toCharacters("abdefgijk"), toCharacters("abcdehijk"), mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("abcdehijk", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("abcefhik"), toCharacters("abdefgijk"), toCharacters("abcdehijk"), mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("abcefhijk", toString(result.getMerged()));
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("abcefhik"), toCharacters("abdefgijk"), toCharacters("abcdehijk"), mergeConfiguration);
    assertEquals(2, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(2, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(conflict1, result.getConflicts().get(1));
    assertEquals("abdefgijk", toString(result.getMerged()));
    mergeConfiguration = null;
    conflict = createConflict(1,
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('i'),
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('j'));
    result = this.diffManager
        .merge(toCharacters("abc"), toCharacters("ajbc"), toCharacters("aibc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aibc"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("abc"), toCharacters("ajbc"), toCharacters("aibc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aibc"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("abc"), toCharacters("ajbc"), toCharacters("aibc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("ajbc"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("abc"), toCharacters("ajbc"), toCharacters("aibc"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("abc"), result.getMerged());
    mergeConfiguration = null;
    conflict = createConflict(1,
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('i'),
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('i', 'j'));
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("aijb"), toCharacters("aib"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aib"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("aijb"), toCharacters("aib"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aib"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("aijb"), toCharacters("aib"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aijb"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("aijb"), toCharacters("aib"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("ab"), result.getMerged());
    mergeConfiguration = null;
    conflict = createConflict(1,
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('i', 'j'),
        Type.CHANGE, 1, 1, Collections.emptyList(), Arrays.asList('j'));
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("ajb"), toCharacters("aijb"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aijb"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("ajb"), toCharacters("aijb"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("aijb"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.NEXT);
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("ajb"), toCharacters("aijb"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("ajb"), result.getMerged());
    mergeConfiguration = new MergeConfiguration<>();
    mergeConfiguration.setFallbackOnConflict(MergeConfiguration.Version.PREVIOUS);
    result = this.diffManager
        .merge(toCharacters("ab"), toCharacters("ajb"), toCharacters("aijb"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("ab"), result.getMerged());
    // Current and next are same for the first part, so conflict should only concern the last part.
    conflict = this.createConflict(0,
        Type.CHANGE, 0, 0, Arrays.asList('y'), Arrays.asList('c'),
        Type.CHANGE, 0, 0, Arrays.asList('y'), Arrays.asList('b'));
    mergeConfiguration = null;
    result = this.diffManager
        .merge(toCharacters("xy"), toCharacters("ab"), toCharacters("ac"), mergeConfiguration);
    assertEquals(1, result.getLog().getLogs(LogLevel.ERROR).size());
    assertEquals(1, result.getConflicts().size());
    assertEquals(conflict, result.getConflicts().get(0));
    assertEquals(toCharacters("ac"), result.getMerged());
}