Search in sources :

Example 11 with FixSuggestionInfo

use of com.google.gerrit.extensions.common.FixSuggestionInfo in project gerrit by GerritCodeReview.

the class RobotCommentsIT method fixWithTwoCloseReplacementsOnSameFileCanBeApplied.

@Test
public void fixWithTwoCloseReplacementsOnSameFileCanBeApplied() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    FixReplacementInfo fixReplacementInfo1 = new FixReplacementInfo();
    fixReplacementInfo1.path = FILE_NAME;
    fixReplacementInfo1.range = createRange(2, 0, 3, 0);
    fixReplacementInfo1.replacement = "First modification\n";
    FixReplacementInfo fixReplacementInfo2 = new FixReplacementInfo();
    fixReplacementInfo2.path = FILE_NAME;
    fixReplacementInfo2.range = createRange(3, 0, 4, 0);
    fixReplacementInfo2.replacement = "Some other modified content\n";
    FixSuggestionInfo fixSuggestionInfo = createFixSuggestionInfo(fixReplacementInfo1, fixReplacementInfo2);
    withFixRobotCommentInput.fixSuggestions = ImmutableList.of(fixSuggestionInfo);
    addRobotComment(changeId, withFixRobotCommentInput);
    List<RobotCommentInfo> robotCommentInfos = getRobotComments();
    List<String> fixIds = getFixIds(robotCommentInfos);
    String fixId = Iterables.getOnlyElement(fixIds);
    gApi.changes().id(changeId).current().applyFix(fixId);
    Optional<BinaryResult> file = gApi.changes().id(changeId).edit().getFile(FILE_NAME);
    BinaryResultSubject.assertThat(file).value().asString().isEqualTo("First line\nFirst modification\nSome other modified content\nFourth line\nFifth line\n" + "Sixth line\nSeventh line\nEighth line\nNinth line\nTenth line\n");
}
Also used : FixReplacementInfo(com.google.gerrit.extensions.common.FixReplacementInfo) FixSuggestionInfo(com.google.gerrit.extensions.common.FixSuggestionInfo) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

FixSuggestionInfo (com.google.gerrit.extensions.common.FixSuggestionInfo)11 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 FixReplacementInfo (com.google.gerrit.extensions.common.FixReplacementInfo)9 Test (org.junit.Test)9 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)8 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)4 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)2