Search in sources :

Example 11 with DependencyMaterialConfig

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));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 12 with DependencyMaterialConfig

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()));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 13 with DependencyMaterialConfig

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

Example 14 with DependencyMaterialConfig

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]"));
}
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 15 with DependencyMaterialConfig

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)));
}
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)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)131 Test (org.junit.Test)83 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)13 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