@Test public void getPatch() throws DiffException { String expected = "1\n2\n3"; String actual = "1\n2"; assertThat( Client.getPatch(expected, actual, "expected.txt", "actual.txt"), equalTo( "--- expected.txt\n" + "+++ actual.txt\n" + "@@ -1,3 +1,2 @@\n" + " 1\n" + " 2\n" + "-3")); }
@Nonnull @VisibleForTesting static String getPatch( String expected, String actual, String expectedFileName, String actualFileName) throws DiffException { List<String> referenceLines = Arrays.asList(expected.split("\n")); List<String> testLines = Arrays.asList(actual.split("\n")); Patch<String> patch = DiffUtils.diff(referenceLines, testLines); if (patch.getDeltas().isEmpty()) { return ""; } else { List<String> patchLines = UnifiedDiffUtils.generateUnifiedDiff( expectedFileName, actualFileName, referenceLines, patch, 3); return StringUtils.join(patchLines, "\n"); } }
Client extends AbstractClient implements IClient { @Nonnull @VisibleForTesting static String getPatch( String expected, String actual, String expectedFileName, String actualFileName) throws DiffException { List<String> referenceLines = Arrays.asList(expected.split("\n")); List<String> testLines = Arrays.asList(actual.split("\n")); Patch<String> patch = DiffUtils.diff(referenceLines, testLines); if (patch.getDeltas().isEmpty()) { return ""; } else { List<String> patchLines = UnifiedDiffUtils.generateUnifiedDiff( expectedFileName, actualFileName, referenceLines, patch, 3); return StringUtils.join(patchLines, "\n"); } } }
Client extends AbstractClient implements IClient { @Nonnull @VisibleForTesting static String getPatch( String expected, String actual, String expectedFileName, String actualFileName) throws DiffException { List<String> referenceLines = Arrays.asList(expected.split("\n")); List<String> testLines = Arrays.asList(actual.split("\n")); Patch<String> patch = DiffUtils.diff(referenceLines, testLines); if (patch.getDeltas().isEmpty()) { return ""; } else { List<String> patchLines = UnifiedDiffUtils.generateUnifiedDiff( expectedFileName, actualFileName, referenceLines, patch, 3); return StringUtils.join(patchLines, "\n"); } } Client(Settings settings);  Client(String[] args); }
Client extends AbstractClient implements IClient { @Nonnull @VisibleForTesting static String getPatch( String expected, String actual, String expectedFileName, String actualFileName) throws DiffException { List<String> referenceLines = Arrays.asList(expected.split("\n")); List<String> testLines = Arrays.asList(actual.split("\n")); Patch<String> patch = DiffUtils.diff(referenceLines, testLines); if (patch.getDeltas().isEmpty()) { return ""; } else { List<String> patchLines = UnifiedDiffUtils.generateUnifiedDiff( expectedFileName, actualFileName, referenceLines, patch, 3); return StringUtils.join(patchLines, "\n"); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands); }
Client extends AbstractClient implements IClient { @Nonnull @VisibleForTesting static String getPatch( String expected, String actual, String expectedFileName, String actualFileName) throws DiffException { List<String> referenceLines = Arrays.asList(expected.split("\n")); List<String> testLines = Arrays.asList(actual.split("\n")); Patch<String> patch = DiffUtils.diff(referenceLines, testLines); if (patch.getDeltas().isEmpty()) { return ""; } else { List<String> patchLines = UnifiedDiffUtils.generateUnifiedDiff( expectedFileName, actualFileName, referenceLines, patch, 3); return StringUtils.join(patchLines, "\n"); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands);  }