Search in sources :

Example 11 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class RefControlTest method setUp.

@Before
public void setUp() throws Exception {
    repoManager = new InMemoryRepositoryManager();
    projectCache = new ProjectCache() {

        @Override
        public ProjectState getAllProjects() {
            return get(allProjectsName);
        }

        @Override
        public ProjectState getAllUsers() {
            return null;
        }

        @Override
        public ProjectState get(Project.NameKey projectName) {
            return all.get(projectName);
        }

        @Override
        public void evict(Project p) {
        }

        @Override
        public void remove(Project p) {
        }

        @Override
        public Iterable<Project.NameKey> all() {
            return Collections.emptySet();
        }

        @Override
        public Iterable<Project.NameKey> byName(String prefix) {
            return Collections.emptySet();
        }

        @Override
        public void onCreateProject(Project.NameKey newProjectName) {
        }

        @Override
        public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() {
            return Collections.emptySet();
        }

        @Override
        public ProjectState checkedGet(Project.NameKey projectName) throws IOException {
            return all.get(projectName);
        }

        @Override
        public void evict(Project.NameKey p) {
        }
    };
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    try {
        Repository repo = repoManager.createRepository(allProjectsName);
        ProjectConfig allProjects = new ProjectConfig(new Project.NameKey(allProjectsName.get()));
        allProjects.load(repo);
        LabelType cr = Util.codeReview();
        allProjects.getLabelSections().put(cr.getName(), cr);
        add(allProjects);
    } catch (IOException | ConfigInvalidException e) {
        throw new RuntimeException(e);
    }
    db = schemaFactory.open();
    singleVersionListener.start();
    try {
        schemaCreator.create(db);
    } finally {
        singleVersionListener.stop();
    }
    Cache<SectionSortCache.EntryKey, SectionSortCache.EntryVal> c = CacheBuilder.newBuilder().build();
    sectionSorter = new PermissionCollection.Factory(new SectionSortCache(c));
    parent = new ProjectConfig(parentKey);
    parent.load(newRepository(parentKey));
    add(parent);
    local = new ProjectConfig(localKey);
    local.load(newRepository(localKey));
    add(local);
    local.getProject().setParentName(parentKey);
    requestContext.setContext(new RequestContext() {

        @Override
        public CurrentUser getUser() {
            return null;
        }

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });
    changeControlFactory = injector.getInstance(ChangeControl.Factory.class);
}
Also used : Set(java.util.Set) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) CurrentUser(com.google.gerrit.server.CurrentUser) InMemoryRepositoryManager(com.google.gerrit.testutil.InMemoryRepositoryManager) Injector(com.google.inject.Injector) LabelType(com.google.gerrit.common.data.LabelType) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) RequestContext(com.google.gerrit.server.util.RequestContext) InMemoryModule(com.google.gerrit.testutil.InMemoryModule) IOException(java.io.IOException) AllUsersNameProvider(com.google.gerrit.server.config.AllUsersNameProvider) AllProjectsNameProvider(com.google.gerrit.server.config.AllProjectsNameProvider) Provider(com.google.inject.Provider) ProjectConfig(com.google.gerrit.server.git.ProjectConfig) Project(com.google.gerrit.reviewdb.client.Project) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) InMemoryRepositoryManager.newRepository(com.google.gerrit.testutil.InMemoryRepositoryManager.newRepository) Repository(org.eclipse.jgit.lib.Repository) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) Before(org.junit.Before)

Example 12 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class LuceneQueryAccountsTest method createInjector.

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    return Guice.createInjector(new InMemoryModule(luceneConfig, notesMigration));
}
Also used : Config(org.eclipse.jgit.lib.Config) InMemoryModule(com.google.gerrit.testutil.InMemoryModule)

Aggregations

InMemoryModule (com.google.gerrit.testutil.InMemoryModule)12 Config (org.eclipse.jgit.lib.Config)7 CurrentUser (com.google.gerrit.server.CurrentUser)6 RequestContext (com.google.gerrit.server.util.RequestContext)6 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)6 Injector (com.google.inject.Injector)6 Provider (com.google.inject.Provider)6 Before (org.junit.Before)6 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)5 Account (com.google.gerrit.reviewdb.client.Account)4 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)4 Project (com.google.gerrit.reviewdb.client.Project)3 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)2 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 LabelType (com.google.gerrit.common.data.LabelType)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1 AllProjectsNameProvider (com.google.gerrit.server.config.AllProjectsNameProvider)1 AllUsersNameProvider (com.google.gerrit.server.config.AllUsersNameProvider)1 InMemoryRepositoryManager (com.google.gerrit.testutil.InMemoryRepositoryManager)1