use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class MingleConfigTest method shouldReturnInvalidIfTheURLIsNotAHTTPSURL.
@Test
public void shouldReturnInvalidIfTheURLIsNotAHTTPSURL() {
MingleConfig mingleConfig = new MingleConfig("http://some-mingle-instance", "go");
mingleConfig.validate(new ConfigSaveValidationContext(null));
assertThat(mingleConfig.errors().isEmpty(), is(false));
assertThat(mingleConfig.errors().on(MingleConfig.PROJECT_IDENTIFIER), is(nullValue()));
assertThat(mingleConfig.errors().on(MingleConfig.BASE_URL), is("Should be a URL starting with https://"));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class PackageMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveAPackageId.
@Test
public void shouldAddErrorIfMaterialDoesNotHaveAPackageId() throws Exception {
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig();
packageMaterialConfig.validateConcreteMaterial(new ConfigSaveValidationContext(null, null));
assertThat(packageMaterialConfig.errors().getAll().size(), is(1));
assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Please select a repository and package"));
}
use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.
the class SvnMaterialConfigTest method validate_shouldEnsureMaterialNameIsValid.
@Test
public void validate_shouldEnsureMaterialNameIsValid() {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("/foo", "", "", false);
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on(SvnMaterialConfig.MATERIAL_NAME), is(nullValue()));
svnMaterialConfig.setName(new CaseInsensitiveString(".bad-name-with-dot"));
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on(SvnMaterialConfig.MATERIAL_NAME), is("Invalid material name '.bad-name-with-dot'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
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 PluggableSCMMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveASCMId.
@Test
public void shouldAddErrorIfMaterialDoesNotHaveASCMId() throws Exception {
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig();
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"));
}
Aggregations