Search in sources :

Example 76 with GitMaterialConfig

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));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.Test)

Example 77 with GitMaterialConfig

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));
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) User(org.springframework.security.userdetails.User) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) UsernamePasswordAuthenticationToken(org.springframework.security.providers.UsernamePasswordAuthenticationToken) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ConfigFileHasChangedException(com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) ConfigMergeException(com.thoughtworks.go.config.exceptions.ConfigMergeException) IOException(java.io.IOException) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) SecurityContext(org.springframework.security.context.SecurityContext) ConfigRepoExtension(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension) Before(org.junit.Before)

Example 78 with GitMaterialConfig

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"));
    }
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 79 with GitMaterialConfig

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));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 80 with GitMaterialConfig

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");
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7