Search in sources :

Example 56 with FixResult

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

the class OneLineContentWithEOLTest method replaceWithSingleLineWithEOLAtEnd.

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

Example 57 with FixResult

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

the class OneLineContentWithEOLTest method insertSingleLineNoEOLAtStart.

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

Example 58 with FixResult

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

the class OneLineContentWithEOLTest method replaceWholeContent.

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

Example 59 with FixResult

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

the class OneLineContentWithEOLTest method deleteAtEnd.

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

Example 60 with FixResult

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

the class OneLineContentWithEOLTest method insertSingleLineNoEOLAtEnd.

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