Search in sources :

Example 71 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldNotAllowAnEmptyDepMaterialWhenOtherMaterialsUseThatPipelineName.

/*
                        Name
        Pipeline X    - Material1           - pipeline1
                      - Material2           - someSvn
                      - DepMaterial1        -  ""       dependant on a pipeline named "pipeline1"
Above scenario allowed
*/
@Test
public void shouldNotAllowAnEmptyDepMaterialWhenOtherMaterialsUseThatPipelineName() throws Exception {
    CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
    SvnMaterialConfig one = new SvnMaterialConfig("svn://abc", "", "", false);
    one.setName(new CaseInsensitiveString("pipeline2"));
    DependencyMaterialConfig invalidOne = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
    MaterialConfigs materials = new MaterialConfigs(one, invalidOne);
    ValidationContext validationContext = ConfigSaveValidationContext.forChain(config);
    materials.validate(validationContext);
    assertThat(invalidOne.errors().isEmpty(), is(false));
    assertThat(invalidOne.errors().on("materialName"), is("You have defined multiple materials called 'pipeline2'." + " Material names are case-insensitive and must be unique. Note that for dependency materials the default materialName is the name of the upstream pipeline. " + "You can override this by setting the materialName explicitly for the upstream pipeline."));
}
Also used : SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 72 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldIgnorePipelineWithEmptyNameInUniquenessCheck.

@Test
public void shouldIgnorePipelineWithEmptyNameInUniquenessCheck() throws Exception {
    CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
    DependencyMaterialConfig one = new DependencyMaterialConfig(new CaseInsensitiveString(""), new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
    DependencyMaterialConfig another = new DependencyMaterialConfig(new CaseInsensitiveString(""), new CaseInsensitiveString("pipeline3"), new CaseInsensitiveString("stage"));
    MaterialConfigs materials = new MaterialConfigs(one, another);
    ValidationContext validationContext = ConfigSaveValidationContext.forChain(config);
    materials.validate(validationContext);
    assertThat(one.errors().isEmpty(), is(true));
    assertThat(another.errors().isEmpty(), is(true));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 73 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldSetDependencyMaterialConfigAttributesForMaterial.

@Test
public void shouldSetDependencyMaterialConfigAttributesForMaterial() {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Map<String, String> hashMap = new HashMap<>();
    hashMap.put(DependencyMaterialConfig.PIPELINE_STAGE_NAME, "blah [foo]");
    Map<String, Object> attributeMap = new HashMap<>();
    attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, DependencyMaterialConfig.TYPE);
    attributeMap.put(DependencyMaterialConfig.TYPE, hashMap);
    materialConfigs.setConfigAttributes(attributeMap);
    assertThat(materialConfigs.size(), is(1));
    DependencyMaterialConfig expected = new DependencyMaterialConfig(new CaseInsensitiveString("blah"), new CaseInsensitiveString("foo"));
    assertThat(materialConfigs.first(), is(expected));
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 74 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldNotAllowMultipleDependenciesForTheSamePipelines.

@Test
public void shouldNotAllowMultipleDependenciesForTheSamePipelines() throws Exception {
    CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
    DependencyMaterialConfig dependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
    DependencyMaterialConfig duplicateDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
    MaterialConfigs materialConfigs = new MaterialConfigs(dependencyMaterial, duplicateDependencyMaterial);
    ValidationContext validationContext = ConfigSaveValidationContext.forChain(config);
    materialConfigs.validate(validationContext);
    ConfigErrors errors = duplicateDependencyMaterial.errors();
    assertThat(errors.isEmpty(), is(false));
    assertThat(errors.on("pipelineStageName"), is("A pipeline can depend on each upstream pipeline only once. Remove one of the occurrences of 'pipeline2' from the current pipeline dependencies."));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.Test)

Example 75 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PartialConfigMother method pipelineWithDependencyMaterial.

public static PartialConfig pipelineWithDependencyMaterial(String name, PipelineConfig upstream, RepoConfigOrigin repoConfig) {
    PartialConfig partialConfig = withPipeline(name, repoConfig);
    PipelineConfig pipeline = partialConfig.getGroups().first().get(0);
    pipeline.materialConfigs().add(new DependencyMaterialConfig(upstream.name(), upstream.first().name()));
    return partialConfig;
}
Also used : PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)11 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)10 Date (java.util.Date)10 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Pipeline (com.thoughtworks.go.domain.Pipeline)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)8 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)7 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7