use of com.google.gerrit.extensions.api.changes.NotifyInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method notifyDetailsWorkOnPostReview.
@Test
public void notifyDetailsWorkOnPostReview() throws Exception {
PushOneCommit.Result r = createChange();
TestAccount userToNotify = createAccounts(1, "notify-details-post-review").get(0);
ReviewInput reviewInput = new ReviewInput();
reviewInput.reviewer(user.email, ReviewerState.REVIEWER, true);
reviewInput.notify = NotifyHandling.NONE;
reviewInput.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
sender.clear();
gApi.changes().id(r.getChangeId()).current().review(reviewInput);
assertThat(sender.getMessages()).hasSize(1);
assertThat(sender.getMessages().get(0).rcpt()).containsExactly(userToNotify.emailAddress);
}
use of com.google.gerrit.extensions.api.changes.NotifyInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method notifyDetailsWorkOnPostReviewers.
@Test
public void notifyDetailsWorkOnPostReviewers() throws Exception {
PushOneCommit.Result r = createChange();
TestAccount userToNotify = createAccounts(1, "notify-details-post-reviewers").get(0);
AddReviewerInput addReviewer = new AddReviewerInput();
addReviewer.reviewer = user.email;
addReviewer.notify = NotifyHandling.NONE;
addReviewer.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
sender.clear();
gApi.changes().id(r.getChangeId()).addReviewer(addReviewer);
assertThat(sender.getMessages()).hasSize(1);
assertThat(sender.getMessages().get(0).rcpt()).containsExactly(userToNotify.emailAddress);
}
use of com.google.gerrit.extensions.api.changes.NotifyInfo 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);
}
use of com.google.gerrit.extensions.api.changes.NotifyInfo in project gerrit by GerritCodeReview.
the class ChangeIT method deleteVoteNotifyAccount.
@Test
public void deleteVoteNotifyAccount() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
DeleteVoteInput in = new DeleteVoteInput();
in.label = "Code-Review";
in.notify = NotifyHandling.NONE;
// notify unrelated account as TO
TestAccount user2 = accounts.user2();
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.TO, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyTo(user2);
// notify unrelated account as CC
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.CC, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyCc(user2);
// notify unrelated account as BCC
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.BCC, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyBcc(user2);
}
Aggregations