use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class CommentsIT method cannotCreateCommentWithInvalidInReplyTo.
@Test
public void cannotCreateCommentWithInvalidInReplyTo() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
CommentInput comment = CommentsUtil.newComment(COMMIT_MSG, "comment 1 reply");
comment.inReplyTo = "invalid";
BadRequestException exception = assertThrows(BadRequestException.class, () -> CommentsUtil.addComments(gApi, changeId, comment));
assertThat(exception.getMessage()).contains(String.format("%s not found", comment.inReplyTo));
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class CommentsIT method putDraft_invalidInReplyTo.
@Test
public void putDraft_invalidInReplyTo() throws Exception {
Change.Id changeId = changeOperations.newChange().create();
DraftInput draft = CommentsUtil.newDraft(COMMIT_MSG, Side.REVISION, 0, "foo");
draft.inReplyTo = "invalid";
BadRequestException exception = assertThrows(BadRequestException.class, () -> addDraft(changeId, draft));
assertThat(exception.getMessage()).contains(String.format("%s not found", draft.inReplyTo));
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class CommentsIT method patchsetLevelDraftCommentCantHaveSide.
@Test
public void patchsetLevelDraftCommentCantHaveSide() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
String revId = r.getCommit().getName();
DraftInput comment = CommentsUtil.newDraftWithOnlyMandatoryFields(PATCHSET_LEVEL, "comment");
comment.side = Side.REVISION;
BadRequestException ex = assertThrows(BadRequestException.class, () -> addDraft(changeId, revId, comment));
assertThat(ex.getMessage()).contains("range");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class DeleteBranchesIT method emptyBranchList.
@Test
public void emptyBranchList() throws Exception {
DeleteBranchesInput input = new DeleteBranchesInput();
input.branches = Lists.newArrayList();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> project().deleteBranches(input));
assertThat(thrown).hasMessageThat().contains("branches must be specified");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotCreateLabelWithoutName.
@Test
public void cannotCreateLabelWithoutName() throws Exception {
BatchLabelInput input = new BatchLabelInput();
input.create = ImmutableList.of(new LabelDefinitionInput());
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).labels(input));
assertThat(thrown).hasMessageThat().contains("label name is required for new label");
}
Aggregations