Search in sources :

Example 56 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist.

@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHgWithWhitelist() {
    // this url would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = hg("url", "folder");
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial(null, null, new CRFilter(filter, true));
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
    assertThat(materialConfig.getName()).as("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode").isNull();
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("filter");
    assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
    assertThat(hgMaterialConfig.filter()).isEqualTo(new Filter(new IgnoredFiles("filter")));
    assertThat(hgMaterialConfig.isInvertFilter()).isTrue();
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) 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) Test(org.junit.jupiter.api.Test)

Example 57 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithEmptyFilter.

@Test
void shouldConvertConfigMaterialWhenConfigRepoIsHgWithEmptyFilter() {
    // this url would be configured inside xml config-repo section
    HgMaterialConfig configRepoMaterial = hg("url", "folder");
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial(null, null, new CRFilter(new ArrayList<>(), true));
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context, new SCMs());
    assertThat(materialConfig.getName()).as("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode").isNull();
    HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
    assertThat(hgMaterialConfig.getAutoUpdate()).isTrue();
    assertThat(hgMaterialConfig.getFilterAsString()).isEqualTo("");
    assertThat(hgMaterialConfig.getUrl()).isEqualTo("url");
    assertThat(hgMaterialConfig.filter()).isEqualTo(new Filter());
    assertThat(hgMaterialConfig.isInvertFilter()).isFalse();
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) Filter(com.thoughtworks.go.config.materials.Filter) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) 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) Test(org.junit.jupiter.api.Test)

Example 58 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigServiceTest method shouldBeAbleToListAllSCMMaterialConfigs.

@Test
public void shouldBeAbleToListAllSCMMaterialConfigs() {
    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<MaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableSCMMaterials();
    assertThat(schedulableDependencyMaterials.size(), is(2));
    assertTrue(schedulableDependencyMaterials.contains(svnMaterialConfig));
    assertTrue(schedulableDependencyMaterials.contains(pluggableSCMMaterialConfig));
}
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 59 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigServiceTest method shouldFindMaterialConfigBasedOnFingerprint.

@Test
public void shouldFindMaterialConfigBasedOnFingerprint() throws Exception {
    SvnMaterialConfig expected = svn("repo", null, null, false);
    cruiseConfig = configWith(GoConfigMother.createPipelineConfigWithMaterialConfig(expected));
    when(goConfigDao.load()).thenReturn(cruiseConfig);
    MaterialConfig actual = goConfigService.materialForPipelineWithFingerprint("pipeline", expected.getFingerprint());
    assertThat(actual, is(expected));
}
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) Test(org.junit.jupiter.api.Test)

Example 60 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class GoConfigFileHelper method addMaterialToPipeline.

public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
    CruiseConfig config = loadForEdit();
    PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    for (MaterialConfig materialConfig1 : new MaterialConfig[] { materialConfig }) {
        pipelineConfig.addMaterialConfig(materialConfig1);
    }
    writeConfigFile(config);
    return pipelineConfig;
}
Also used : MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12