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."));
}
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));
}
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));
}
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."));
}
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;
}
Aggregations