use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class GoFileConfigDataSourceTest method setup.
@Before
public void setup() throws Exception {
systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(SystemEnvironment.OPTIMIZE_FULL_CONFIG_SAVE.propertyName(), "false");
configHelper = new GoConfigFileHelper();
configHelper.onSetUp();
configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
timeProvider = mock(TimeProvider.class);
fullConfigSaveMergeFlow = mock(FullConfigSaveMergeFlow.class);
fullConfigSaveNormalFlow = mock(FullConfigSaveNormalFlow.class);
when(timeProvider.currentTime()).thenReturn(new Date());
ServerVersion serverVersion = new ServerVersion();
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
ServerHealthService serverHealthService = new ServerHealthService();
cachedGoPartials = new CachedGoPartials(serverHealthService);
dataSource = new GoFileConfigDataSource(new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {
public void handle(Exception e) {
throw new RuntimeException(e);
}
}, configRepository, new TimeProvider(), configCache, registry), configRepository, systemEnvironment, timeProvider, configCache, serverVersion, registry, mock(ServerHealthService.class), cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
dataSource.upgradeIfNecessary();
CachedGoConfig cachedGoConfig = new CachedGoConfig(serverHealthService, dataSource, mock(CachedGoPartials.class), null, null);
cachedGoConfig.loadConfigIfNull();
goConfigDao = new GoConfigDao(cachedGoConfig);
configHelper.load();
configHelper.usingCruiseConfigDao(goConfigDao);
GoConfigWatchList configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
ConfigElementImplementationRegistry configElementImplementationRegistry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
GoConfigPluginService configPluginService = new GoConfigPluginService(mock(ConfigRepoExtension.class), new ConfigCache(), configElementImplementationRegistry, cachedGoConfig);
repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
configHelper.addConfigRepo(repoConfig);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class InvalidConfigMessageRemoverIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
File tempFolder = temporaryFolder.newFolder();
configFile = new File(tempFolder, "cruise-config.xml");
configFile.createNewFile();
GoConfigFileHelper.clearConfigVersions();
configHelper = new GoConfigFileHelper();
configHelper.onSetUp();
SystemEnvironment systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(SystemEnvironment.CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
new ConfigRepository(systemEnvironment).initialize();
serverHealthService.removeAllLogs();
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class FullConfigSaveMergeFlowTest method setup.
@BeforeEach
public void setup() throws Exception {
configForEdit = mock(CruiseConfig.class);
updateConfigCommand = new FullConfigUpdateCommand(configForEdit, "md5");
loader = mock(MagicalGoConfigXmlLoader.class);
writer = mock(MagicalGoConfigXmlWriter.class);
document = mock(Document.class);
fileWriter = mock(GoConfigFileWriter.class);
timeProvider = mock(TimeProvider.class);
configRepository = mock(ConfigRepository.class);
cachedGoPartials = mock(CachedGoPartials.class);
configElementImplementationRegistry = mock(ConfigElementImplementationRegistry.class);
partials = new ArrayList<>();
flow = new FullConfigSaveMergeFlow(loader, writer, configElementImplementationRegistry, timeProvider, configRepository, cachedGoPartials, fileWriter);
when(writer.documentFrom(configForEdit)).thenReturn(document);
when(writer.toString(document)).thenReturn("cruise_config");
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class FullConfigSaveNormalFlowTest method setup.
@BeforeEach
public void setup() throws Exception {
configForEdit = new BasicCruiseConfig();
updateConfigCommand = new FullConfigUpdateCommand(configForEdit, "md5");
loader = mock(MagicalGoConfigXmlLoader.class);
writer = mock(MagicalGoConfigXmlWriter.class);
document = mock(Document.class);
fileWriter = mock(GoConfigFileWriter.class);
timeProvider = mock(TimeProvider.class);
configRepository = mock(ConfigRepository.class);
cachedGoPartials = mock(CachedGoPartials.class);
configElementImplementationRegistry = mock(ConfigElementImplementationRegistry.class);
partials = new ArrayList<>();
flow = new FullConfigSaveNormalFlow(loader, writer, configElementImplementationRegistry, timeProvider, configRepository, cachedGoPartials, fileWriter);
when(writer.documentFrom(configForEdit)).thenReturn(document);
when(loader.preprocessAndValidate(configForEdit)).thenReturn(new BasicCruiseConfig());
when(writer.toString(document)).thenReturn("cruise_config");
}
use of com.thoughtworks.go.service.ConfigRepository in project gocd by gocd.
the class ConfigRepositoryValidatorServiceTest method shouldShutDownServerIfConfigRepositoryIsCorrupted.
@Test
public void shouldShutDownServerIfConfigRepositoryIsCorrupted() throws Exception {
ConfigRepository configRepository = mock(ConfigRepository.class);
when(configRepository.isRepositoryCorrupted()).thenReturn(true);
ConfigRepositoryValidatorService configRepositoryValidatorServiceSpy = spy(new ConfigRepositoryValidatorService(configRepository));
doNothing().when(configRepositoryValidatorServiceSpy).shutDownServer();
configRepositoryValidatorServiceSpy.afterPropertiesSet();
verify(configRepositoryValidatorServiceSpy).shutDownServer();
}
Aggregations