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());
}
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;
}
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);
}
}
}
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."));
}
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));
}
Aggregations