Search in sources :

Example 21 with PluggableSCMMaterialConfig

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

Example 22 with PluggableSCMMaterialConfig

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

Example 23 with PluggableSCMMaterialConfig

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

Example 24 with PluggableSCMMaterialConfig

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

Example 25 with PluggableSCMMaterialConfig

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());
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) 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