Search in sources :

Example 11 with MaterialConfigs

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

the class PipelineConfigValidationTest method shouldAddValidationErrorsFromStagesOntoPipelineIfPipelineIsAssociatedToATemplate.

@Test
public void shouldAddValidationErrorsFromStagesOntoPipelineIfPipelineIsAssociatedToATemplate() {
    BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2", "p3");
    PipelineConfig p1 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p1"));
    PipelineConfig p2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p2"));
    PipelineConfig p3 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3"));
    p2.addMaterialConfig(new DependencyMaterialConfig(p1.name(), p1.first().name()));
    p3.addMaterialConfig(new DependencyMaterialConfig(p2.name(), p2.first().name()));
    p3.first().getJobs().first().addTask(new FetchTask(new CaseInsensitiveString("p1/p2"), p1.first().name(), p1.first().getJobs().first().name(), "src", "dest"));
    StageConfig stageConfig = new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig(new CaseInsensitiveString("new-job"))));
    PipelineConfig pipelineConfig = new PipelineConfig(p1.name(), new MaterialConfigs(), stageConfig);
    String group = cruiseConfig.getGroups().first().getGroup();
    cruiseConfig.update(group, pipelineConfig.name().toString(), pipelineConfig);
    PipelineConfigSaveValidationContext validationContext = PipelineConfigSaveValidationContext.forChain(false, group, cruiseConfig, pipelineConfig);
    pipelineConfig.validateTree(validationContext);
    assertThat(pipelineConfig.errors().on("base"), is("\"p3 :: stage :: job\" tries to fetch artifact from job \"p1 :: stage :: 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)

Example 12 with MaterialConfigs

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

the class ModificationBuildCauseTest method shouldBeValidWithExternalMaterials.

@Test
public void shouldBeValidWithExternalMaterials() {
    SvnMaterial mainRepo = MaterialsMother.svnMaterial("mainRepo");
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(mainRepo, multipleModificationList());
    revisions.addRevision(MaterialsMother.svnMaterial("externalRepo"), multipleModificationList());
    buildCause = BuildCause.createWithModifications(revisions, "");
    buildCause.assertMaterialsMatch(new MaterialConfigs(mainRepo.config()));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 13 with MaterialConfigs

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

the class ModificationBuildCauseTest method shouldBeInvalidWhenMaterialsFromConfigAreNotInBuildCause.

@Test
public void shouldBeInvalidWhenMaterialsFromConfigAreNotInBuildCause() {
    SvnMaterial mainRepo = MaterialsMother.svnMaterial("mainRepo");
    SvnMaterial extRepo = MaterialsMother.svnMaterial("externalRepo");
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(mainRepo, multipleModificationList());
    buildCause = BuildCause.createWithModifications(revisions, "");
    try {
        buildCause.assertMaterialsMatch(new MaterialConfigs(mainRepo.config(), extRepo.config()));
        fail("All the materials from config file should be in build cause");
    } catch (Exception expected) {
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 14 with MaterialConfigs

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

the class BasicCruiseConfig method materialConfigFor.

@Override
public MaterialConfig materialConfigFor(CaseInsensitiveString pipelineName, String fingerprint) {
    PipelineConfig pipelineConfig = pipelineConfigByName(pipelineName);
    MaterialConfigs materialConfigs = pipelineConfig.materialConfigs();
    for (MaterialConfig materialConfig : materialConfigs) {
        if (materialConfig.getFingerprint().equals(fingerprint)) {
            return materialConfig;
        }
    }
    return null;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig)

Example 15 with MaterialConfigs

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

the class ConfigSaveValidationContext method primeForMaterialValidations.

private void primeForMaterialValidations() {
    CruiseConfig cruiseConfig = getCruiseConfig();
    fingerprintToMaterials = new HashMap<>();
    for (PipelineConfig pipelineConfig : cruiseConfig.getAllPipelineConfigs()) {
        for (MaterialConfig material : pipelineConfig.materialConfigs()) {
            String fingerprint = material.getFingerprint();
            if (!fingerprintToMaterials.containsKey(fingerprint)) {
                fingerprintToMaterials.put(fingerprint, new MaterialConfigs());
            }
            MaterialConfigs materialsForFingerprint = fingerprintToMaterials.get(fingerprint);
            materialsForFingerprint.add(material);
        }
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)208 Test (org.junit.Test)160 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)40 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)30 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)26 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)22 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)18 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)18 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 Material (com.thoughtworks.go.domain.materials.Material)13 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)12 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)12 ArrayList (java.util.ArrayList)12