use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoConfigWatchListTest method shouldNotifyConfigListenersWhenSingleConfigRepoHasChanged.
@Test
public void shouldNotifyConfigListenersWhenSingleConfigRepoHasChanged() throws Exception {
final ChangedRepoConfigWatchListListener listener = mock(ChangedRepoConfigWatchListListener.class);
watchList.registerListener(listener);
watchList.onEntityConfigChange(new ConfigRepoConfig(new GitMaterialConfig("http://git1"), "myplugin", "id"));
verify(listener, times(2)).onChangedRepoConfigWatchList(notNull(ConfigReposConfig.class));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig 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.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed.
@Test
public void shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed() throws Exception {
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenThrow(new RuntimeException("Failed to initialize plugin"));
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(material, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
try {
repoConfigDataSource.latestPartialConfigForMaterial(material);
} catch (RuntimeException ex) {
assertThat(ex.getMessage(), is("Failed to initialize plugin"));
}
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldAssignConfigOriginInPipelines.
@Test
public void shouldAssignConfigOriginInPipelines() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig configRepo = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
configWatchList.onConfigChange(cruiseConfig);
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(PartialConfigMother.withPipeline("pipe1"));
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
assertNotNull(partialConfig.getOrigin());
assertThat(partialConfig.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
PipelineConfig pipe = partialConfig.getGroups().get(0).get(0);
assertThat(pipe.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldProvideConfigurationInParseContextWhenCallingPlugin.
@Test
public void shouldProvideConfigurationInParseContextWhenCallingPlugin() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig repoConfig = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig));
configWatchList.onConfigChange(cruiseConfig);
repoConfig.getConfiguration().addNewConfigurationWithValue("key", "value", false);
plugin = new AssertingConfigPlugin(repoConfig.getConfiguration());
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
}
Aggregations