Search in sources :

Example 6 with RobotCommentInput

use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method twoFixesOnSameFileCanBeApplied.

@Test
public void twoFixesOnSameFileCanBeApplied() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    FixReplacementInfo fixReplacementInfo1 = new FixReplacementInfo();
    fixReplacementInfo1.path = FILE_NAME;
    fixReplacementInfo1.range = createRange(2, 0, 3, 0);
    fixReplacementInfo1.replacement = "First modification\n";
    FixSuggestionInfo fixSuggestionInfo1 = createFixSuggestionInfo(fixReplacementInfo1);
    FixReplacementInfo fixReplacementInfo2 = new FixReplacementInfo();
    fixReplacementInfo2.path = FILE_NAME;
    fixReplacementInfo2.range = createRange(8, 0, 9, 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));
    gApi.changes().id(changeId).current().applyFix(fixIds.get(1));
    Optional<BinaryResult> file = gApi.changes().id(changeId).edit().getFile(FILE_NAME);
    BinaryResultSubject.assertThat(file).value().asString().isEqualTo("First line\nFirst modification\nThird line\nFourth line\nFifth line\nSixth line\n" + "Seventh line\nSome other modified content\nNinth line\nTenth line\n");
}
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) BinaryResult(com.google.gerrit.extensions.restapi.BinaryResult) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with RobotCommentInput

use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method createRobotCommentInputWithMandatoryFields.

private static RobotCommentInput createRobotCommentInputWithMandatoryFields() {
    RobotCommentInput in = new RobotCommentInput();
    in.robotId = "happyRobot";
    in.robotRunId = "1";
    in.line = 1;
    in.message = "nit: trailing whitespace";
    in.path = FILE_NAME;
    return in;
}
Also used : RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)

Example 8 with RobotCommentInput

use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method addedRobotCommentsCanBeRetrieved.

@Test
public void addedRobotCommentsCanBeRetrieved() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    RobotCommentInput in = createRobotCommentInput();
    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)

Example 9 with RobotCommentInput

use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method robotCommentsCanBeRetrievedAsList.

@Test
public void robotCommentsCanBeRetrievedAsList() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    RobotCommentInput robotCommentInput = createRobotCommentInput();
    addRobotComment(changeId, robotCommentInput);
    List<RobotCommentInfo> robotCommentInfos = gApi.changes().id(changeId).current().robotCommentsAsList();
    assertThat(robotCommentInfos).hasSize(1);
    RobotCommentInfo robotCommentInfo = Iterables.getOnlyElement(robotCommentInfos);
    assertRobotComment(robotCommentInfo, 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 10 with RobotCommentInput

use of com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput in project gerrit by GerritCodeReview.

the class RobotCommentsIT method addedRobotCommentsCanBeRetrievedByChange.

@Test
public void addedRobotCommentsCanBeRetrievedByChange() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    RobotCommentInput in = createRobotCommentInput();
    addRobotComment(changeId, in);
    pushFactory.create(db, admin.getIdent(), testRepo, changeId).to("refs/for/master");
    RobotCommentInput in2 = createRobotCommentInput();
    addRobotComment(changeId, in2);
    Map<String, List<RobotCommentInfo>> out = gApi.changes().id(changeId).robotComments();
    assertThat(out).hasSize(1);
    assertThat(out.get(in.path)).hasSize(2);
    RobotCommentInfo comment1 = out.get(in.path).get(0);
    assertRobotComment(comment1, in, false);
    RobotCommentInfo comment2 = out.get(in.path).get(1);
    assertRobotComment(comment2, in2, 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