Search in sources :

Example 6 with RobotComment

use of com.google.gerrit.entities.RobotComment in project gerrit by GerritCodeReview.

the class Fixes method parse.

@Override
public FixResource parse(RevisionResource revisionResource, IdString id) throws ResourceNotFoundException {
    String fixId = id.get();
    ChangeNotes changeNotes = revisionResource.getNotes();
    List<RobotComment> robotComments = commentsUtil.robotCommentsByPatchSet(changeNotes, revisionResource.getPatchSet().id());
    for (RobotComment robotComment : robotComments) {
        for (FixSuggestion fixSuggestion : robotComment.fixSuggestions) {
            if (Objects.equals(fixId, fixSuggestion.fixId)) {
                return new FixResource(revisionResource, fixSuggestion.replacements);
            }
        }
    }
    throw new ResourceNotFoundException(id);
}
Also used : FixResource(com.google.gerrit.server.change.FixResource) FixSuggestion(com.google.gerrit.entities.FixSuggestion) RobotComment(com.google.gerrit.entities.RobotComment) IdString(com.google.gerrit.extensions.restapi.IdString) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Example 7 with RobotComment

use of com.google.gerrit.entities.RobotComment in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOfWithRobotComment.

@Test
public void voteOnBehalfOfWithRobotComment() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = user.id().toString();
    in.label("Code-Review", 1);
    RobotCommentInput ci = new RobotCommentInput();
    ci.robotId = "my-robot";
    ci.robotRunId = "abcd1234";
    ci.path = Patch.COMMIT_MSG;
    ci.side = Side.REVISION;
    ci.line = 1;
    ci.message = "message";
    in.robotComments = ImmutableMap.of(ci.path, ImmutableList.of(ci));
    gApi.changes().id(r.getChangeId()).current().review(in);
    ChangeData cd = r.getChange();
    RobotComment c = Iterables.getOnlyElement(commentsUtil.robotCommentsByChange(cd.notes()));
    assertThat(c.message).isEqualTo(ci.message);
    assertThat(c.robotId).isEqualTo(ci.robotId);
    assertThat(c.robotRunId).isEqualTo(ci.robotRunId);
    assertThat(c.author.getId()).isEqualTo(user.id());
    assertThat(c.getRealAuthor().getId()).isEqualTo(admin.id());
}
Also used : RobotComment(com.google.gerrit.entities.RobotComment) RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ChangeData(com.google.gerrit.server.query.change.ChangeData) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

RobotComment (com.google.gerrit.entities.RobotComment)7 Comment (com.google.gerrit.entities.Comment)2 HumanComment (com.google.gerrit.entities.HumanComment)2 IdString (com.google.gerrit.extensions.restapi.IdString)2 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)2 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)2 Map (java.util.Map)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 FixSuggestion (com.google.gerrit.entities.FixSuggestion)1 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1 FixResource (com.google.gerrit.server.change.FixResource)1 RobotCommentResource (com.google.gerrit.server.change.RobotCommentResource)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ObjectReader (org.eclipse.jgit.lib.ObjectReader)1