commit 716dc5a3bfa2b21bfe590159d926b9949291e199 Author: Alice Kober-Sotzek Date: Thu Oct 1 15:48:43 2020 +0200 Prove that the unresolved flag for robot comments is ignored As the added test shows, robot comments can't be set to unresolved. They are always created with the default value, which is false (= null internally). This behavior can also be explained with the existing code. In PostReview.Op#createRobotCommentFromInput (see [1]), the value of the unresolved flag isn't copied from the input. Hence, all existing robot comments were created without an 'unresolved' value being present (false=null). [1] https://gerrit.googlesource.com/gerrit/+/6d90ff931199fb3bf3d65b876d3dd9efc27bf2a0/java/com/google/gerrit/server/restapi/change/PostReview.java#1103 Change-Id: Ied977dbacfed1890661d66e233f5b59e37048497 diff --git a/java/com/google/gerrit/extensions/common/testing/RobotCommentInfoSubject.java b/java/com/google/gerrit/extensions/common/testing/RobotCommentInfoSubject.java index 5176145..a99b859 100644 --- a/java/com/google/gerrit/extensions/common/testing/RobotCommentInfoSubject.java +++ b/java/com/google/gerrit/extensions/common/testing/RobotCommentInfoSubject.java @@ -17,6 +17,7 @@ package com.google.gerrit.extensions.common.testing; import static com.google.common.truth.Truth.assertAbout; import static com.google.gerrit.truth.ListSubject.elements; +import com.google.common.truth.BooleanSubject; import com.google.common.truth.FailureMetadata; import com.google.common.truth.MapSubject; import com.google.common.truth.StringSubject; @@ -80,6 +81,11 @@ public class RobotCommentInfoSubject extends Subject { return check("property").that(robotCommentInfo.properties); } + public BooleanSubject unresolved() { + isNotNull(); + return check("unresolved").that(robotCommentInfo.unresolved); + } + public FixSuggestionInfoSubject onlyFixSuggestion() { return fixSuggestions().onlyElement(); } diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java index 1ad952c..4829086 100644 --- a/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java +++ b/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java @@ -440,6 +440,17 @@ public class RobotCommentsIT extends AbstractDaemonTest { } @Test + public void robotCommentsAreAlwaysResolved() throws Exception { + RobotCommentInput robotCommentInput = TestCommentHelper.createRobotCommentInput(FILE_NAME); + robotCommentInput.unresolved = true; + testCommentHelper.addRobotComment(changeId, robotCommentInput); + + List robotCommentInfos = getRobotComments(); + // The unresolved flag is false even though we explicitly set it to true! + assertThatList(robotCommentInfos).onlyElement().unresolved().isFalse(); + } + + @Test public void addedFixSuggestionCanBeRetrieved() throws Exception { testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput); List robotCommentInfos = getRobotComments();