Search in sources :

Example 81 with FixResult

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

the class OneLineContentNoEOLTest method insertMultilineLineWithEOLAtEnd.

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

Example 82 with FixResult

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

the class OneLineContentNoEOLTest method insertMultilineLineWithEOLAtStart.

@Test
public void insertMultilineLineWithEOLAtStart() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line", 1, 0, 1, 0, "Abc\nDefgh\n");
    assertThat(fixResult).text().isEqualTo("Abc\nDefgh\nFirst line");
    assertThat(fixResult).edits().hasSize(1);
    Edit edit = fixResult.edits.get(0);
    assertThat(edit).isInsert(0, 0, 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 83 with FixResult

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

the class OneLineContentNoEOLTest method insertSingleLineWithEOLAtEnd.

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

Example 84 with FixResult

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

the class OneLineContentWithEOLTest method replaceMultilineLineNoEOLAtEnd.

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

Example 85 with FixResult

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

the class OneLineContentWithEOLTest method insertMultilineLineWithEOLAtStart.

@Test
public void insertMultilineLineWithEOLAtStart() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\n", 1, 0, 1, 0, "Abc\nDefgh\n");
    assertThat(fixResult).text().isEqualTo("Abc\nDefgh\nFirst line\n");
    assertThat(fixResult).edits().hasSize(1);
    Edit edit = fixResult.edits.get(0);
    assertThat(edit).isInsert(0, 0, 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)

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