use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class ConfigRepoCommand method isValid.
@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
validateConfigRepoId(this.configRepo);
validateConfigRepoPluginId(this.configRepo);
if (!this.configRepo.errors().isEmpty()) {
return false;
}
preprocessedConfigRepo = preprocessedConfig.getConfigRepos().getConfigRepo(this.configRepo.getId());
preprocessedConfigRepo.validateTree(new ConfigSaveValidationContext(preprocessedConfig));
List<ConfigErrors> allErrors = ErrorCollector.getAllErrors(preprocessedConfigRepo);
if (!allErrors.isEmpty()) {
BasicCruiseConfig.copyErrors(preprocessedConfigRepo, configRepo);
return false;
}
return true;
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class UpdatePipelineConfigCommandTest method updatePipelineConfigShouldValidateAllExternalArtifacts.
@Test
void updatePipelineConfigShouldValidateAllExternalArtifacts() {
PluggableArtifactConfig s3 = mock(PluggableArtifactConfig.class);
PluggableArtifactConfig docker = mock(PluggableArtifactConfig.class);
when(goConfigService.artifactStores()).thenReturn(mock(ArtifactStores.class));
when(goConfigService.findGroupNameByPipeline(new CaseInsensitiveString("P1"))).thenReturn("group");
ConfigErrors configErrors = new ConfigErrors();
when(s3.errors()).thenReturn(configErrors);
when(docker.errors()).thenReturn(configErrors);
JobConfig job1 = JobConfigMother.jobWithNoResourceRequirement();
JobConfig job2 = JobConfigMother.jobWithNoResourceRequirement();
job1.artifactTypeConfigs().add(s3);
job2.artifactTypeConfigs().add(docker);
PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("P1", new StageConfig(new CaseInsensitiveString("S1"), new JobConfigs(job1)), new StageConfig(new CaseInsensitiveString("S2"), new JobConfigs(job2)));
UpdatePipelineConfigCommand command = new UpdatePipelineConfigCommand(goConfigService, null, pipeline, "group", username, "stale_digest", localizedOperationResult, externalArtifactsService);
BasicCruiseConfig preprocessedConfig = GoConfigMother.defaultCruiseConfig();
preprocessedConfig.addPipelineWithoutValidation("group", pipeline);
command.isValid(preprocessedConfig);
verify(externalArtifactsService).validateExternalArtifactConfig(eq(s3), any(), eq(true));
verify(externalArtifactsService).validateExternalArtifactConfig(eq(docker), any(), eq(true));
}
Aggregations