use of com.google.startupos.common.Protos.TextDiff in project startup-os by google.
the class TextDifferencerTool method run.
void run() throws IOException {
String leftFileContents = fileUtils.readFile(leftFile.get());
String rightFileContents = fileUtils.readFile(rightFile.get());
String diffString = GitRepo.getTextDiff(leftFile.get(), rightFile.get());
TextDiff textDiff = textDifferencer.getTextDiff(leftFileContents, rightFileContents, diffString);
if (printOutput.get()) {
System.out.println(textDiff);
}
}
use of com.google.startupos.common.Protos.TextDiff in project startup-os by google.
the class TextDifferencerTest method testMixedChangesAtTheMiddle.
@Test
public void testMixedChangesAtTheMiddle() {
String leftContents = "With Change.";
String rightContents = "With a Change.";
String diff = "@@ -1 +1 @@\n-With Change.\n+With a Change.";
TextDiff expectedTextDiff = readTextDiff("MixedChangesAtTheMiddle_diff_prototxt.txt");
assertEquals(expectedTextDiff, differencer.getTextDiff(leftContents, rightContents, diff));
}
use of com.google.startupos.common.Protos.TextDiff in project startup-os by google.
the class TextDifferencerTest method testOnlyDeletions.
@Test
public void testOnlyDeletions() {
String leftContents = "Deletion.";
String rightContents = "";
String diff = "@@ -1 +0,0 @@\n-Deletion.";
TextDiff expectedTextDiff = TextDiff.newBuilder().addLeftDiffLine(DiffLine.newBuilder().setText(leftContents).setType(ChangeType.DELETE).build()).addRightDiffLine(DiffLine.newBuilder().setText(rightContents).setType(ChangeType.LINE_PLACEHOLDER).build()).setLeftFileContents(leftContents).setRightFileContents(rightContents).build();
assertEquals(expectedTextDiff, differencer.getTextDiff(leftContents, rightContents, diff));
}
use of com.google.startupos.common.Protos.TextDiff in project startup-os by google.
the class TextDifferencerTest method testOnlyNoChanges.
@Test
public void testOnlyNoChanges() {
String contents = "No Change.";
TextDiff expectedTextDiff = TextDiff.newBuilder().setLeftFileContents(contents).setRightFileContents(contents).build();
assertEquals(expectedTextDiff, differencer.getTextDiff(contents, contents, ""));
}
use of com.google.startupos.common.Protos.TextDiff in project startup-os by google.
the class TextDifferencerTest method testMixedChangesAtTheEnd.
@Test
public void testMixedChangesAtTheEnd() {
String leftContents = "Change at end.";
String rightContents = "Change at end!";
String diff = "@@ -1 +1 @@\n-Change at end.\n+Change at end!";
TextDiff expectedTextDiff = readTextDiff("MixedChangesAtTheEnd_diff_prototxt.txt");
assertEquals(expectedTextDiff, differencer.getTextDiff(leftContents, rightContents, diff));
}
Aggregations