Search in sources :

Example 1 with MaintenanceModeService

use of com.thoughtworks.go.server.service.MaintenanceModeService in project gocd by gocd.

the class GoConfigFileHelper method createTestingDao.

/**
 * Creates config dao that accesses single file
 */
public static GoConfigDao createTestingDao() {
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    try {
        MaintenanceModeService maintenanceModeService = new MaintenanceModeService(new TimeProvider(), systemEnvironment);
        ServerHealthService serverHealthService = new ServerHealthService();
        ConfigRepository configRepository = new ConfigRepository(systemEnvironment);
        configRepository.initialize();
        ConfigCache configCache = new ConfigCache();
        ConfigElementImplementationRegistry configElementImplementationRegistry = ConfigElementImplementationRegistryMother.withNoPlugins();
        CachedGoPartials cachedGoPartials = new CachedGoPartials(serverHealthService);
        FullConfigSaveNormalFlow normalFlow = new FullConfigSaveNormalFlow(configCache, configElementImplementationRegistry, systemEnvironment, new TimeProvider(), configRepository, cachedGoPartials);
        GoFileConfigDataSource dataSource = new GoFileConfigDataSource(new DoNotUpgrade(), configRepository, systemEnvironment, new TimeProvider(), configCache, configElementImplementationRegistry, cachedGoPartials, null, normalFlow, mock(PartialConfigHelper.class));
        GoConfigMigration goConfigMigration = new GoConfigMigration(new TimeProvider(), configElementImplementationRegistry);
        GoConfigMigrator goConfigMigrator = new GoConfigMigrator(goConfigMigration, new SystemEnvironment(), configCache, configElementImplementationRegistry, normalFlow, configRepository, serverHealthService);
        FileUtils.writeStringToFile(dataSource.fileLocation(), ConfigFileFixture.configWithSecurity(""), UTF_8);
        goConfigMigrator.migrate();
        CachedGoConfig cachedConfigService = new CachedGoConfig(serverHealthService, dataSource, cachedGoPartials, null, maintenanceModeService);
        cachedConfigService.loadConfigIfNull();
        return new GoConfigDao(cachedConfigService);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ConfigRepository(com.thoughtworks.go.service.ConfigRepository) IOException(java.io.IOException) MaintenanceModeService(com.thoughtworks.go.server.service.MaintenanceModeService) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService)

Aggregations

ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1 MaintenanceModeService (com.thoughtworks.go.server.service.MaintenanceModeService)1 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)1 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)1 IOException (java.io.IOException)1