Search in sources :

Example 6 with SuggestedReviewerInfo

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

the class SuggestReviewersIT method reviewerRankingProjectIsolation.

@Test
public void reviewerRankingProjectIsolation() throws Exception {
    // Create new project
    Project.NameKey newProject = createProject("test");
    // Create users who review changes in both the default and the new project
    String fullName = "Primum Finalis";
    TestAccount userWhoOwns = user("customuser1", fullName);
    TestAccount reviewer1 = user("customuser2", fullName);
    TestAccount reviewer2 = user("customuser3", fullName);
    setApiUser(userWhoOwns);
    String changeId1 = createChangeFromApi();
    setApiUser(reviewer1);
    reviewChange(changeId1);
    setApiUser(userWhoOwns);
    String changeId2 = createChangeFromApi(newProject);
    setApiUser(reviewer2);
    reviewChange(changeId2);
    setApiUser(userWhoOwns);
    String changeId3 = createChangeFromApi(newProject);
    setApiUser(reviewer2);
    reviewChange(changeId3);
    setApiUser(userWhoOwns);
    List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Prim", 4);
    // Assert that reviewer1 is on top, even though reviewer2 has more reviews
    // in other projects
    assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList())).containsExactly(reviewer1.id.get(), reviewer2.id.get()).inOrder();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with SuggestedReviewerInfo

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

the class ReviewersUtil method loadAccounts.

private List<SuggestedReviewerInfo> loadAccounts(List<Account.Id> accountIds) throws OrmException {
    try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
        List<SuggestedReviewerInfo> reviewer = accountIds.stream().map(accountLoader::get).filter(Objects::nonNull).map(a -> {
            SuggestedReviewerInfo info = new SuggestedReviewerInfo();
            info.account = a;
            info.count = 1;
            return info;
        }).collect(toList());
        accountLoader.fill();
        return reviewer;
    }
}
Also used : GroupBackend(com.google.gerrit.server.account.GroupBackend) Iterables(com.google.common.collect.Iterables) AccountLoader(com.google.gerrit.server.account.AccountLoader) OrmException(com.google.gwtorm.server.OrmException) Inject(com.google.inject.Inject) QueryResult(com.google.gerrit.server.query.QueryResult) AccountQueryProcessor(com.google.gerrit.server.query.account.AccountQueryProcessor) NoSuchGroupException(com.google.gerrit.common.errors.NoSuchGroupException) GroupMembers(com.google.gerrit.server.account.GroupMembers) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Description(com.google.gerrit.metrics.Description) Account(com.google.gerrit.reviewdb.client.Account) EnumSet(java.util.EnumSet) SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) Project(com.google.gerrit.reviewdb.client.Project) PostReviewers(com.google.gerrit.server.change.PostReviewers) ProjectControl(com.google.gerrit.server.project.ProjectControl) GroupBaseInfo(com.google.gerrit.extensions.common.GroupBaseInfo) Timer0(com.google.gerrit.metrics.Timer0) Units(com.google.gerrit.metrics.Description.Units) FillOptions(com.google.gerrit.server.account.AccountDirectory.FillOptions) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) AccountQueryBuilder(com.google.gerrit.server.query.account.AccountQueryBuilder) Set(java.util.Set) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) IOException(java.io.IOException) Objects(java.util.Objects) QueryParseException(com.google.gerrit.server.query.QueryParseException) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) List(java.util.List) Url(com.google.gerrit.extensions.restapi.Url) MetricMaker(com.google.gerrit.metrics.MetricMaker) SuggestReviewers(com.google.gerrit.server.change.SuggestReviewers) AccountState(com.google.gerrit.server.account.AccountState) Collections(java.util.Collections) GroupReference(com.google.gerrit.common.data.GroupReference) Singleton(com.google.inject.Singleton) SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) Objects(java.util.Objects) Timer0(com.google.gerrit.metrics.Timer0)

Aggregations

SuggestedReviewerInfo (com.google.gerrit.extensions.common.SuggestedReviewerInfo)7 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)5 Test (org.junit.Test)5 TestAccount (com.google.gerrit.acceptance.TestAccount)4 GerritConfig (com.google.gerrit.acceptance.GerritConfig)2 GroupReference (com.google.gerrit.common.data.GroupReference)2 GroupBaseInfo (com.google.gerrit.extensions.common.GroupBaseInfo)2 Timer0 (com.google.gerrit.metrics.Timer0)2 Project (com.google.gerrit.reviewdb.client.Project)2 ArrayList (java.util.ArrayList)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 NoSuchGroupException (com.google.gerrit.common.errors.NoSuchGroupException)1 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)1 Url (com.google.gerrit.extensions.restapi.Url)1 Description (com.google.gerrit.metrics.Description)1 Units (com.google.gerrit.metrics.Description.Units)1 MetricMaker (com.google.gerrit.metrics.MetricMaker)1