Search in sources :

Example 1 with GroupCache

use of com.google.gerrit.server.account.GroupCache in project gerrit by GerritCodeReview.

the class ProjectResetterTest method groupEviction.

@Test
public void groupEviction() throws Exception {
    AccountGroup.UUID uuid1 = AccountGroup.uuid("abcd1");
    AccountGroup.UUID uuid2 = AccountGroup.uuid("abcd2");
    AccountGroup.UUID uuid3 = AccountGroup.uuid("abcd3");
    Project.NameKey allUsers = Project.nameKey(AllUsersNameProvider.DEFAULT);
    Repository allUsersRepo = repoManager.createRepository(allUsers);
    GroupCache cache = mock(GroupCache.class);
    GroupIndexer indexer = mock(GroupIndexer.class);
    GroupIncludeCache includeCache = mock(GroupIncludeCache.class);
    createRef(allUsersRepo, RefNames.refsGroups(uuid1));
    Ref ref2 = createRef(allUsersRepo, RefNames.refsGroups(uuid2));
    try (ProjectResetter resetProject = builder(null, null, null, cache, includeCache, indexer, null).build(new ProjectResetter.Config().reset(project).reset(allUsers))) {
        updateRef(allUsersRepo, ref2);
        createRef(allUsersRepo, RefNames.refsGroups(uuid3));
    }
    verify(cache).evict(uuid2);
    verify(indexer).index(uuid2);
    verify(includeCache).evictParentGroupsOf(uuid2);
    verify(cache).evict(uuid3);
    verify(indexer).index(uuid3);
    verify(includeCache).evictParentGroupsOf(uuid3);
    verifyNoMoreInteractions(cache, indexer, includeCache);
}
Also used : Project(com.google.gerrit.entities.Project) Repository(org.eclipse.jgit.lib.Repository) Ref(org.eclipse.jgit.lib.Ref) AccountGroup(com.google.gerrit.entities.AccountGroup) GroupIndexer(com.google.gerrit.server.index.group.GroupIndexer) GroupCache(com.google.gerrit.server.account.GroupCache) GroupIncludeCache(com.google.gerrit.server.account.GroupIncludeCache) Test(org.junit.Test)

Aggregations

AccountGroup (com.google.gerrit.entities.AccountGroup)1 Project (com.google.gerrit.entities.Project)1 GroupCache (com.google.gerrit.server.account.GroupCache)1 GroupIncludeCache (com.google.gerrit.server.account.GroupIncludeCache)1 GroupIndexer (com.google.gerrit.server.index.group.GroupIndexer)1 Ref (org.eclipse.jgit.lib.Ref)1 Repository (org.eclipse.jgit.lib.Repository)1 Test (org.junit.Test)1