Search in sources :

Example 1 with DiffRow

use of com.github.difflib.text.DiffRow in project page-factory-2 by sbtqa.

the class DiffUtils method diff.

public static String diff(String string1, String string2) {
    DiffRowGenerator generator = DiffRowGenerator.create().showInlineDiffs(true).mergeOriginalRevised(true).oldTag(f -> "|").newTag(f -> "|").build();
    List<DiffRow> rows = new ArrayList<>();
    try {
        rows = generator.generateDiffRows(Collections.singletonList(string1), Collections.singletonList(string2));
    } catch (DiffException e) {
        LOG.info("There is an error in string diff", e);
    }
    return !rows.isEmpty() ? rows.get(0).getOldLine() : "";
}
Also used : List(java.util.List) Logger(org.slf4j.Logger) CoreStepsImpl(ru.sbtqa.tag.pagefactory.junit.CoreStepsImpl) DiffException(com.github.difflib.algorithm.DiffException) LoggerFactory(org.slf4j.LoggerFactory) DiffRow(com.github.difflib.text.DiffRow) DiffRowGenerator(com.github.difflib.text.DiffRowGenerator) Collections(java.util.Collections) ArrayList(java.util.ArrayList) DiffRow(com.github.difflib.text.DiffRow) DiffException(com.github.difflib.algorithm.DiffException) ArrayList(java.util.ArrayList) DiffRowGenerator(com.github.difflib.text.DiffRowGenerator)

Aggregations

DiffException (com.github.difflib.algorithm.DiffException)1 DiffRow (com.github.difflib.text.DiffRow)1 DiffRowGenerator (com.github.difflib.text.DiffRowGenerator)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 CoreStepsImpl (ru.sbtqa.tag.pagefactory.junit.CoreStepsImpl)1