Search in sources :

Example 31 with PluggableSCMMaterialConfig

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SCM(com.thoughtworks.go.domain.scm.SCM) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 32 with PluggableSCMMaterialConfig

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));
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 33 with PluggableSCMMaterialConfig

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());
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 34 with PluggableSCMMaterialConfig

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)));
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 35 with PluggableSCMMaterialConfig

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;
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)

Aggregations

PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)36 Test (org.junit.jupiter.api.Test)25 SCM (com.thoughtworks.go.domain.scm.SCM)14 SCMs (com.thoughtworks.go.domain.scm.SCMs)11 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)7 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 GoConfigHolder (com.thoughtworks.go.config.GoConfigHolder)3 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)3 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)3 ErrorGetter (com.thoughtworks.go.api.representers.ErrorGetter)2 Filter (com.thoughtworks.go.config.materials.Filter)2