Search in sources :

Example 16 with ErrorCollection

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));
    }
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 17 with ErrorCollection

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."));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 18 with ErrorCollection

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."));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 19 with ErrorCollection

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"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 20 with ErrorCollection

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."));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) CRMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ErrorCollection (com.thoughtworks.go.plugin.access.configrepo.ErrorCollection)25 Test (org.junit.Test)24 CRMaterial (com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial)3 ArrayList (java.util.ArrayList)3 CRGitMaterial (com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CRBaseTest (com.thoughtworks.go.plugin.access.configrepo.contract.CRBaseTest)1 CRTimer (com.thoughtworks.go.plugin.access.configrepo.contract.CRTimer)1