use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PipelineGroups method getAllUniquePostCommitSchedulableMaterials.
public Set<MaterialConfig> getAllUniquePostCommitSchedulableMaterials() {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<String> uniqueMaterials = new HashSet<>();
for (PipelineConfigs pipelineConfigs : this) {
for (PipelineConfig pipelineConfig : pipelineConfigs) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if ((materialConfig instanceof ScmMaterialConfig || materialConfig instanceof PluggableSCMMaterialConfig) && !materialConfig.isAutoUpdate() && !uniqueMaterials.contains(materialConfig.getFingerprint())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getFingerprint());
}
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PipelineConfigTest method shouldGetPluggableSCMMaterialConfigs.
@Test
public void shouldGetPluggableSCMMaterialConfigs() throws Exception {
SvnMaterialConfig svn = new SvnMaterialConfig("svn", false);
PluggableSCMMaterialConfig pluggableSCMMaterialOne = new PluggableSCMMaterialConfig("scm-id-1");
PluggableSCMMaterialConfig pluggableSCMMaterialTwo = new PluggableSCMMaterialConfig("scm-id-2");
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(svn, pluggableSCMMaterialOne, pluggableSCMMaterialTwo));
List<PluggableSCMMaterialConfig> pluggableSCMMaterialConfigs = pipelineConfig.pluggableSCMMaterialConfigs();
assertThat(pluggableSCMMaterialConfigs.size(), is(2));
assertThat(pluggableSCMMaterialConfigs, hasItems(pluggableSCMMaterialOne, pluggableSCMMaterialTwo));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PipelineGroupsTest method shouldGetPluggableSCMMaterialUsageInPipelines.
@Test
public void shouldGetPluggableSCMMaterialUsageInPipelines() throws Exception {
PluggableSCMMaterialConfig pluggableSCMMaterialOne = new PluggableSCMMaterialConfig("scm-id-one");
PluggableSCMMaterialConfig pluggableSCMMaterialTwo = new PluggableSCMMaterialConfig("scm-id-two");
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(pluggableSCMMaterialOne, pluggableSCMMaterialTwo), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(pluggableSCMMaterialTwo), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
PipelineGroups groups = new PipelineGroups();
PipelineConfigs groupOne = new BasicPipelineConfigs(p1);
PipelineConfigs groupTwo = new BasicPipelineConfigs(p2);
groups.addAll(asList(groupOne, groupTwo));
Map<String, List<Pair<PipelineConfig, PipelineConfigs>>> pluggableSCMMaterialUsageInPipelinesOne = groups.getPluggableSCMMaterialUsageInPipelines();
assertThat(pluggableSCMMaterialUsageInPipelinesOne.get("scm-id-one").size(), is(1));
assertThat(pluggableSCMMaterialUsageInPipelinesOne.get("scm-id-one"), hasItems(new Pair<>(p1, groupOne)));
assertThat(pluggableSCMMaterialUsageInPipelinesOne.get("scm-id-two").size(), is(2));
assertThat(pluggableSCMMaterialUsageInPipelinesOne.get("scm-id-two"), hasItems(new Pair<>(p1, groupOne), new Pair<>(p2, groupTwo)));
Map<String, List<Pair<PipelineConfig, PipelineConfigs>>> pluggableSCMMaterialUsageInPipelinesTwo = groups.getPluggableSCMMaterialUsageInPipelines();
assertSame(pluggableSCMMaterialUsageInPipelinesOne, pluggableSCMMaterialUsageInPipelinesTwo);
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterialWithNewSCM.
@Test
void shouldConvertPluggableScmMaterialWithNewSCM() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(new SCMs());
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
Configuration config = new Configuration();
config.addNewConfigurationWithValue("url", "url", false);
SCM myscm = new SCM("scmid", new PluginConfiguration("plugin_id", "1.0"), config);
CRPluggableScmMaterial crPluggableScmMaterial = new CRPluggableScmMaterial("name", "scmid", "directory", filter, false);
crPluggableScmMaterial.setPluginConfiguration(new CRPluginConfiguration("plugin_id", "1.0"));
crPluggableScmMaterial.getConfiguration().add(new CRConfigurationProperty("url", "url"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context, new SCMs());
assertThat(pluggableSCMMaterialConfig.getName().toLower()).isEqualTo("name");
assertThat(pluggableSCMMaterialConfig.getSCMConfig().getName()).isEqualTo("name");
assertThat(pluggableSCMMaterialConfig.getSCMConfig().getId()).isEqualTo("scmid");
assertThat(pluggableSCMMaterialConfig.getSCMConfig().getFingerprint()).isEqualTo(myscm.getFingerprint());
assertThat(pluggableSCMMaterialConfig.getScmId()).isEqualTo("scmid");
assertThat(pluggableSCMMaterialConfig.getFolder()).isEqualTo("directory");
assertThat(pluggableSCMMaterialConfig.getFilterAsString()).isEqualTo("filter");
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPluggableScmMaterialWithADuplicateSCMIDShouldUseWhatAlreadyExists.
@Test
void shouldConvertPluggableScmMaterialWithADuplicateSCMIDShouldUseWhatAlreadyExists() {
SCM scm = new SCM("scmid", new PluginConfiguration(), new Configuration());
scm.setName("noName");
SCMs scms = new SCMs(scm);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setSCMs(scms);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPluggableScmMaterial crPluggableScmMaterial = new CRPluggableScmMaterial("name", "scmid", "directory", filter, false);
crPluggableScmMaterial.setPluginConfiguration(new CRPluginConfiguration("plugin_id", "1.0"));
crPluggableScmMaterial.getConfiguration().add(new CRConfigurationProperty("url", "url"));
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = (PluggableSCMMaterialConfig) configConverter.toMaterialConfig(crPluggableScmMaterial, context, scms);
assertThat(pluggableSCMMaterialConfig.getSCMConfig()).isEqualTo(scm);
}
Aggregations