Search in sources :

Example 1 with PluggableSCMMaterialConfig

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

Example 2 with PluggableSCMMaterialConfig

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

Example 3 with PluggableSCMMaterialConfig

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);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfigMother.createPipelineConfig(com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Pair(com.thoughtworks.go.util.Pair) Test(org.junit.jupiter.api.Test)

Example 4 with PluggableSCMMaterialConfig

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

Example 5 with PluggableSCMMaterialConfig

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

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