Test cherry-pick to a non-existing branch Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I050c60945f9f1e9fff19ff283c34a36ca3df2367
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java index ca444c4..b9821d4 100644 --- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java +++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -87,6 +87,7 @@ import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSetApproval; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.restapi.change.GetRevisionActions; @@ -909,6 +910,24 @@ } @Test + public void cherryPickToNonExistingBranch() throws Exception { + PushOneCommit.Result result = createChange(); + + CherryPickInput input = new CherryPickInput(); + input.message = "foo bar"; + input.destination = "non-existing"; + // TODO(ekempin): This should rather result in an UnprocessableEntityException. + BadRequestException thrown = + assertThrows( + BadRequestException.class, + () -> gApi.changes().id(result.getChangeId()).current().cherryPick(input)); + assertThat(thrown) + .hasMessageThat() + .isEqualTo( + String.format("Branch %s does not exist.", RefNames.REFS_HEADS + input.destination)); + } + + @Test public void cherryPickToNonExistingBaseCommit() throws Exception { createBranch(new Branch.NameKey(project, "foo")); PushOneCommit.Result result = createChange();