Search in sources :

Example 41 with FixResult

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

the class OneLineContentWithEOLTest method replaceMultilineLineNoEOLInTheMiddle.

@Test
public void replaceMultilineLineNoEOLInTheMiddle() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\n", 1, 3, 1, 5, "Abc\nDefgh");
    assertThat(fixResult).text().isEqualTo("FirAbc\nDefgh 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(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 42 with FixResult

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

the class OneLineContentWithEOLTest method replaceMultilineLineWithEOLAtStart.

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

Example 43 with FixResult

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

the class OneLineContentWithEOLTest method insertSingleLineNoEOLInTheMiddle.

@Test
public void insertSingleLineNoEOLInTheMiddle() throws Exception {
    FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\n", 1, 5, 1, 5, "Abc");
    assertThat(fixResult).text().isEqualTo("FirstAbc 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(5, 5, 3);
}
Also used : FixResult(com.google.gerrit.server.fixes.FixCalculator.FixResult) Edit(org.eclipse.jgit.diff.Edit) Test(org.junit.Test)

Example 44 with FixResult

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

the class OneLineContentWithEOLTest method replaceMultilineLineNoEOLAtStart.

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

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

the class OneLineContentNoEOLTest method replaceWithSingleLineWithEOLInTheMiddle.

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