use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial 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."));
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial 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"));
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial in project gocd by gocd.
the class CRPipeline method getErrors.
@Override
public void getErrors(ErrorCollection errors, String parentLocation) {
String location = this.getLocation(parentLocation);
errors.checkMissing(location, "name", name);
errors.checkMissing(location, "group", group);
errors.checkMissing(location, "materials", materials);
validateAtLeastOneMaterial(errors, location);
if (materials != null) {
for (CRMaterial material : this.materials) {
material.getErrors(errors, location);
}
if (materials.size() > 1) {
validateMaterialNameUniqueness(errors, location);
validateScmMaterials(errors, location);
}
}
validateTemplateOrStages(errors, location);
if (!hasTemplate()) {
validateAtLeastOneStage(errors, location);
if (stages != null) {
for (CRStage stage : this.stages) {
stage.getErrors(errors, location);
}
if (stages.size() > 1) {
validateStageNameUniqueness(errors, location);
}
}
}
validateEnvironmentVariableUniqueness(errors, location);
validateParamNameUniqueness(errors, location);
validateLockBehaviorValue(errors, location);
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial in project gocd by gocd.
the class CRPipelineTest method shouldHandlePolymorphismWhenDeserializingJobs.
@Test
public void shouldHandlePolymorphismWhenDeserializingJobs() {
String json = gson.toJson(pipe1);
CRPipeline deserializedValue = gson.fromJson(json, CRPipeline.class);
CRMaterial git = deserializedValue.getMaterialByName("gitMaterial1");
assertThat(git instanceof CRGitMaterial, is(true));
assertThat(((CRGitMaterial) git).getBranch(), is("feature12"));
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial 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."));
}
Aggregations