use of com.google.gerrit.extensions.api.changes.ReviewerResult in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addOverlappingGroups.
@Test
public void addOverlappingGroups() throws Exception {
String emailPrefix = "addOverlappingGroups-";
TestAccount user1 = accountCreator.create(name("user1"), emailPrefix + "user1@example.com", "User1", null);
TestAccount user2 = accountCreator.create(name("user2"), emailPrefix + "user2@example.com", "User2", null);
TestAccount user3 = accountCreator.create(name("user3"), emailPrefix + "user3@example.com", "User3", null);
String group1 = groupOperations.newGroup().name("group1").create().get();
String group2 = groupOperations.newGroup().name("group2").create().get();
gApi.groups().id(group1).addMembers(user1.username(), user2.username());
gApi.groups().id(group2).addMembers(user2.username(), user3.username());
PushOneCommit.Result r = createChange();
ReviewInput input = ReviewInput.approve().reviewer(group1).reviewer(group2);
ReviewResult result = review(r.getChangeId(), r.getCommit().name(), input);
assertThat(result.reviewers).isNotNull();
assertThat(result.reviewers).hasSize(2);
ReviewerResult reviewerResult = result.reviewers.get(group1);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.reviewers).hasSize(2);
reviewerResult = result.reviewers.get(group2);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.reviewers).hasSize(1);
// Repeat the above for CCs
r = createChange();
input = ReviewInput.approve().reviewer(group1, CC, false).reviewer(group2, CC, false);
result = review(r.getChangeId(), r.getCommit().name(), input);
assertThat(result.reviewers).isNotNull();
assertThat(result.reviewers).hasSize(2);
reviewerResult = result.reviewers.get(group1);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.ccs).hasSize(2);
reviewerResult = result.reviewers.get(group2);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.ccs).hasSize(1);
// Repeat again with one group REVIEWER, the other CC. The overlapping
// member should end up as a REVIEWER.
r = createChange();
input = ReviewInput.approve().reviewer(group1, REVIEWER, false).reviewer(group2, CC, false);
result = review(r.getChangeId(), r.getCommit().name(), input);
assertThat(result.reviewers).isNotNull();
assertThat(result.reviewers).hasSize(2);
reviewerResult = result.reviewers.get(group1);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.reviewers).hasSize(2);
reviewerResult = result.reviewers.get(group2);
assertThat(reviewerResult.error).isNull();
assertThat(reviewerResult.reviewers).isNull();
assertThat(reviewerResult.ccs).hasSize(1);
}
use of com.google.gerrit.extensions.api.changes.ReviewerResult in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addDuplicateReviewers.
@Test
public void addDuplicateReviewers() throws Exception {
PushOneCommit.Result r = createChange();
ReviewInput input = ReviewInput.approve().reviewer(user.email()).reviewer(user.email());
ReviewResult result = review(r.getChangeId(), r.getCommit().name(), input);
assertThat(result.reviewers).isNotNull();
assertThat(result.reviewers).hasSize(1);
ReviewerResult reviewerResult = result.reviewers.get(user.email());
assertThat(reviewerResult).isNotNull();
assertThat(reviewerResult.confirm).isNull();
assertThat(reviewerResult.error).isNull();
}
use of com.google.gerrit.extensions.api.changes.ReviewerResult in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method rejectWhenFeatureIsDisabled.
@Test
public void rejectWhenFeatureIsDisabled() throws Exception {
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.FALSE;
gApi.projects().name(project.get()).config(conf);
PushOneCommit.Result r = createChange();
ReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer("Foo Bar <foo.bar@gerritcodereview.com>");
assertThat(result.error).isEqualTo("Account 'Foo Bar <foo.bar@gerritcodereview.com>' not found\n" + "Foo Bar <foo.bar@gerritcodereview.com> does not identify a registered user or" + " group");
assertThat(result.reviewers).isNull();
}
use of com.google.gerrit.extensions.api.changes.ReviewerResult in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method rejectMissingEmail.
@Test
public void rejectMissingEmail() throws Exception {
PushOneCommit.Result r = createChange();
ReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer("");
assertThat(result.error).isEqualTo(" is not a valid user identifier");
assertThat(result.reviewers).isNull();
}
Aggregations