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