Search in sources :

Example 6 with ErrorCollection

use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.

the class CRPipelineTest method shouldAddAnErrorWhenBothTemplateAndStagesAreDefined.

@Test
public void shouldAddAnErrorWhenBothTemplateAndStagesAreDefined() throws Exception {
    CRPipeline crPipeline = new CRPipeline("p1", "g1", veryCustomGit, "template", buildStage);
    ErrorCollection errorCollection = new ErrorCollection();
    crPipeline.getErrors(errorCollection, "TEST");
    assertThat(errorCollection.getErrorCount(), is(1));
    assertThat(errorCollection.getErrorsAsText(), contains("Pipeline has to either define stages or template. Not both."));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 7 with ErrorCollection

use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.

the class CRPipelineTest method shouldAddAnErrorForDuplicateParameterNames.

@Test
public void shouldAddAnErrorForDuplicateParameterNames() throws Exception {
    ArrayList<CRMaterial> materials = new ArrayList<>();
    materials.add(veryCustomGit);
    ArrayList<CRParameter> crParameters = new ArrayList<>();
    crParameters.add(new CRParameter("param1", "value1"));
    crParameters.add(new CRParameter("param1", "value2"));
    CRPipeline crPipeline = new CRPipeline("p1", "g1", "label", LOCK_VALUE_LOCK_ON_FAILURE, null, null, null, new ArrayList<>(), materials, null, "t1", crParameters);
    ErrorCollection errors = new ErrorCollection();
    crPipeline.getErrors(errors, "TEST");
    assertThat(errors.getErrorsAsText(), contains("Param name 'param1' is not unique."));
}
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)

Example 8 with ErrorCollection

use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.

the class CRPipelineTest method shouldAddAnErrorForDuplicateEnvironmentVariables.

@Test
public void shouldAddAnErrorForDuplicateEnvironmentVariables() throws Exception {
    ArrayList<CRMaterial> materials = new ArrayList<>();
    materials.add(veryCustomGit);
    ArrayList<CREnvironmentVariable> crEnvironmentVariables = new ArrayList<>();
    crEnvironmentVariables.add(new CREnvironmentVariable("env1", "value1"));
    crEnvironmentVariables.add(new CREnvironmentVariable("env1", "value2"));
    CRPipeline crPipeline = new CRPipeline("p1", "g1", "label", LOCK_VALUE_LOCK_ON_FAILURE, null, null, null, crEnvironmentVariables, materials, null, "t1", new ArrayList<>());
    ErrorCollection errors = new ErrorCollection();
    crPipeline.getErrors(errors, "TEST");
    assertThat(errors.getErrorsAsText(), contains("Environment variable env1 defined more than once"));
}
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)

Example 9 with ErrorCollection

use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.

the class CRPipelineTest method shouldAddAnErrorIfLockBehaviorValueIsInvalid.

@Test
public void shouldAddAnErrorIfLockBehaviorValueIsInvalid() throws Exception {
    CRPipeline validPipelineWithInvalidLockBehaviorOnly = new CRPipeline("pipe1", "group1", null, "INVALID_LOCK_VALUE", null, null, null, emptyList(), asList(veryCustomGit), asList(buildStage), null, emptyList());
    ErrorCollection errorCollection = new ErrorCollection();
    validPipelineWithInvalidLockBehaviorOnly.getErrors(errorCollection, "TEST");
    String expectedMessage = "Lock behavior has an invalid value (INVALID_LOCK_VALUE). Valid values are:";
    assertThat(errorCollection.getErrorCount(), is(1));
    assertThat(errorCollection.getOrCreateErrorList(validPipelineWithInvalidLockBehaviorOnly.getLocation("TEST")).get(0), contains(expectedMessage));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 10 with ErrorCollection

use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.

the class CRStageTest method shouldCheckErrorsInJobs.

@Test
public void shouldCheckErrorsInJobs() {
    CRStage withNamelessJob = new CRStage("build", new CRJob());
    ErrorCollection errors = new ErrorCollection();
    withNamelessJob.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("TEST; Stage (build)"));
    assertThat(fullError, contains("Missing field 'name'"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) 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