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);
}
}
Aggregations