use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickMergeUsingNonExistentParent.
@Test
public void cherryPickMergeUsingNonExistentParent() throws Exception {
String parent1FileName = "a.txt";
String parent2FileName = "b.txt";
PushOneCommit.Result mergeChangeResult = createCherryPickableMerge(parent1FileName, parent2FileName);
String cherryPickBranchName = "branch_for_cherry_pick";
createBranch(BranchNameKey.create(project, cherryPickBranchName));
CherryPickInput cherryPickInput = new CherryPickInput();
cherryPickInput.destination = cherryPickBranchName;
cherryPickInput.message = "Cherry-pick a merge commit to another branch";
cherryPickInput.parent = 3;
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(mergeChangeResult.getChangeId()).current().cherryPick(cherryPickInput));
assertThat(thrown).hasMessageThat().contains("Cherry Pick: Parent 3 does not exist. Please specify a parent in range [1, 2].");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickToExistingMergedChange.
@Test
public void cherryPickToExistingMergedChange() throws Exception {
PushOneCommit.Result r1 = pushFactory.create(admin.newIdent(), testRepo, SUBJECT, FILE_NAME, "a").to("refs/for/master");
BranchInput bin = new BranchInput();
bin.revision = r1.getCommit().getParent(0).name();
gApi.projects().name(project.get()).branch("foo").create(bin);
PushOneCommit.Result r2 = pushFactory.create(admin.newIdent(), testRepo, SUBJECT, FILE_NAME, "b", r1.getChangeId()).to("refs/for/foo");
String t2 = project.get() + "~foo~" + r2.getChangeId();
gApi.changes().id(t2).current().review(ReviewInput.approve());
gApi.changes().id(t2).current().submit();
CherryPickInput in = new CherryPickInput();
in.destination = "foo";
in.message = r1.getCommit().getFullMessage();
in.allowConflicts = true;
in.allowEmpty = true;
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(t2).current().cherryPick(in));
assertThat(thrown).hasMessageThat().isEqualTo(String.format("Cherry-pick with Change-Id %s could not update the existing change %d in " + "destination branch refs/heads/foo of project %s, because " + "the change was closed (MERGED)", r1.getChangeId(), info(t2)._number, project.get()));
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class ChangeEditIT method updateCommitMessageByEditingMagicCommitMsgFileWithoutContent.
@Test
public void updateCommitMessageByEditingMagicCommitMsgFileWithoutContent() throws Exception {
createEmptyEditFor(changeId);
BadRequestException ex = assertThrows(BadRequestException.class, () -> gApi.changes().id(changeId).edit().modifyFile(Patch.COMMIT_MSG, (RawInput) null));
assertThat(ex).hasMessageThat().isEqualTo("either content or binary_content is required");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class RobotCommentsIT method rangeOfFixReplacementIsMandatory.
@Test
public void rangeOfFixReplacementIsMandatory() {
fixReplacementInfo.range = null;
BadRequestException thrown = assertThrows(BadRequestException.class, () -> testCommentHelper.addRobotComment(changeId, withFixRobotCommentInput));
assertThat(thrown).hasMessageThat().contains(String.format("A range must be given 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 ParameterParserTest method rejectDuplicateMethod.
@Test
public void rejectDuplicateMethod() {
FakeHttpServletRequest req = new FakeHttpServletRequest();
req.setQueryString("$m=PUT&$m=DELETE");
BadRequestException bad = assertThrows(BadRequestException.class, () -> ParameterParser.getQueryParams(req));
assertThat(bad).hasMessageThat().isEqualTo("duplicate $m");
}
Aggregations