use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class AssigneeIT method assigneeAddedAsReviewer.
@Test
public void assigneeAddedAsReviewer() throws Exception {
ReviewerState state;
// CC) CC is stored as REVIEWER
if (notesMigration.readChanges()) {
state = ReviewerState.CC;
} else {
state = ReviewerState.REVIEWER;
}
PushOneCommit.Result r = createChange();
Iterable<AccountInfo> reviewers = getReviewers(r, state);
assertThat(reviewers).isNull();
assertThat(setAssignee(r, user.email)._accountId).isEqualTo(user.getId().get());
reviewers = getReviewers(r, state);
assertThat(reviewers).hasSize(1);
AccountInfo reviewer = Iterables.getFirst(reviewers, null);
assertThat(reviewer._accountId).isEqualTo(user.getId().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeInfo method reviewers.
public final Map<ReviewerState, List<AccountInfo>> reviewers() {
NativeMap<JsArray<AccountInfo>> reviewers = _reviewers();
Map<ReviewerState, List<AccountInfo>> result = new HashMap<>();
for (String k : reviewers.keySet()) {
ReviewerState state = ReviewerState.valueOf(k.toUpperCase());
List<AccountInfo> accounts = result.get(state);
if (accounts == null) {
accounts = new ArrayList<>();
result.put(state, accounts);
}
accounts.addAll(Natives.asList(reviewers.get(k)));
}
return result;
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class PostReviewers method prepareApplication.
public Addition prepareApplication(ChangeResource rsrc, AddReviewerInput input, boolean allowGroup) throws OrmException, IOException, PermissionBackendException {
String reviewer = input.reviewer;
ReviewerState state = input.state();
NotifyHandling notify = input.notify;
ListMultimap<RecipientType, Account.Id> accountsToNotify = null;
try {
accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
} catch (BadRequestException e) {
return fail(reviewer, e.getMessage());
}
boolean confirmed = input.confirmed();
boolean allowByEmail = projectCache.checkedGet(rsrc.getProject()).isEnableReviewerByEmail();
Addition byAccountId = addByAccountId(reviewer, rsrc, state, notify, accountsToNotify, allowGroup, allowByEmail);
if (byAccountId != null) {
return byAccountId;
}
Addition wholeGroup = addWholeGroup(reviewer, rsrc, state, notify, accountsToNotify, confirmed, allowGroup, allowByEmail);
if (wholeGroup != null) {
return wholeGroup;
}
return addByEmail(reviewer, rsrc, state, notify, accountsToNotify);
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeJson method reviewerMap.
private Map<ReviewerState, Collection<AccountInfo>> reviewerMap(ReviewerSet reviewers, ReviewerByEmailSet reviewersByEmail, boolean includeRemoved) {
Map<ReviewerState, Collection<AccountInfo>> reviewerMap = new HashMap<>();
for (ReviewerStateInternal state : ReviewerStateInternal.values()) {
if (!includeRemoved && state == ReviewerStateInternal.REMOVED) {
continue;
}
Collection<AccountInfo> reviewersByState = toAccountInfo(reviewers.byState(state));
reviewersByState.addAll(toAccountInfoByEmail(reviewersByEmail.byState(state)));
if (!reviewersByState.isEmpty()) {
reviewerMap.put(state.asReviewerState(), reviewersByState);
}
}
return reviewerMap;
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class PostReviewIT method commentingMakesUserCC.
@Test
public void commentingMakesUserCC() throws Exception {
// Admin owns the change
PushOneCommit.Result r = createChange();
// User adds themselves and changes state
requestScopeOperations.setApiUser(user.id());
ReviewInput input = new ReviewInput().message("Foo bar!");
gApi.changes().id(r.getChangeId()).current().review(input);
Map<ReviewerState, Collection<AccountInfo>> reviewers = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers).hasSize(1);
AccountInfo reviewer = Iterables.getOnlyElement(reviewers.get(ReviewerState.CC));
assertThat(reviewer._accountId).isEqualTo(user.id().get());
}
Aggregations