use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRArtifactTest method shouldDeserializeFromAPILikeObject.
@Test
public void shouldDeserializeFromAPILikeObject() {
String json = "{\n" + " \"source\": \"test\",\n" + " \"destination\": \"res1\",\n" + " \"type\": \"test\"\n" + " }";
CRArtifact deserializedValue = gson.fromJson(json, CRArtifact.class);
assertThat(deserializedValue.getSource(), is("test"));
assertThat(deserializedValue.getDestination(), is("res1"));
assertThat(deserializedValue.getType(), is(CRArtifactType.test));
ErrorCollection errors = deserializedValue.getErrors();
assertTrue(errors.isEmpty());
}
use of com.thoughtworks.go.plugin.access.configrepo.ErrorCollection in project gocd by gocd.
the class CRBaseTest method shouldGetErrorsWhenDeserializedFromEmptyBlock.
@Test
public void shouldGetErrorsWhenDeserializedFromEmptyBlock() {
String json = "{}";
Class<? extends CRBase> typeOfT = null;
for (T example : getGoodExamples().values()) {
typeOfT = example.getClass();
break;
}
T deserializedValue = (T) gson.fromJson(json, typeOfT);
ErrorCollection errorCollection = new ErrorCollection();
deserializedValue.getErrors(errorCollection, "GetErrorsWhenDeserializedFromEmptyBlockTest");
}
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 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 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"));
}
Aggregations