Search in sources :

Example 1 with NameKey

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);
}
Also used : CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) NameKey(com.google.gerrit.reviewdb.client.Branch.NameKey) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)1 NotifyInfo (com.google.gerrit.extensions.api.changes.NotifyInfo)1 NameKey (com.google.gerrit.reviewdb.client.Branch.NameKey)1 Test (org.junit.Test)1