use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class PostReviewIT method reviewerToCc.
@Test
public void reviewerToCc() throws Exception {
// Admin owns the change
PushOneCommit.Result r = createChange();
// User adds themselves and changes state
requestScopeOperations.setApiUser(user.id());
ReviewInput input = new ReviewInput().reviewer(user.id().toString());
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.REVIEWER));
assertThat(reviewer._accountId).isEqualTo(user.id().get());
// Reviewer -> CC
ReviewInput input2 = new ReviewInput().reviewer(user.id().toString(), ReviewerState.CC, false);
gApi.changes().id(r.getChangeId()).current().review(input2);
Map<ReviewerState, Collection<AccountInfo>> reviewers2 = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers2).hasSize(1);
AccountInfo reviewer2 = Iterables.getOnlyElement(reviewers2.get(ReviewerState.CC));
assertThat(reviewer2._accountId).isEqualTo(user.id().get());
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithCcByEmail.
@Test
public void pushForMasterWithCcByEmail() throws Exception {
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
gApi.projects().name(project.get()).config(conf);
PushOneCommit.Result r = pushTo("refs/for/master%cc=non.existing.1@example.com,cc=non.existing.2@example.com");
r.assertOkStatus();
ChangeInfo ci = get(r.getChangeId(), DETAILED_LABELS);
ImmutableList<AccountInfo> ccs = firstNonNull(ci.reviewers.get(ReviewerState.CC), ImmutableList.<AccountInfo>of()).stream().sorted(comparing((AccountInfo a) -> a.email)).collect(toImmutableList());
assertThat(ccs).hasSize(2);
assertThat(ccs.get(0).email).isEqualTo("non.existing.1@example.com");
assertThat(ccs.get(0)._accountId).isNull();
assertThat(ccs.get(1).email).isEqualTo("non.existing.2@example.com");
assertThat(ccs.get(1)._accountId).isNull();
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithReviewerByEmail.
@Test
public void pushForMasterWithReviewerByEmail() throws Exception {
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
gApi.projects().name(project.get()).config(conf);
PushOneCommit.Result r = pushTo("refs/for/master%r=non.existing.1@example.com,r=non.existing.2@example.com");
r.assertOkStatus();
ChangeInfo ci = get(r.getChangeId(), DETAILED_LABELS);
ImmutableList<AccountInfo> reviewers = firstNonNull(ci.reviewers.get(ReviewerState.REVIEWER), ImmutableList.<AccountInfo>of()).stream().sorted(comparing((AccountInfo a) -> a.email)).collect(toImmutableList());
assertThat(reviewers).hasSize(2);
assertThat(reviewers.get(0).email).isEqualTo("non.existing.1@example.com");
assertThat(reviewers.get(0)._accountId).isNull();
assertThat(reviewers.get(1).email).isEqualTo("non.existing.2@example.com");
assertThat(reviewers.get(1)._accountId).isNull();
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class AccountApiImpl method get.
@Override
public com.google.gerrit.extensions.common.AccountInfo get() throws RestApiException {
AccountLoader accountLoader = accountLoaderFactory.create(true);
try {
AccountInfo ai = accountLoader.get(account.getUser().getAccountId());
accountLoader.fill();
return ai;
} catch (Exception e) {
throw asRestApiException("Cannot parse account", e);
}
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class EventUtil method accountInfo.
public AccountInfo accountInfo(AccountState accountState) {
if (accountState == null || accountState.account().id() == null) {
return null;
}
Account account = accountState.account();
AccountInfo accountInfo = new AccountInfo(account.id().get());
accountInfo.email = account.preferredEmail();
accountInfo.name = account.fullName();
accountInfo.username = accountState.userName().orElse(null);
return accountInfo;
}
Aggregations