Search in sources :

Example 31 with RobotCommentInfo

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

the class ChangesRestApiBindingsIT method fixEndpoints.

@Test
public void fixEndpoints() throws Exception {
    String changeId = createChange("Subject", FILENAME, "content").getChangeId();
    RobotCommentInput robotCommentInput = new RobotCommentInput();
    robotCommentInput.robotId = "happyRobot";
    robotCommentInput.robotRunId = "1";
    robotCommentInput.line = 1;
    robotCommentInput.message = "nit: trailing whitespace";
    robotCommentInput.path = FILENAME;
    FixReplacementInfo fixReplacementInfo = new FixReplacementInfo();
    fixReplacementInfo.path = FILENAME;
    fixReplacementInfo.replacement = "some replacement code";
    fixReplacementInfo.range = createRange(1, 1, 1, 2);
    FixSuggestionInfo fixSuggestionInfo = new FixSuggestionInfo();
    fixSuggestionInfo.fixId = "An ID which must be overwritten.";
    fixSuggestionInfo.description = "A description for a suggested fix.";
    fixSuggestionInfo.replacements = ImmutableList.of(fixReplacementInfo);
    robotCommentInput.fixSuggestions = ImmutableList.of(fixSuggestionInfo);
    ReviewInput reviewInput = new ReviewInput();
    reviewInput.robotComments = Collections.singletonMap(robotCommentInput.path, ImmutableList.of(robotCommentInput));
    reviewInput.message = "robot comment test";
    gApi.changes().id(changeId).current().review(reviewInput);
    List<RobotCommentInfo> robotCommentInfos = gApi.changes().id(changeId).current().robotCommentsAsList();
    List<String> fixIds = getFixIds(robotCommentInfos);
    String fixId = Iterables.getOnlyElement(fixIds);
    RestApiCallHelper.execute(adminRestSession, FIX_ENDPOINTS, changeId, "current", fixId);
}
Also used : FixReplacementInfo(com.google.gerrit.extensions.common.FixReplacementInfo) FixSuggestionInfo(com.google.gerrit.extensions.common.FixSuggestionInfo) RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 32 with RobotCommentInfo

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

the class PatchsetOperationsImplTest method robotCommentIsCreatedWithProperty.

@Test
public void robotCommentIsCreatedWithProperty() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newRobotComment().addProperty("key", "value").create();
    RobotCommentInfo comment = getRobotCommentFromServerInCurrentPatchset(changeId, commentUuid);
    assertThat(comment).properties().containsExactly("key", "value");
}
Also used : Change(com.google.gerrit.entities.Change) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 33 with RobotCommentInfo

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

the class PatchsetOperationsImplTest method robotCommentIsCreatedWithUrl.

@Test
public void robotCommentIsCreatedWithUrl() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newRobotComment().url("url").create();
    RobotCommentInfo comment = getRobotCommentFromServerInCurrentPatchset(changeId, commentUuid);
    assertThat(comment).url().isEqualTo("url");
}
Also used : Change(com.google.gerrit.entities.Change) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 34 with RobotCommentInfo

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

the class PatchsetOperationsImplTest method robotCommentIsCreatedWithRobotRunId.

@Test
public void robotCommentIsCreatedWithRobotRunId() throws Exception {
    Change.Id changeId = changeOperations.newChange().create();
    String commentUuid = changeOperations.change(changeId).currentPatchset().newRobotComment().robotId("robot-run-id").create();
    RobotCommentInfo comment = getRobotCommentFromServerInCurrentPatchset(changeId, commentUuid);
    assertThat(comment).robotId().isEqualTo("robot-run-id");
}
Also used : Change(com.google.gerrit.entities.Change) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)34 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)33 Test (org.junit.Test)33 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)18 FixReplacementInfo (com.google.gerrit.extensions.common.FixReplacementInfo)16 FixSuggestionInfo (com.google.gerrit.extensions.common.FixSuggestionInfo)15 Change (com.google.gerrit.entities.Change)9 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)8 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)7 ImmutableList (com.google.common.collect.ImmutableList)6 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)6 RobotCommentInfoSubject.assertThatList (com.google.gerrit.extensions.common.testing.RobotCommentInfoSubject.assertThatList)6 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)6 EditInfo (com.google.gerrit.extensions.common.EditInfo)5 List (java.util.List)5 Collectors.toList (java.util.stream.Collectors.toList)5 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)3 Iterables (com.google.common.collect.Iterables)3 MoreCollectors.onlyElement (com.google.common.collect.MoreCollectors.onlyElement)3