use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class UpdateSCMConfigCommandTest method shouldUpdateSCMConfigurationOnAssociatedPipelines.
@Test
public void shouldUpdateSCMConfigurationOnAssociatedPipelines() {
SCM updatedSCM = SCMMother.create("id", "prop3", "prop4");
cruiseConfig.addPipelineWithoutValidation("group1", PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(pluggableSCMMaterialConfig("id", "prop1", "prop2"))));
cruiseConfig.addPipelineWithoutValidation("group2", PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(pluggableSCMMaterialConfig("id", "prop1", "prop2"))));
UpdateSCMConfigCommand command = new UpdateSCMConfigCommand(updatedSCM, pluggableScmService, goConfigService, currentUser, result, "digest", entityHashingService);
command.update(cruiseConfig);
PluggableSCMMaterialConfig materialConfig1 = (PluggableSCMMaterialConfig) cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p1")).materialConfigs().get(0);
assertThat(materialConfig1.getSCMConfig(), is(updatedSCM));
PluggableSCMMaterialConfig materialConfig2 = (PluggableSCMMaterialConfig) cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p2")).materialConfigs().get(0);
assertThat(materialConfig2.getSCMConfig(), is(updatedSCM));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PipelineConfigServiceIntegrationTest method shouldMapErrorsBackToScmMaterials.
@Test
public void shouldMapErrorsBackToScmMaterials() throws Exception {
GoConfigHolder goConfigHolder = goConfigDao.loadConfigHolder();
String scmid = "scmid";
saveScmMaterialToConfig(scmid);
PluggableSCMMaterialConfig scmMaterialConfig = new PluggableSCMMaterialConfig(scmid);
String digest = entityHashingService.hashForEntity(pipelineConfig, groupName);
pipelineConfig.materialConfigs().add(scmMaterialConfig);
pipelineConfigService.updatePipelineConfig(user, pipelineConfig, groupName, digest, result);
assertThat(result.toString(), result.isSuccessful(), is(false));
assertThat(scmMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Destination directory is required when a pipeline has multiple SCM materials."));
assertThat(scmMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Could not find plugin for scm-id: [scmid]."));
assertThat(configRepository.getCurrentRevCommit().name(), is(headCommitBeforeUpdate));
assertThat(goConfigDao.loadConfigHolder().configForEdit, is(goConfigHolder.configForEdit));
assertThat(goConfigDao.loadConfigHolder().config, is(goConfigHolder.config));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldUpdateMaterialFromMaterialConfig.
@Test
void shouldUpdateMaterialFromMaterialConfig() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
PluggableSCMMaterialConfig materialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("new_key"), new ConfigurationValue("new_value")));
materialConfig.getSCMConfig().setConfiguration(configuration);
material.updateFromConfig(materialConfig);
assertThat(material.getScmConfig().getConfiguration()).isEqualTo(materialConfig.getSCMConfig().getConfiguration());
assertThat(material.getScmConfig().getName()).isEqualTo(materialConfig.getSCMConfig().getName());
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class GoConfigMaterialsTest method shouldNotIncludePluggableSCMMaterialsWithAutoUpdateFalse.
@Test
public void shouldNotIncludePluggableSCMMaterialsWithAutoUpdateFalse() {
PipelineConfig pipeline1 = pipelineWithManyMaterials(false);
PluggableSCMMaterialConfig autoUpdateMaterialConfig = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id-1"), null, null, false);
pipeline1.addMaterialConfig(autoUpdateMaterialConfig);
PluggableSCMMaterialConfig nonAutoUpdateMaterialConfig = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id-2"), null, null, false);
nonAutoUpdateMaterialConfig.getSCMConfig().setAutoUpdate(false);
pipeline1.addMaterialConfig(nonAutoUpdateMaterialConfig);
pipeline1.add(new StageConfig(new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval()));
CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(pipeline1));
Set<MaterialConfig> materialsBelongingToAutoPipelines = config.getAllUniqueMaterialsBelongingToAutoPipelines();
assertThat(materialsBelongingToAutoPipelines.size(), is(4));
assertThat(materialsBelongingToAutoPipelines, containsInAnyOrder(pipeline1.materialConfigs().get(1), pipeline1.materialConfigs().get(2), pipeline1.materialConfigs().get(3), pipeline1.materialConfigs().get(4)));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig in project gocd by gocd.
the class PluggableScmMaterialRepresenter method fromJSON.
@Override
public PluggableSCMMaterialConfig fromJSON(JsonReader jsonReader, ConfigHelperOptions options) {
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig();
CruiseConfig cruiseConfig = options.getCruiseConfig();
if (cruiseConfig != null) {
String ref = jsonReader.getString("ref");
pluggableSCMMaterialConfig.setSCMConfig(cruiseConfig.getSCMs().find(ref));
pluggableSCMMaterialConfig.setScmId(ref);
}
jsonReader.readStringIfPresent("destination", pluggableSCMMaterialConfig::setFolder);
jsonReader.optJsonObject("filter").ifPresent(filterReader -> {
pluggableSCMMaterialConfig.setFilter(FilterRepresenter.fromJSON(filterReader));
});
jsonReader.optBoolean("invert_filter").ifPresent(pluggableSCMMaterialConfig::setInvertFilter);
return pluggableSCMMaterialConfig;
}
Aggregations