use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class InternalAccountDirectory method fillAccountInfo.
@Override
public void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options) throws DirectoryException {
if (options.equals(ID_ONLY)) {
return;
}
for (AccountInfo info : in) {
Account.Id id = new Account.Id(info._accountId);
AccountState state = accountCache.get(id);
fill(info, state.getAccount(), state.getExternalIds(), options);
}
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class EventUtil method accountInfo.
public AccountInfo accountInfo(Account a) {
if (a == null || a.getId() == null) {
return null;
}
AccountInfo accountInfo = new AccountInfo(a.getId().get());
accountInfo.email = a.getPreferredEmail();
accountInfo.name = a.getFullName();
accountInfo.username = a.getUserName();
return accountInfo;
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class ChangeIT method addSelfAsReviewer.
@Test
public void addSelfAsReviewer() throws Exception {
TestTimeUtil.resetWithClockStep(1, SECONDS);
PushOneCommit.Result r = createChange();
ChangeResource rsrc = parseResource(r);
String oldETag = rsrc.getETag();
Timestamp oldTs = rsrc.getChange().getLastUpdatedOn();
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
setApiUser(user);
gApi.changes().id(r.getChangeId()).addReviewer(in);
// There should be no email notification when adding self
assertThat(sender.getMessages()).isEmpty();
// When NoteDb is enabled adding a reviewer records that user as reviewer
// in NoteDb. When NoteDb is disabled adding a reviewer results in a dummy 0
// approval on the change which is treated as CC when the ChangeInfo is
// created.
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.getId().get());
// Ensure ETag and lastUpdatedOn are updated.
rsrc = parseResource(r);
assertThat(rsrc.getETag()).isNotEqualTo(oldETag);
assertThat(rsrc.getChange().getLastUpdatedOn()).isNotEqualTo(oldTs);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class ChangeIT method addReviewerToClosedChange.
@Test
public void addReviewerToClosedChange() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(admin.getId().get());
assertThat(c.reviewers).doesNotContainKey(CC);
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes().id(r.getChangeId()).addReviewer(in);
c = gApi.changes().id(r.getChangeId()).get();
reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).hasSize(2);
Iterator<AccountInfo> reviewerIt = reviewers.iterator();
assertThat(reviewerIt.next()._accountId).isEqualTo(admin.getId().get());
assertThat(reviewerIt.next()._accountId).isEqualTo(user.getId().get());
assertThat(c.reviewers).doesNotContainKey(CC);
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class ImpersonationIT method runAsValidUser.
@Test
public void runAsValidUser() throws Exception {
allowRunAs();
RestResponse res = adminRestSession.getWithHeader("/accounts/self", runAsHeader(user.id));
res.assertOK();
AccountInfo account = newGson().fromJson(res.getEntityContent(), AccountInfo.class);
assertThat(account._accountId).isEqualTo(user.id.get());
}
Aggregations