fitnesse.responders.versions.VersionComparer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
package fitnesse.responders.versions;
import java.util.LinkedList;
import java.util.List;
import difflib.DiffUtils;
import difflib.Patch;
public class VersionComparer {
private List differences;
public boolean compare(String originalVersion, String originalContent, String revisedVersion, String revisedContent) {
Patch patch = DiffUtils.diff(contentToLines(originalContent), contentToLines(revisedContent));
differences = DiffUtils.generateUnifiedDiff(originalVersion, revisedVersion,
contentToLines(originalContent), patch, 5);
return true;
}
public List getDifferences() {
return differences;
}
private List contentToLines(String content) {
List lines = new LinkedList<>();
for(String line : content.split("\n"))
lines.add(line);
return lines;
}
}