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