Search in sources :

Example 1 with NewGoConfigMother

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)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) NewGoConfigMother(com.thoughtworks.go.domain.materials.dependency.NewGoConfigMother) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 2 with NewGoConfigMother

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")));
}
Also used : NewGoConfigMother(com.thoughtworks.go.domain.materials.dependency.NewGoConfigMother) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 NewGoConfigMother (com.thoughtworks.go.domain.materials.dependency.NewGoConfigMother)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Test (org.junit.Test)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)1