use of com.thoughtworks.go.domain.materials.dependency.NewGoConfigMother 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)));
}
use of com.thoughtworks.go.domain.materials.dependency.NewGoConfigMother in project gocd by gocd.
the class DependencyMaterialConfigTest method shouldBeAbleToSaveADependencyMaterialToConfig.
@Test
public void shouldBeAbleToSaveADependencyMaterialToConfig() throws Exception {
DependencyMaterialConfig originalMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
NewGoConfigMother mother = new NewGoConfigMother();
mother.addPipeline("pipeline-name", "stage-name", "job-name");
mother.addPipeline("dependent", "stage-name", "job-name").addMaterialConfig(originalMaterial);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.write(mother.cruiseConfig(), buffer, false);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.toByteArray());
CruiseConfig config = loader.loadConfigHolder(FileUtil.readToEnd(inputStream)).config;
DependencyMaterialConfig material = (DependencyMaterialConfig) config.pipelineConfigByName(new CaseInsensitiveString("dependent")).materialConfigs().get(1);
assertThat(material, is(originalMaterial));
assertThat(material.getPipelineName(), is(new CaseInsensitiveString("pipeline-name")));
assertThat(material.getStageName(), is(new CaseInsensitiveString("stage-name")));
}
Aggregations