Search in sources :

Example 1 with AllProjectsConfigProvider

use of com.google.gerrit.server.config.AllProjectsConfigProvider in project gerrit by GerritCodeReview.

the class AllProjectsConfigTest method setUp.

@Before
public void setUp() throws Exception {
    sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
    Files.createDirectories(sitePaths.etc_dir);
    Path gitPath = sitePaths.resolve("git");
    StoredConfig gerritConfig = new FileBasedConfig(sitePaths.resolve("etc").resolve("gerrit.config").toFile(), FS.DETECTED);
    gerritConfig.load();
    gerritConfig.setString("gerrit", null, "basePath", gitPath.toAbsolutePath().toString());
    gerritConfig.setString("gerrit", null, "allProjects", ALL_PROJECTS);
    gerritConfig.save();
    Files.createDirectories(sitePaths.resolve("git"));
    allProjectsRepoFile = gitPath.resolve("All-The-Projects.git").toFile();
    try (Repository repo = new FileRepository(allProjectsRepoFile)) {
        repo.create(true);
    }
    InMemorySecureStore secureStore = new InMemorySecureStore();
    InitFlags flags = new InitFlags(sitePaths, secureStore, ImmutableList.of(), false);
    Section.Factory sections = (name, subsection) -> new Section(flags, sitePaths, secureStore, ui, name, subsection);
    AllProjectsConfigProvider configProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
    allProjectsConfig = new AllProjectsConfig(new AllProjectsNameOnInitProvider(sections), configProvider, sitePaths, flags);
}
Also used : Path(java.nio.file.Path) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) InMemorySecureStore(com.google.gerrit.server.securestore.testing.InMemorySecureStore) FileBasedAllProjectsConfigProvider(com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider) Config(org.eclipse.jgit.lib.Config) ImmutableList(com.google.common.collect.ImmutableList) Path(java.nio.file.Path) Before(org.junit.Before) TestRepository(org.eclipse.jgit.junit.TestRepository) Files(java.nio.file.Files) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) IOException(java.io.IOException) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) File(java.io.File) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) Rule(org.junit.Rule) SitePaths(com.google.gerrit.server.config.SitePaths) StoredConfig(org.eclipse.jgit.lib.StoredConfig) FS(org.eclipse.jgit.util.FS) AllProjectsConfigProvider(com.google.gerrit.server.config.AllProjectsConfigProvider) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Repository(org.eclipse.jgit.lib.Repository) TemporaryFolder(org.junit.rules.TemporaryFolder) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) SitePaths(com.google.gerrit.server.config.SitePaths) StoredConfig(org.eclipse.jgit.lib.StoredConfig) TestRepository(org.eclipse.jgit.junit.TestRepository) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) Repository(org.eclipse.jgit.lib.Repository) FileBasedAllProjectsConfigProvider(com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider) InMemorySecureStore(com.google.gerrit.server.securestore.testing.InMemorySecureStore) FileBasedAllProjectsConfigProvider(com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider) AllProjectsConfigProvider(com.google.gerrit.server.config.AllProjectsConfigProvider) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) Before(org.junit.Before)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 AllProjectsConfigProvider (com.google.gerrit.server.config.AllProjectsConfigProvider)1 FileBasedAllProjectsConfigProvider (com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider)1 SitePaths (com.google.gerrit.server.config.SitePaths)1 InMemorySecureStore (com.google.gerrit.server.securestore.testing.InMemorySecureStore)1 File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1 FileRepository (org.eclipse.jgit.internal.storage.file.FileRepository)1 TestRepository (org.eclipse.jgit.junit.TestRepository)1 Config (org.eclipse.jgit.lib.Config)1 Repository (org.eclipse.jgit.lib.Repository)1 StoredConfig (org.eclipse.jgit.lib.StoredConfig)1 FileBasedConfig (org.eclipse.jgit.storage.file.FileBasedConfig)1 FS (org.eclipse.jgit.util.FS)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1