Search in sources :

Example 26 with AccountInfo

use of com.google.gerrit.extensions.common.AccountInfo 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());
}
Also used : ReviewerState(com.google.gerrit.extensions.client.ReviewerState) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 27 with AccountInfo

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

the class AccountIT method create.

@Test
public void create() throws Exception {
    TestAccount foo = accounts.create("foo");
    AccountInfo info = gApi.accounts().id(foo.id.get()).get();
    assertThat(info.username).isEqualTo("foo");
    if (SshMode.useSsh()) {
        // account creation + adding SSH keys
        accountIndexedCounter.assertReindexOf(foo, 2);
    } else {
        // account creation
        accountIndexedCounter.assertReindexOf(foo, 1);
    }
    // check user branch
    try (Repository repo = repoManager.openRepository(allUsers);
        RevWalk rw = new RevWalk(repo)) {
        Ref ref = repo.exactRef(RefNames.refsUsers(foo.getId()));
        assertThat(ref).isNotNull();
        RevCommit c = rw.parseCommit(ref.getObjectId());
        long timestampDiffMs = Math.abs(c.getCommitTime() * 1000L - accountCache.get(foo.getId()).getAccount().getRegisteredOn().getTime());
        assertThat(timestampDiffMs).isAtMost(ChangeRebuilderImpl.MAX_WINDOW_MS);
    }
}
Also used : TestRepository(org.eclipse.jgit.junit.TestRepository) Repository(org.eclipse.jgit.lib.Repository) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) Ref(org.eclipse.jgit.lib.Ref) RevWalk(org.eclipse.jgit.revwalk.RevWalk) TestAccount(com.google.gerrit.acceptance.TestAccount) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 28 with AccountInfo

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

the class AccountIT method putStatus.

@Test
public void putStatus() throws Exception {
    List<String> statuses = ImmutableList.of("OOO", "Busy");
    AccountInfo info;
    for (String status : statuses) {
        gApi.accounts().self().setStatus(status);
        admin.status = status;
        info = gApi.accounts().self().get();
        assertUser(info, admin);
        accountIndexedCounter.assertReindexOf(admin);
    }
}
Also used : PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 29 with AccountInfo

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

the class AccountIT method suggestAccounts.

@Test
public void suggestAccounts() throws Exception {
    String adminUsername = "admin";
    List<AccountInfo> result = gApi.accounts().suggestAccounts().withQuery(adminUsername).get();
    assertThat(result).hasSize(1);
    assertThat(result.get(0).username).isEqualTo(adminUsername);
    List<AccountInfo> resultShortcutApi = gApi.accounts().suggestAccounts(adminUsername).get();
    assertThat(resultShortcutApi).hasSize(result.size());
    List<AccountInfo> emptyResult = gApi.accounts().suggestAccounts("unknown").get();
    assertThat(emptyResult).isEmpty();
    accountIndexedCounter.assertNoReindex();
}
Also used : PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 30 with AccountInfo

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

the class AccountIT method getByIntId.

@Test
public void getByIntId() throws Exception {
    AccountInfo info = gApi.accounts().id("admin").get();
    AccountInfo infoByIntId = gApi.accounts().id(info._accountId).get();
    assertThat(info.name).isEqualTo(infoByIntId.name);
    accountIndexedCounter.assertNoReindex();
}
Also used : AccountInfo(com.google.gerrit.extensions.common.AccountInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) 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