SideBySideDiffCreator { public List<SideBySideDiffRow> createFromDiffResult(final String diffResult) { final List<DiffSegment> diffSegments = DiffResultParser.parseNormalDiffResult(diffResult); final List<SourceLine> leftLinesList = process(LEFT, leftSourceLines, diffSegments); final List<SourceLine> rightLinesList = process(RIGHT, rightSourceLines, diffSegments); assertEqualListSize(diffResult, leftLinesList, rightLinesList); final List<SideBySideDiffRow> diff = new ArrayList<SideBySideDiffRow>(); for (int i = 0; i < Math.max(leftLinesList.size(), rightLinesList.size()); i++) { diff.add(new SideBySideDiffRow(leftLinesList.get(i), rightLinesList.get(i))); } return diff; } @SuppressWarnings({"unchecked"})  SideBySideDiffCreator(final TextFile fromFile, final TextFile toFile); List<SideBySideDiffRow> createFromDiffResult(final String diffResult);  }
@Test public void testCreateFromDiffResult() throws Exception { final String diffResult = "1d1\r\n<\r\n"; final TextFile fromFile = new TextFile("\r\ntest\r\nfile\r\n"); final TextFile toFile = new TextFile("test\r\nfile\r\n"); final SideBySideDiffCreator diffCreator = new SideBySideDiffCreator(fromFile, toFile); final List<SideBySideDiffRow> result = diffCreator.createFromDiffResult(diffResult); assertEquals(3, result.size()); final Iterator<SideBySideDiffRow> iterator = result.iterator(); assertFalse(iterator.next().getIsUnchanged()); assertTrue(iterator.next().getIsUnchanged()); assertTrue(iterator.next().getIsUnchanged()); for (SideBySideDiffRow row : result) { assertEquals(row.getLeft().getLine(), row.getRight().getLine()); } }