Search in sources :

Example 16 with ConfigSaveValidationContext

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

the class SCMTest method shouldValidateIfNameIsMissing.

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

Example 17 with ConfigSaveValidationContext

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

the class PluggableSCMMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveASCMId.

@Test
public void shouldAddErrorIfMaterialDoesNotHaveASCMId() throws Exception {
    pluggableSCMMaterialConfig.setScmId(null);
    pluggableSCMMaterialConfig.validateConcreteMaterial(new ConfigSaveValidationContext(null, null));
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Please select a SCM"));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext)

Example 18 with ConfigSaveValidationContext

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

the class PluggableSCMMaterialConfigTest method shouldAddErrorIDestinationIsNotValid.

@Test
public void shouldAddErrorIDestinationIsNotValid() throws Exception {
    ConfigSaveValidationContext configSaveValidationContext = mock(ConfigSaveValidationContext.class);
    SCM scmConfig = mock(SCM.class);
    when(configSaveValidationContext.findScmById(anyString())).thenReturn(scmConfig);
    when(scmConfig.doesPluginExist()).thenReturn(true);
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "/usr/home", null);
    pluggableSCMMaterialConfig.setScmId("scm-id");
    pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Dest folder '/usr/home' is not valid. It must be a sub-directory of the working folder."));
    pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "./../crap", null);
    pluggableSCMMaterialConfig.setScmId("scm-id");
    pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(2));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Invalid directory name './../crap'. It should be a valid relative path."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 19 with ConfigSaveValidationContext

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

the class ScmMaterialConfigTest method shouldNotValidateEmptyDestinationFolder.

@Test
public void shouldNotValidateEmptyDestinationFolder() {
    material.setConfigAttributes(Collections.singletonMap(FOLDER, ""));
    material.validate(new ConfigSaveValidationContext(null));
    assertThat(material.errors.isEmpty(), is(true));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 20 with ConfigSaveValidationContext

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

the class GitMaterialConfigTest method validate_shouldEnsureUrlIsNotBlank.

@Test
public void validate_shouldEnsureUrlIsNotBlank() {
    GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("");
    gitMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(gitMaterialConfig.errors().on(GitMaterialConfig.URL), is("URL cannot be blank"));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Aggregations

ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)30 Test (org.junit.Test)25 GoCipher (com.thoughtworks.go.security.GoCipher)9 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)7 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)3 PipelineConfigSaveValidationContext (com.thoughtworks.go.config.PipelineConfigSaveValidationContext)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 Agents (com.thoughtworks.go.config.Agents)1 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)1 SCM (com.thoughtworks.go.domain.scm.SCM)1