use of com.google.gerrit.extensions.common.RobotCommentInfo in project gerrit by GerritCodeReview.
the class RobotCommentsIT method fixOnPreviousPatchSetWithExistingChangeEditCanBeApplied.
@Test
public void fixOnPreviousPatchSetWithExistingChangeEditCanBeApplied() throws Exception {
// Create an empty change edit.
gApi.changes().id(changeId).edit().create();
fixReplacementInfo.path = FILE_NAME;
fixReplacementInfo.replacement = "Modified content";
fixReplacementInfo.range = createRange(3, 1, 3, 3);
testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput);
List<RobotCommentInfo> robotCommentInfos = getRobotComments();
// Remember patch set and add another one.
String previousRevision = gApi.changes().id(changeId).get().currentRevision;
amendChange(changeId);
List<String> fixIds = getFixIds(robotCommentInfos);
String fixId = Iterables.getOnlyElement(fixIds);
EditInfo editInfo = gApi.changes().id(changeId).revision(previousRevision).applyFix(fixId);
Optional<BinaryResult> file = gApi.changes().id(changeId).edit().getFile(FILE_NAME);
BinaryResultSubject.assertThat(file).value().asString().isEqualTo("First line\nSecond line\nTModified contentrd line\nFourth line\nFifth line\n" + "Sixth line\nSeventh line\nEighth line\nNinth line\nTenth line\n");
assertThat(editInfo).baseRevision().isEqualTo(previousRevision);
}
use of com.google.gerrit.extensions.common.RobotCommentInfo in project gerrit by GerritCodeReview.
the class RobotCommentsIT method rangesOfFixReplacementsOfDifferentFixSuggestionsForSameFileMayOverlap.
@Test
public void rangesOfFixReplacementsOfDifferentFixSuggestionsForSameFileMayOverlap() throws Exception {
FixReplacementInfo fixReplacementInfo1 = new FixReplacementInfo();
fixReplacementInfo1.path = FILE_NAME;
fixReplacementInfo1.range = createRange(2, 0, 3, 1);
fixReplacementInfo1.replacement = "First modification\n";
FixSuggestionInfo fixSuggestionInfo1 = createFixSuggestionInfo(fixReplacementInfo1);
FixReplacementInfo fixReplacementInfo2 = new FixReplacementInfo();
fixReplacementInfo2.path = FILE_NAME;
fixReplacementInfo2.range = createRange(3, 0, 4, 0);
fixReplacementInfo2.replacement = "Second modification\n";
FixSuggestionInfo fixSuggestionInfo2 = createFixSuggestionInfo(fixReplacementInfo2);
withFixRobotCommentInput.fixSuggestions = ImmutableList.of(fixSuggestionInfo1, fixSuggestionInfo2);
testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput);
List<RobotCommentInfo> robotCommentInfos = getRobotComments();
assertThatList(robotCommentInfos).onlyElement().fixSuggestions().hasSize(2);
}
use of com.google.gerrit.extensions.common.RobotCommentInfo in project gerrit by GerritCodeReview.
the class RobotCommentsIT method specificRobotCommentCanBeRetrieved.
@Test
public void specificRobotCommentCanBeRetrieved() throws Exception {
RobotCommentInput robotCommentInput = TestCommentHelper.createRobotCommentInput(FILE_NAME);
testCommentHelper.addRobotComment(changeId, robotCommentInput);
List<RobotCommentInfo> robotCommentInfos = getRobotComments();
RobotCommentInfo robotCommentInfo = Iterables.getOnlyElement(robotCommentInfos);
RobotCommentInfo specificRobotCommentInfo = gApi.changes().id(changeId).current().robotComment(robotCommentInfo.id).get();
assertRobotComment(specificRobotCommentInfo, robotCommentInput);
}
use of com.google.gerrit.extensions.common.RobotCommentInfo in project gerrit by GerritCodeReview.
the class RobotCommentsIT method fixReplacementsDoNotNeedToBeOrderedAccordingToRange.
@Test
public void fixReplacementsDoNotNeedToBeOrderedAccordingToRange() throws Exception {
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 = "Second modification\n";
FixReplacementInfo fixReplacementInfo3 = new FixReplacementInfo();
fixReplacementInfo3.path = FILE_NAME;
fixReplacementInfo3.range = createRange(4, 0, 5, 0);
fixReplacementInfo3.replacement = "Third modification\n";
FixSuggestionInfo fixSuggestionInfo = createFixSuggestionInfo(fixReplacementInfo2, fixReplacementInfo1, fixReplacementInfo3);
withFixRobotCommentInput.fixSuggestions = ImmutableList.of(fixSuggestionInfo);
testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput);
List<RobotCommentInfo> robotCommentInfos = getRobotComments();
assertThatList(robotCommentInfos).onlyElement().onlyFixSuggestion().replacements().hasSize(3);
}
use of com.google.gerrit.extensions.common.RobotCommentInfo in project gerrit by GerritCodeReview.
the class RobotCommentsIT method canCreateRobotCommentWithRobotCommentAsParent.
@Test
public void canCreateRobotCommentWithRobotCommentAsParent() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
String parentRobotCommentUuid = changeOperations.change(changeId).currentPatchset().newRobotComment().create();
ReviewInput.RobotCommentInput robotCommentInput = TestCommentHelper.createRobotCommentInputWithMandatoryFields(COMMIT_MSG);
robotCommentInput.message = "comment reply";
robotCommentInput.inReplyTo = parentRobotCommentUuid;
testCommentHelper.addRobotComment(changeId, robotCommentInput);
RobotCommentInfo resultComment = Iterables.getOnlyElement(gApi.changes().id(changeId.get()).current().robotCommentsAsList().stream().filter(c -> c.message.equals("comment reply")).collect(toImmutableSet()));
assertThat(resultComment.inReplyTo).isEqualTo(parentRobotCommentUuid);
}
Aggregations