use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method robotCommentsNotSupportedWithoutNoteDb.
@Test
public void robotCommentsNotSupportedWithoutNoteDb() throws Exception {
assume().that(notesMigration.readChanges()).isFalse();
RobotCommentInput in = createRobotCommentInput();
ReviewInput reviewInput = new ReviewInput();
Map<String, List<RobotCommentInput>> robotComments = new HashMap<>();
robotComments.put(in.path, ImmutableList.of(in));
reviewInput.robotComments = robotComments;
reviewInput.message = "comment test";
exception.expect(MethodNotAllowedException.class);
exception.expectMessage("robot comments not supported");
gApi.changes().id(changeId).current().review(reviewInput);
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method createRobotCommentInput.
private static RobotCommentInput createRobotCommentInput(FixSuggestionInfo... fixSuggestionInfos) {
RobotCommentInput in = createRobotCommentInputWithMandatoryFields();
in.url = "http://www.happy-robot.com";
in.properties = new HashMap<>();
in.properties.put("key1", "value1");
in.properties.put("key2", "value2");
in.fixSuggestions = Arrays.asList(fixSuggestionInfos);
return in;
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method specificRobotCommentCanBeRetrieved.
@Test
public void specificRobotCommentCanBeRetrieved() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
RobotCommentInput robotCommentInput = createRobotCommentInput();
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.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method twoConflictingFixesOnSameFileCannotBeApplied.
@Test
public void twoConflictingFixesOnSameFileCannotBeApplied() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
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 = "Some other modified content\n";
FixSuggestionInfo fixSuggestionInfo2 = createFixSuggestionInfo(fixReplacementInfo2);
RobotCommentInput robotCommentInput1 = createRobotCommentInput(fixSuggestionInfo1);
RobotCommentInput robotCommentInput2 = createRobotCommentInput(fixSuggestionInfo2);
addRobotComment(changeId, robotCommentInput1);
addRobotComment(changeId, robotCommentInput2);
List<RobotCommentInfo> robotCommentInfos = getRobotComments();
List<String> fixIds = getFixIds(robotCommentInfos);
gApi.changes().id(changeId).current().applyFix(fixIds.get(0));
exception.expect(ResourceConflictException.class);
exception.expectMessage("merge");
gApi.changes().id(changeId).current().applyFix(fixIds.get(1));
}
use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method robotCommentWithoutOptionalFieldsCanBeAdded.
@Test
public void robotCommentWithoutOptionalFieldsCanBeAdded() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
RobotCommentInput in = createRobotCommentInputWithMandatoryFields();
addRobotComment(changeId, in);
Map<String, List<RobotCommentInfo>> out = gApi.changes().id(changeId).current().robotComments();
assertThat(out).hasSize(1);
RobotCommentInfo comment = Iterables.getOnlyElement(out.get(in.path));
assertRobotComment(comment, in, false);
}
Aggregations