Search in sources :

Example 21 with ErrorCollection

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

the class CRPipelineTest method shouldCheckErrorsInStages.

@Test
public void shouldCheckErrorsInStages() {
    CRPipeline p = new CRPipeline();
    p.setName("pipe4");
    // plugin may voluntarily set this
    p.setLocation("pipe4.json");
    CRStage invalidSameEnvironmentVariableTwice = new CRStage("bla");
    invalidSameEnvironmentVariableTwice.addEnvironmentVariable("key", "value1");
    invalidSameEnvironmentVariableTwice.addEnvironmentVariable("key", "value2");
    p.addStage(invalidSameEnvironmentVariableTwice);
    ErrorCollection errors = new ErrorCollection();
    p.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("Pipeline pipe4; Stage (bla)"));
    assertThat(fullError, contains("Stage has no jobs"));
    assertThat(fullError, contains("Environment variable key defined more than once"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 22 with ErrorCollection

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

the class CRPipelineTest method shouldCheckErrorsInMaterials.

@Test
public void shouldCheckErrorsInMaterials() {
    CRPipeline p = new CRPipeline();
    p.setName("pipe4");
    CRGitMaterial invalidGit = new CRGitMaterial("gitMaterial1", "dir1", false, true, null, "feature12", false, "externals", "tools");
    p.addMaterial(invalidGit);
    // plugin may voluntarily set this
    p.setLocation("pipe4.json");
    ErrorCollection errors = new ErrorCollection();
    p.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("Pipeline pipe4; Git material"));
    assertThat(fullError, contains("Missing field 'url'"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) CRGitMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial) Test(org.junit.Test)

Example 23 with ErrorCollection

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

the class CRPipelineTest method shouldCheckMissingDestinationDirectoryWhenManySCMs.

@Test
public void shouldCheckMissingDestinationDirectoryWhenManySCMs() {
    CRPipeline p = new CRPipeline();
    p.setName("pipe4");
    CRGitMaterial simpleGit1 = new CRGitMaterial();
    simpleGit1.setUrl("url1");
    CRGitMaterial simpleGit2 = new CRGitMaterial();
    simpleGit2.setUrl("url2");
    p.addMaterial(simpleGit1);
    p.addMaterial(simpleGit2);
    ErrorCollection errors = new ErrorCollection();
    p.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("Pipeline pipe4; Git material"));
    assertThat(fullError, contains("Material must have destination directory when there are many SCM materials"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) CRGitMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial) Test(org.junit.Test)

Example 24 with ErrorCollection

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

the class CRPropertyGeneratorTest method shouldDeserializeFromAPILikeObject.

@Test
public void shouldDeserializeFromAPILikeObject() {
    String json = "{\n" + "      \"name\": \"coverage.class\",\n" + "      \"source\": \"target/emma/coverage.xml\",\n" + "      \"xpath\": \"substring-before(//report/data/all/coverage[starts-with(@type,'class')]/@value, '%')\"\n" + "    }";
    CRPropertyGenerator deserializedValue = gson.fromJson(json, CRPropertyGenerator.class);
    assertThat(deserializedValue.getName(), is("coverage.class"));
    assertThat(deserializedValue.getSrc(), is("target/emma/coverage.xml"));
    assertThat(deserializedValue.getXpath(), is("substring-before(//report/data/all/coverage[starts-with(@type,'class')]/@value, '%')"));
    ErrorCollection errors = deserializedValue.getErrors();
    assertTrue(errors.isEmpty());
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Test(org.junit.Test)

Example 25 with ErrorCollection

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

the class CRBase method getErrors.

public // shorthand for tests
ErrorCollection getErrors() {
    ErrorCollection errors = new ErrorCollection();
    getErrors(errors, "Unknown");
    return errors;
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection)

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