use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method replaceMultilineLineNoEOLInTheMiddle.
@Test
public void replaceMultilineLineNoEOLInTheMiddle() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 2, 3, 2, 5, "Abc\nDefgh");
assertThat(fixResult).text().isEqualTo("First line\nSecAbc\nDefghd line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(1, 1, 1, 2);
assertThat(edit).internalEdits().onlyElement().isReplace(3, 2, 3, 9);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method replaceWholeContent.
@Test
public void replaceWholeContent() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 4, 0, "Abc");
assertThat(fixResult).text().isEqualTo("Abc");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(0, 3, 0, 1);
assertThat(edit).internalEdits().onlyElement().isReplace(0, 34, 0, 3);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method insertMultilineLineWithEOLInTheMiddle.
@Test
public void insertMultilineLineWithEOLInTheMiddle() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 2, 5, 2, 5, "Abc\nDefgh\n");
assertThat(fixResult).text().isEqualTo("First line\nSeconAbc\nDefgh\nd line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(1, 1, 1, 3);
assertThat(edit).internalEdits().onlyElement().isInsert(5, 5, 10);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method deleteWholeContent.
@Test
public void deleteWholeContent() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 4, 0, "");
assertThat(fixResult).text().isEqualTo("");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isDelete(0, 3, 0);
assertThat(edit).internalEdits().onlyElement().isDelete(0, 34, 0);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method insertSingleLineNoEOLAtStart.
@Test
public void insertSingleLineNoEOLAtStart() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 1, 0, "Abc");
assertThat(fixResult).text().isEqualTo("AbcFirst line\nSecond line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(0, 1, 0, 1);
assertThat(edit).internalEdits().onlyElement().isInsert(0, 0, 3);
}
Aggregations