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"));
}
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'"));
}
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"));
}
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());
}
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;
}
Aggregations