Search in sources :

Example 6 with FixResult

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

the class MultilineContentNoEOLTest method deleteWholeContent.

@Test
public void deleteWholeContent() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line", 1, 0, 3, 10, "");
    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, 33, 0);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 7 with FixResult

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

the class MultilineContentNoEOLTest method replaceWholeContent.

@Test
public void replaceWholeContent() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line", 1, 0, 3, 10, "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, 33, 0, 3);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 8 with FixResult

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

the class MultilineContentNoEOLTest method replaceMultilineLineNoEOLAtStart.

@Test
public void replaceMultilineLineNoEOLAtStart() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line", 1, 0, 1, 2, "Abc\nDefgh");
    assertThat(fixResult).text().isEqualTo("Abc\nDefghrst line\nSecond line\nThird line");
    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 9 with FixResult

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

the class MultilineContentNoEOLTest method replaceMultilineLineNoEOLAtEnd.

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

Example 10 with FixResult

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

the class MultilineContentNoEOLTest method replaceWithSingleLineWithEOLInTheMiddle.

@Test
public void replaceWithSingleLineWithEOLInTheMiddle() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line", 2, 3, 2, 5, "Abc\n");
    assertThat(fixResult).text().isEqualTo("First line\nSecAbc\nd line\nThird line");
    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, 4);
}
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