Search in sources :

Example 26 with FixResult

use of com.google.gerrit.server.fixes.FixCalculator.FixResult in project gerrit by GerritCodeReview.

the class MultilineContentWithEOLTest method replaceMultilineLineNoEOLAtStart.

@Test
public void replaceMultilineLineNoEOLAtStart() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 1, 2, "Abc\nDefgh");
    assertThat(fixResult).text().isEqualTo("Abc\nDefghrst line\nSecond line\nThird line\n");
    assertThat(fixResult).edits().hasSize(1);
    Edit edit = fixResult.edits.get(0);
    assertThat(edit).isReplace(0, 1, 0, 2);
    assertThat(edit).internalEdits().onlyElement().isReplace(0, 2, 0, 9);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 27 with FixResult

use of com.google.gerrit.server.fixes.FixCalculator.FixResult in project gerrit by GerritCodeReview.

the class MultilineContentWithEOLTest method insertMultilineLineWithEOLAtEnd.

@Test
public void insertMultilineLineWithEOLAtEnd() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 4, 0, 4, 0, "Abc\nDefgh\n");
    assertThat(fixResult).text().isEqualTo("First line\nSecond line\nThird line\nAbc\nDefgh\n");
    assertThat(fixResult).edits().hasSize(1);
    Edit edit = fixResult.edits.get(0);
    assertThat(edit).isInsert(3, 3, 2);
    assertThat(edit).internalEdits().onlyElement().isInsert(0, 0, 10);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 28 with FixResult

use of com.google.gerrit.server.fixes.FixCalculator.FixResult 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);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 29 with FixResult

use of com.google.gerrit.server.fixes.FixCalculator.FixResult 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);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 30 with FixResult

use of com.google.gerrit.server.fixes.FixCalculator.FixResult 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);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Aggregations

FixResult (com.google.gerrit.server.fixes.FixCalculator.FixResult)113 Test (org.junit.Test)113 Edit (org.eclipse.jgit.diff.Edit)112 Range (com.google.gerrit.entities.Comment.Range)5 FixReplacement (com.google.gerrit.entities.FixReplacement)5 Text (com.google.gerrit.server.patch.Text)1