use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class SCMConfigXmlLoaderTest method shouldResolveSCMReferenceElementForAMaterialInConfig.
@Test
public void shouldResolveSCMReferenceElementForAMaterialInConfig() throws Exception {
String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'>\n" + "<scms>\n" + " <scm id='scm-id' name='scm-name'>\n" + " <pluginConfiguration id='plugin-id' version='1.0'/>\n" + " <configuration>\n" + " <property>\n" + " <key>url</key>\n" + " <value>http://go</value>\n" + " </property>\n" + " </configuration>\n" + " </scm>\n" + " </scms>" + "<pipelines group=\"group_name\">\n" + " <pipeline name=\"new_name\">\n" + " <materials>\n" + " <scm ref='scm-id' />\n" + " </materials>\n" + " <stage name=\"stage_name\">\n" + " <jobs>\n" + " <job name=\"job_name\">\n" + " <tasks><ant /></tasks>\n" + " </job>\n" + " </jobs>\n" + " </stage>\n" + " </pipeline>\n" + "</pipelines></cruise>";
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(goConfigHolder.config.getSCMs().get(0)));
assertThat(pluggableSCMMaterialConfig.getFolder(), is(nullValue()));
assertThat(pluggableSCMMaterialConfig.filter(), is(new Filter()));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class SCMConfigXmlLoaderTest method shouldReadFolderAndFilterForPluggableSCMMaterialConfig.
@Test
public void shouldReadFolderAndFilterForPluggableSCMMaterialConfig() throws Exception {
String xml = "<cruise schemaVersion='" + GoConstants.CONFIG_SCHEMA_VERSION + "'>\n" + "<scms>\n" + " <scm id='scm-id' name='scm-name'>\n" + " <pluginConfiguration id='plugin-id' version='1.0'/>\n" + " <configuration>\n" + " <property>\n" + " <key>url</key>\n" + " <value>http://go</value>\n" + " </property>\n" + " </configuration>\n" + " </scm>\n" + " </scms>" + "<pipelines group=\"group_name\">\n" + " <pipeline name=\"new_name\">\n" + " <materials>\n" + " <scm ref='scm-id' dest='dest'>\n" + " <filter>\n" + " <ignore pattern=\"x\"/>\n" + " <ignore pattern=\"y\"/>\n" + " </filter>\n" + " </scm>\n" + " </materials>\n" + " <stage name=\"stage_name\">\n" + " <jobs>\n" + " <job name=\"job_name\">\n" + " <tasks><ant /></tasks>\n" + " </job>\n" + " </jobs>\n" + " </stage>\n" + " </pipeline>\n" + "</pipelines></cruise>";
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(goConfigHolder.config.getSCMs().get(0)));
assertThat(pluggableSCMMaterialConfig.getFolder(), is("dest"));
assertThat(pluggableSCMMaterialConfig.filter(), is(new Filter(new IgnoredFiles("x"), new IgnoredFiles("y"))));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class DeleteSCMConfigCommandTest method shouldValidateWhetherSCMIsAssociatedWithPipelines.
@Test
public void shouldValidateWhetherSCMIsAssociatedWithPipelines() {
PipelineConfig pipelineConfig = new GoConfigMother().addPipeline(cruiseConfig, "p1", "s1", "j1");
pipelineConfig.addMaterialConfig(new PluggableSCMMaterialConfig(scmConfig.getSCMId()));
DeleteSCMConfigCommand command = new DeleteSCMConfigCommand(scmConfig, pluggableScmService, result, currentUser, goConfigService);
assertThatThrownBy(() -> command.isValid(cruiseConfig)).hasMessageContaining("The scm 'name' is being referenced by pipeline(s): [p1]");
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldBeAbleToListAllDependencyMaterialConfigs.
@Test
public void shouldBeAbleToListAllDependencyMaterialConfigs() {
BasicCruiseConfig config = mock(BasicCruiseConfig.class);
DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
HashSet<MaterialConfig> materialConfigs = new HashSet<>(Arrays.asList(dependencyMaterialConfig, svnMaterialConfig, pluggableSCMMaterialConfig));
when(goConfigService.getCurrentConfig()).thenReturn(config);
when(config.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos()).thenReturn(materialConfigs);
Set<DependencyMaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableDependencyMaterials();
assertThat(schedulableDependencyMaterials.size(), is(1));
assertTrue(schedulableDependencyMaterials.contains(dependencyMaterialConfig));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist.
@Test
void shouldConvertConfigMaterialWhenPluggableScmMaterialWithWhitelist() {
SCM myscm = new SCM("scmid", new PluginConfiguration(), new Configuration());
SCMs scms = new SCMs(myscm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
PluggableSCMMaterialConfig configRepoMaterial = new PluggableSCMMaterialConfig(new CaseInsensitiveString("scmid"), myscm, null, null, true);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", new CRFilter(filter, true));
MaterialConfig pluggableMaterial = configConverter.toMaterialConfig(crConfigMaterial, context, scms);
assertTrue(pluggableMaterial.isInvertFilter());
}
Aggregations