use of com.google.gerrit.reviewdb.client.Branch.NameKey in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickNotify.
@Test
public void cherryPickNotify() throws Exception {
createBranch(new NameKey(project, "branch-1"));
createBranch(new NameKey(project, "branch-2"));
createBranch(new NameKey(project, "branch-3"));
// Creates a change for 'admin'.
PushOneCommit.Result result = createChange();
String changeId = project.get() + "~master~" + result.getChangeId();
// 'user' cherry-picks the change to a new branch, the source change's author/committer('admin')
// will be added as a reviewer of the newly created change.
setApiUser(user);
CherryPickInput input = new CherryPickInput();
input.message = "it goes to a new branch";
// Enable the notification. 'admin' as a reviewer should be notified.
input.destination = "branch-1";
input.notify = NotifyHandling.ALL;
sender.clear();
gApi.changes().id(changeId).current().cherryPick(input);
assertNotifyCc(admin);
// Disable the notification. 'admin' as a reviewer should not be notified any more.
input.destination = "branch-2";
input.notify = NotifyHandling.NONE;
sender.clear();
gApi.changes().id(changeId).current().cherryPick(input);
assertThat(sender.getMessages()).hasSize(0);
// Disable the notification. The user provided in the 'notifyDetails' should still be notified.
TestAccount userToNotify = accounts.user2();
input.destination = "branch-3";
input.notify = NotifyHandling.NONE;
input.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
sender.clear();
gApi.changes().id(changeId).current().cherryPick(input);
assertNotifyTo(userToNotify);
}
Aggregations