use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRBaseTest method shouldErrorWhenBadExample.
@Test
public void shouldErrorWhenBadExample() {
Map<String, T> examples = getBadExamples();
for (Map.Entry<String, T> example : examples.entrySet()) {
ErrorCollection errorCollection = new ErrorCollection();
example.getValue().getErrors(errorCollection, "ErrorWhenBadExampleTest");
assertThat(String.format("Example %s - invalid value should return errors", example.getKey()), errorCollection.isEmpty(), is(false));
}
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRParameterTest method shouldAddAnErrorIfParameterNameIsInvalid.
@Test
public void shouldAddAnErrorIfParameterNameIsInvalid() throws Exception {
CRParameter crParameter = new CRParameter("#$$%@");
ErrorCollection errorCollection = new ErrorCollection();
crParameter.getErrors(errorCollection, "TEST");
assertThat(errorCollection.getErrorsAsText(), contains("Invalid parameter name '#$$%@'. 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.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRParameterTest method shouldAddAnErrorIfParameterNameIsBlank.
@Test
public void shouldAddAnErrorIfParameterNameIsBlank() throws Exception {
CRParameter crParameter = new CRParameter();
ErrorCollection errorCollection = new ErrorCollection();
crParameter.getErrors(errorCollection, "TEST");
assertThat(errorCollection.getErrorsAsText(), contains("Invalid parameter name 'null'. 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.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAppendPrettyLocationInErrors_WhenPipelineHasExplicitLocationField.
@Test
public void shouldAppendPrettyLocationInErrors_WhenPipelineHasExplicitLocationField() {
CRPipeline p = new CRPipeline();
p.setName("pipe4");
p.addMaterial(veryCustomGit);
// plugin may voluntarily set this
p.setLocation("pipe4.json");
ErrorCollection errors = new ErrorCollection();
p.getErrors(errors, "TEST");
String fullError = errors.getErrorsAsText();
assertThat(fullError, contains("pipe4.json; Pipeline pipe4"));
assertThat(fullError, contains("Missing field 'group'"));
assertThat(fullError, contains("Pipeline has no stages"));
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRPipelineTest method shouldAddAnErrorIfNeitherTemplateOrStagesAreDefined.
@Test
public void shouldAddAnErrorIfNeitherTemplateOrStagesAreDefined() throws Exception {
ArrayList<CRMaterial> materials = new ArrayList<>();
materials.add(veryCustomGit);
CRPipeline crPipeline = new CRPipeline("p1", "g1", "label", LOCK_VALUE_LOCK_ON_FAILURE, null, null, null, new ArrayList<>(), materials, new ArrayList<>(), null, new ArrayList<>());
ErrorCollection errorCollection = new ErrorCollection();
crPipeline.getErrors(errorCollection, "TEST");
assertThat(errorCollection.getErrorsAsText(), contains("Pipeline has to define stages or template."));
}
Aggregations