Search in sources :

Example 11 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.

the class GetPastAssignees method apply.

@Override
public Response<List<AccountInfo>> apply(ChangeResource rsrc) throws OrmException {
    Set<Account.Id> pastAssignees = rsrc.getControl().getNotes().load().getPastAssignees();
    if (pastAssignees == null) {
        return Response.ok(Collections.emptyList());
    }
    AccountLoader accountLoader = accountLoaderFactory.create(true);
    List<AccountInfo> infos = pastAssignees.stream().map(accountLoader::get).collect(toList());
    accountLoader.fill();
    return Response.ok(infos);
}
Also used : AccountLoader(com.google.gerrit.server.account.AccountLoader) AccountInfo(com.google.gerrit.extensions.common.AccountInfo)

Example 12 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.

the class AddMembers method toAccountInfoList.

private List<AccountInfo> toAccountInfoList(Set<Account.Id> accountIds) throws OrmException {
    List<AccountInfo> result = new ArrayList<>();
    AccountLoader loader = infoFactory.create(true);
    for (Account.Id accId : accountIds) {
        result.add(loader.get(accId));
    }
    loader.fill();
    return result;
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) AccountLoader(com.google.gerrit.server.account.AccountLoader) ArrayList(java.util.ArrayList) AccountInfo(com.google.gerrit.extensions.common.AccountInfo)

Example 13 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.

the class GetMember method apply.

@Override
public AccountInfo apply(MemberResource rsrc) throws OrmException {
    AccountLoader loader = infoFactory.create(true);
    AccountInfo info = loader.get(rsrc.getMember().getAccountId());
    loader.fill();
    return info;
}
Also used : AccountLoader(com.google.gerrit.server.account.AccountLoader) AccountInfo(com.google.gerrit.extensions.common.AccountInfo)

Example 14 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.

the class AbstractQueryAccountsTest method isActive.

@Test
public void isActive() throws Exception {
    String domain = name("test.com");
    AccountInfo user1 = newAccountWithEmail("user1", "user1@" + domain);
    AccountInfo user2 = newAccountWithEmail("user2", "user2@" + domain);
    AccountInfo user3 = newAccount("user3", "user3@" + domain, false);
    AccountInfo user4 = newAccount("user4", "user4@" + domain, false);
    // by default only active accounts are returned
    assertQuery(domain, user1, user2);
    assertQuery("name:" + domain, user1, user2);
    assertQuery("is:active name:" + domain, user1, user2);
    assertQuery("is:inactive name:" + domain, user3, user4);
}
Also used : AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Test(org.junit.Test)

Example 15 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.

the class AbstractQueryAccountsTest method byWatchedProject.

@Test
public void byWatchedProject() throws Exception {
    Project.NameKey p = createProject(name("p"));
    Project.NameKey p2 = createProject(name("p2"));
    AccountInfo user1 = newAccountWithFullName("jdoe", "John Doe");
    AccountInfo user2 = newAccountWithFullName("jroe", "Jane Roe");
    AccountInfo user3 = newAccountWithFullName("user3", "Mr Selfish");
    assertThat(internalAccountQuery.byWatchedProject(p)).isEmpty();
    watch(user1, p, null);
    assertAccounts(internalAccountQuery.byWatchedProject(p), user1);
    watch(user2, p, "keyword");
    assertAccounts(internalAccountQuery.byWatchedProject(p), user1, user2);
    watch(user3, p2, "keyword");
    watch(user3, allProjects, "keyword");
    assertAccounts(internalAccountQuery.byWatchedProject(p), user1, user2);
    assertAccounts(internalAccountQuery.byWatchedProject(p2), user3);
    assertAccounts(internalAccountQuery.byWatchedProject(allProjects), user3);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Test(org.junit.Test)

Aggregations

AccountInfo (com.google.gerrit.extensions.common.AccountInfo)58 Test (org.junit.Test)36 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)24 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)18 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)14 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)13 ReviewerState (com.google.gerrit.extensions.client.ReviewerState)9 Account (com.google.gerrit.reviewdb.client.Account)8 Message (com.google.gerrit.testutil.FakeEmailSender.Message)8 AccountLoader (com.google.gerrit.server.account.AccountLoader)5 ArrayList (java.util.ArrayList)5 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)4 AuthException (com.google.gerrit.extensions.restapi.AuthException)3 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)3 Change (com.google.gerrit.reviewdb.client.Change)3 TestAccount (com.google.gerrit.acceptance.TestAccount)2 LabelType (com.google.gerrit.common.data.LabelType)2 AddReviewerResult (com.google.gerrit.extensions.api.changes.AddReviewerResult)2 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 ProblemInfo (com.google.gerrit.extensions.common.ProblemInfo)2