Search in sources :

Example 36 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class SCMTest method shouldValidateIfNameIsMissing.

@Test
void shouldValidateIfNameIsMissing() {
    SCM scm = new SCM();
    scm.validate(new ConfigSaveValidationContext(new BasicCruiseConfig(), null));
    assertThat(scm.errors().getAllOn(SCM.NAME)).isEqualTo(asList("Please provide name"));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 37 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext 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;
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors)

Example 38 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class CreateOrUpdateBackupConfigCommand method isValid.

@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
    preprocessedEntityConfig = preprocessedConfig.server().getBackupConfig();
    preprocessedEntityConfig.validate(new ConfigSaveValidationContext(preprocessedConfig));
    if (preprocessedEntityConfig.errors().present()) {
        BasicCruiseConfig.copyErrors(preprocessedEntityConfig, newBackupConfig);
        return false;
    } else {
        return true;
    }
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext)

Aggregations

ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)38 Test (org.junit.Test)18 Test (org.junit.jupiter.api.Test)10 GoCipher (com.thoughtworks.go.security.GoCipher)9 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)7 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 PipelineConfigSaveValidationContext (com.thoughtworks.go.config.PipelineConfigSaveValidationContext)3 ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 Agents (com.thoughtworks.go.config.Agents)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 SCM (com.thoughtworks.go.domain.scm.SCM)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1