use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method notificationsForAddedWorkInProgressReviewers.
@Test
public void notificationsForAddedWorkInProgressReviewers() throws Exception {
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
ReviewInput batchIn = new ReviewInput();
batchIn.reviewers = ImmutableList.of(in);
// Added reviewers not notified by default.
PushOneCommit.Result r = createWorkInProgressChange();
gApi.changes().id(r.getChangeId()).addReviewer(in);
assertThat(sender.getMessages()).isEmpty();
// Default notification handling can be overridden.
r = createWorkInProgressChange();
in.notify = NotifyHandling.OWNER_REVIEWERS;
gApi.changes().id(r.getChangeId()).addReviewer(in);
assertThat(sender.getMessages()).hasSize(1);
sender.clear();
// Reviewers added via PostReview also not notified by default.
// In this case, the child ReviewerInput has a notify=OWNER_REVIEWERS
// that should be ignored.
r = createWorkInProgressChange();
gApi.changes().id(r.getChangeId()).current().review(batchIn);
assertThat(sender.getMessages()).isEmpty();
// Top-level notify property can force notifications when adding reviewer
// via PostReview.
r = createWorkInProgressChange();
batchIn.notify = NotifyHandling.OWNER_REVIEWERS;
gApi.changes().id(r.getChangeId()).current().review(batchIn);
assertThat(sender.getMessages()).hasSize(1);
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method deleteGroupFromReviewersFails.
@Test
public void deleteGroupFromReviewersFails() throws Exception {
PushOneCommit.Result r = createChange();
// create a group named "kobe" with one user: lee
String myGroupUserEmail = "lee@example.com";
String myGroupUserFullname = "lee";
accountOperations.newAccount().username("lee").preferredEmail(myGroupUserEmail).fullname(myGroupUserFullname).create();
String groupName = "kobe";
String testGroup = groupOperations.newGroup().name(groupName).create().get();
GroupApi groupApi = gApi.groups().id(testGroup);
groupApi.description("test group");
groupApi.addMembers(myGroupUserFullname);
// add the user as reviewer.
gApi.changes().id(r.getChangeId()).addReviewer(myGroupUserFullname);
// fail to remove that user via group.
ReviewResult reviewResult = gApi.changes().id(r.getChangeId()).current().review(ReviewInput.create().reviewer(testGroup, REMOVED, /* confirmed= */
true));
assertThat(reviewResult.error).isEqualTo("error adding reviewer");
ReviewerInput in = new ReviewerInput();
in.reviewer = testGroup;
in.state = REMOVED;
ReviewerResult reviewerResult = gApi.changes().id(r.getChangeId()).addReviewer(in);
assertThat(reviewerResult.error).isEqualTo(MessageFormat.format(ChangeMessages.get().groupRemovalIsNotAllowed, groupName));
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method emailNotificationForFileLevelComment.
@Test
public void emailNotificationForFileLevelComment() throws Exception {
String changeId = createChange().getChangeId();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
gApi.changes().id(changeId).addReviewer(in);
sender.clear();
ReviewInput review = new ReviewInput();
ReviewInput.CommentInput comment = new ReviewInput.CommentInput();
comment.path = PushOneCommit.FILE_NAME;
comment.side = Side.REVISION;
comment.message = "comment 1";
review.comments = new HashMap<>();
review.comments.put(comment.path, Lists.newArrayList(comment));
gApi.changes().id(changeId).current().review(review);
assertThat(sender.getMessages()).hasSize(1);
Message m = sender.getMessages().get(0);
assertThat(m.rcpt()).containsExactly(user.getNameEmail());
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method ignore.
@Test
public void ignore() throws Exception {
String email = "user2@example.com";
String fullname = "User2";
accountOperations.newAccount().username("user2").preferredEmail(email).fullname(fullname).create();
PushOneCommit.Result r = createChange();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
gApi.changes().id(r.getChangeId()).addReviewer(in);
in = new ReviewerInput();
in.reviewer = email;
gApi.changes().id(r.getChangeId()).addReviewer(in);
requestScopeOperations.setApiUser(user.id());
gApi.changes().id(r.getChangeId()).ignore(true);
assertThat(gApi.changes().id(r.getChangeId()).ignored()).isTrue();
// New patch set notification is not sent to users ignoring the change
sender.clear();
requestScopeOperations.setApiUser(admin.id());
amendChange(r.getChangeId());
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Address address = Address.create(fullname, email);
assertThat(messages.get(0).rcpt()).containsExactly(address);
// Review notification is not sent to users ignoring the change
sender.clear();
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(address);
// Abandoned notification is not sent to users ignoring the change
sender.clear();
gApi.changes().id(r.getChangeId()).abandon();
messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(address);
requestScopeOperations.setApiUser(user.id());
gApi.changes().id(r.getChangeId()).ignore(false);
assertThat(gApi.changes().id(r.getChangeId()).ignored()).isFalse();
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method addReviewerThatIsInactiveByUsername.
@Test
public void addReviewerThatIsInactiveByUsername() throws Exception {
PushOneCommit.Result result = createChange();
String username = name("new-user");
Account.Id id = accountOperations.newAccount().username(username).inactive().create();
ReviewerInput in = new ReviewerInput();
in.reviewer = username;
ReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
assertThat(r.input).isEqualTo(in.reviewer);
assertThat(r.error).isNull();
assertThat(r.reviewers).hasSize(1);
ReviewerInfo reviewer = r.reviewers.get(0);
assertThat(reviewer._accountId).isEqualTo(id.get());
assertThat(reviewer.username).isEqualTo(username);
}
Aggregations