use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldBeAbleToLoadADependencyMaterialFromConfig.
@Test
public void shouldBeAbleToLoadADependencyMaterialFromConfig() throws Exception {
String xml = "<pipeline pipelineName=\"pipeline-name\" stageName=\"stage-name\" />";
DependencyMaterialConfig material = loader.fromXmlPartial(xml, DependencyMaterialConfig.class);
assertThat(material.getPipelineName(), is(new CaseInsensitiveString("pipeline-name")));
assertThat(material.getStageName(), is(new CaseInsensitiveString("stage-name")));
assertThat(writer.toXmlPartial(material), is(xml));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldNotBombValidationWhenMaterialNameIsNotSet.
@Test
public void shouldNotBombValidationWhenMaterialNameIsNotSet() {
DependencyMaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline-foo"), new CaseInsensitiveString("stage-bar"));
dependencyMaterialConfig.validate(ConfigSaveValidationContext.forChain(new BasicCruiseConfig(), pipelineConfig));
assertThat(dependencyMaterialConfig.errors().on(AbstractMaterialConfig.MATERIAL_NAME), is(nullValue()));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldNOTBeValidIfThePipelineExistsButTheStageDoesNot.
@Test
public void shouldNOTBeValidIfThePipelineExistsButTheStageDoesNot() throws Exception {
DependencyMaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage-not-existing does not exist!"));
dependencyMaterialConfig.validate(ConfigSaveValidationContext.forChain(config, pipelineConfig));
ConfigErrors configErrors = dependencyMaterialConfig.errors();
assertThat(configErrors.isEmpty(), is(false));
assertThat(configErrors.on(DependencyMaterialConfig.PIPELINE_STAGE_NAME), containsString("Stage with name 'stage-not-existing does not exist!' does not exist on pipeline 'pipeline2'"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialConfigTest method setConfigAttributes_shouldPopulateFromConfigAttributes.
@Test
public void setConfigAttributes_shouldPopulateFromConfigAttributes() {
DependencyMaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(new CaseInsensitiveString(""), new CaseInsensitiveString(""));
assertThat(dependencyMaterialConfig.getPipelineStageName(), is(nullValue()));
HashMap<String, String> configMap = new HashMap<>();
configMap.put(AbstractMaterialConfig.MATERIAL_NAME, "name1");
configMap.put(DependencyMaterialConfig.PIPELINE_STAGE_NAME, "pipeline-1 [stage-1]");
dependencyMaterialConfig.setConfigAttributes(configMap);
assertThat(dependencyMaterialConfig.getMaterialName(), is(new CaseInsensitiveString("name1")));
assertThat(dependencyMaterialConfig.getPipelineName(), is(new CaseInsensitiveString("pipeline-1")));
assertThat(dependencyMaterialConfig.getStageName(), is(new CaseInsensitiveString("stage-1")));
assertThat(dependencyMaterialConfig.getPipelineStageName(), is("pipeline-1 [stage-1]"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldBeAbleToHaveADependencyAndOneOtherMaterial.
@Test
public void shouldBeAbleToHaveADependencyAndOneOtherMaterial() throws Exception {
NewGoConfigMother mother = new NewGoConfigMother();
mother.addPipeline("pipeline-name", "stage-name", "job-name");
PipelineConfig pipelineConfig = mother.addPipeline("dependent", "stage-name", "job-name", new DependencyMaterialConfig(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name")));
pipelineConfig.addMaterialConfig(new P4MaterialConfig("localhost:1666", "foo"));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
CruiseConfig cruiseConfig = mother.cruiseConfig();
writer.write(cruiseConfig, buffer, false);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.toByteArray());
CruiseConfig config = loader.loadConfigHolder(FileUtil.readToEnd(inputStream)).config;
MaterialConfigs materialConfigs = config.pipelineConfigByName(new CaseInsensitiveString("dependent")).materialConfigs();
assertThat(materialConfigs.get(0), is(instanceOf(DependencyMaterialConfig.class)));
assertThat(materialConfigs.get(1), is(instanceOf(P4MaterialConfig.class)));
}
Aggregations