use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method fixSuggestionCannotPointToPatchsetLevel.
@Test
public void fixSuggestionCannotPointToPatchsetLevel() throws Exception {
RobotCommentInput input = TestCommentHelper.createRobotCommentInput(FILE_NAME);
FixReplacementInfo brokenFixReplacement = createFixReplacementInfo();
brokenFixReplacement.path = PATCHSET_LEVEL;
input.fixSuggestions = ImmutableList.of(createFixSuggestionInfo(brokenFixReplacement));
BadRequestException ex = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, input));
assertThat(ex.getMessage()).contains("file path must not be " + PATCHSET_LEVEL);
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method patchsetLevelRobotCommentCantHaveSide.
@Test
public void patchsetLevelRobotCommentCantHaveSide() throws Exception {
RobotCommentInput input = TestCommentHelper.createRobotCommentInput(PATCHSET_LEVEL);
input.side = Side.REVISION;
BadRequestException ex = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, input));
assertThat(ex.getMessage()).contains("side");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method replacementStringOfFixReplacementIsMandatory.
@Test
public void replacementStringOfFixReplacementIsMandatory() {
fixReplacementInfo.replacement = null;
BadRequestException thrown = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput));
assertThat(thrown).hasMessageThat().contains(String.format("A content for replacement must be " + "indicated for the replacement of the robot comment on %s", withFixRobotCommentInput.path));
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method patchsetLevelRobotCommentCantHaveLine.
@Test
public void patchsetLevelRobotCommentCantHaveLine() throws Exception {
RobotCommentInput input = TestCommentHelper.createRobotCommentInput(PATCHSET_LEVEL);
input.line = 1;
BadRequestException ex = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, input));
assertThat(ex.getMessage()).contains("line");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method fixReplacementsAreMandatory.
@Test
public void fixReplacementsAreMandatory() {
fixSuggestionInfo.replacements = Collections.emptyList();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput));
assertThat(thrown).hasMessageThat().contains(String.format("At least one replacement is required" + " for the suggested fix of the robot comment on %s", withFixRobotCommentInput.path));
}
Aggregations