Search in sources :

Example 1 with RobotCommentInput

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);
}
Also used : HashMap(java.util.HashMap) RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) RobotCommentInfoSubject.assertThatList(com.google.gerrit.extensions.common.RobotCommentInfoSubject.assertThatList) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with RobotCommentInput

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;
}
Also used : RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)

Example 3 with RobotCommentInput

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);
}
Also used : RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with 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));
}
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) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with RobotCommentInput

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);
}
Also used : RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) RobotCommentInfoSubject.assertThatList(com.google.gerrit.extensions.common.RobotCommentInfoSubject.assertThatList) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) RobotCommentInfo(com.google.gerrit.extensions.common.RobotCommentInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)13 Test (org.junit.Test)10 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 RobotCommentInfo (com.google.gerrit.extensions.common.RobotCommentInfo)7 List (java.util.List)6 Collectors.toList (java.util.stream.Collectors.toList)6 ImmutableList (com.google.common.collect.ImmutableList)5 RobotCommentInfoSubject.assertThatList (com.google.gerrit.extensions.common.RobotCommentInfoSubject.assertThatList)4 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 MoreObjects (com.google.common.base.MoreObjects)1 FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 ThrowableSubject (com.google.common.truth.ThrowableSubject)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 TruthJUnit.assume (com.google.common.truth.TruthJUnit.assume)1