Search in sources :

Example 96 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class ReportingFanInGraph method buildRestOfTheGraph.

private void buildRestOfTheGraph(ReportingDependencyFanInNode root, PipelineConfig target, HashSet<String> scmMaterialSet) {
    for (MaterialConfig material : target.materialConfigs()) {
        ReportingFanInNode node = createNode(material);
        root.children.add(node);
        node.parents.add(root);
        if (node instanceof ReportingDependencyFanInNode) {
            DependencyMaterialConfig dependencyMaterial = (DependencyMaterialConfig) material;
            fingerprintDepMaterialMap.put(dependencyMaterial.getFingerprint(), dependencyMaterial);
            handleDependencyMaterial(scmMaterialSet, dependencyMaterial, (ReportingDependencyFanInNode) node);
        } else {
            handleScmMaterial(scmMaterialSet, material);
        }
    }
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 97 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineConfigValidationTest method shouldFailValidateWhenUpstreamStageForDependencyMaterailDoesNotExist.

@Test
public void shouldFailValidateWhenUpstreamStageForDependencyMaterailDoesNotExist() {
    String upstreamPipeline = "upstream";
    String upstreamStage = "non-existant";
    PipelineConfig upstream = GoConfigMother.createPipelineConfigWithMaterialConfig(upstreamPipeline, new GitMaterialConfig("url"));
    PipelineConfig pipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig("downstream", new DependencyMaterialConfig(new CaseInsensitiveString(upstreamPipeline), new CaseInsensitiveString(upstreamStage)));
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig, upstream));
    boolean isValid = pipelineConfig.validateTree(PipelineConfigSaveValidationContext.forChain(true, cruiseConfig.getGroups().first().getGroup(), cruiseConfig, pipelineConfig));
    assertThat(isValid, is(false));
    ConfigErrors materialErrors = pipelineConfig.materialConfigs().first().errors();
    assertThat(materialErrors.isEmpty(), is(false));
    assertThat(materialErrors.firstError(), is("Stage with name 'non-existant' does not exist on pipeline 'upstream', it is being referred to from pipeline 'downstream' (cruise-config.xml)"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 98 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineConfigValidationTest method shouldBeValidIfTheReferencedPipelineExists.

@Test
public void shouldBeValidIfTheReferencedPipelineExists() throws Exception {
    pipeline.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage")));
    pipeline.validate(validationContext);
    assertThat(pipeline.errors().isEmpty(), is(true));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 99 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class FetchTaskTest method shouldNotFailValidationIfUpstreamExists_PipelineConfigSave.

@Test
public void shouldNotFailValidationIfUpstreamExists_PipelineConfigSave() {
    PipelineConfig upstream = new PipelineConfig(new CaseInsensitiveString("upstream-pipeline"), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString("upstream-stage"), new JobConfigs(new JobConfig(new CaseInsensitiveString("upstream-job")))));
    JobConfig job = new JobConfig(new CaseInsensitiveString("downstream-job"));
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("upstream-stage"), new CaseInsensitiveString("upstream-job"), "quux.c", "bang-file");
    job.addTask(fetchTask);
    PipelineConfig downstream = new PipelineConfig(new CaseInsensitiveString("downstream-pipeline"), new MaterialConfigs(new DependencyMaterialConfig(upstream.name(), upstream.getFirstStageConfig().name())), new StageConfig(new CaseInsensitiveString("downstream-stage"), new JobConfigs(job)));
    fetchTask.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new BasicCruiseConfig(new BasicPipelineConfigs(upstream, downstream)), downstream, downstream.getFirstStageConfig(), downstream.getFirstStageConfig().getJobs().first()));
    assertThat(fetchTask.errors().isEmpty(), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 100 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class FetchTaskTest method shouldFailValidationIfFetchArtifactPipelineAndStageExistsButJobDoesNot_PipelineConfigSave.

@Test
public void shouldFailValidationIfFetchArtifactPipelineAndStageExistsButJobDoesNot_PipelineConfigSave() {
    PipelineConfig upstream = new PipelineConfig(new CaseInsensitiveString("upstream-pipeline"), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString("upstream-stage"), new JobConfigs(new JobConfig(new CaseInsensitiveString("upstream-job")))));
    JobConfig job = new JobConfig(new CaseInsensitiveString("downstream-job"));
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("upstream-stage"), new CaseInsensitiveString("some-random-job"), "quux.c", "bang-file");
    job.addTask(fetchTask);
    PipelineConfig downstream = new PipelineConfig(new CaseInsensitiveString("downstream-pipeline"), new MaterialConfigs(new DependencyMaterialConfig(upstream.name(), upstream.getFirstStageConfig().name())), new StageConfig(new CaseInsensitiveString("downstream-stage"), new JobConfigs(job)));
    fetchTask.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new BasicCruiseConfig(new BasicPipelineConfigs(upstream, downstream)), downstream, downstream.getFirstStageConfig(), downstream.getFirstStageConfig().getJobs().first()));
    assertThat(fetchTask.errors().isEmpty(), is(false));
    assertThat(fetchTask.errors().on(FetchTask.JOB), is("\"downstream-pipeline :: downstream-stage :: downstream-job\" tries to fetch artifact from job \"upstream-pipeline :: upstream-stage :: some-random-job\" which does not exist."));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 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