Search in sources :

Example 36 with MaterialConfigs

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

the class ServerHealthServiceTest method globalStateRelatedPipelineNames.

@Test
public void globalStateRelatedPipelineNames() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial();
    CruiseConfig config = new BasicCruiseConfig();
    config.addPipeline("group", PipelineConfigMother.pipelineConfig(PIPELINE_NAME, new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(hgMaterial.config())));
    config.addPipeline("group", PipelineConfigMother.pipelineConfig("pipeline3"));
    serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.invalidConfig()));
    assertTrue((serverHealthService.logs().get(0)).getPipelineNames(config).isEmpty());
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 37 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 38 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)

Example 39 with MaterialConfigs

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

the class AdminRoleTest method shouldThrowExceptionIfRoleNameInStageAuthorizationDoesNotExist.

@Test
public void shouldThrowExceptionIfRoleNameInStageAuthorizationDoesNotExist() {
    AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
    StageConfig stage = StageConfigMother.custom("ft", new AuthConfig(role));
    CruiseConfig config = new BasicCruiseConfig(new BasicPipelineConfigs(new PipelineConfig(new CaseInsensitiveString("pipeline"), new MaterialConfigs(), stage)));
    role.validate(ConfigSaveValidationContext.forChain(config));
    ConfigErrors configErrors = role.errors();
    assertThat(configErrors.isEmpty(), is(false));
    assertThat(configErrors.on(AdminRole.NAME), is("Role \"role2\" does not exist."));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.Test)

Example 40 with MaterialConfigs

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

the class ConfigSaveValidationContextTest method shouldReturnAllMaterialsMatchingTheFingerprint.

@Test
public void shouldReturnAllMaterialsMatchingTheFingerprint() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    HgMaterialConfig hg = new HgMaterialConfig("url", null);
    for (int i = 0; i < 10; i++) {
        PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("pipeline" + i, new MaterialConfigs(hg));
        cruiseConfig.addPipeline("defaultGroup", pipelineConfig);
    }
    ValidationContext context = ConfigSaveValidationContext.forChain(cruiseConfig);
    assertThat(context.getAllMaterialsByFingerPrint(hg.getFingerprint()).size(), is(10));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Test(org.junit.Test)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)218 Test (org.junit.Test)158 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)32 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)25 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)25 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)25 TimeProvider (com.thoughtworks.go.util.TimeProvider)25 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)21 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 Material (com.thoughtworks.go.domain.materials.Material)14 Materials (com.thoughtworks.go.config.materials.Materials)12