use of com.thoughtworks.go.config.ParamConfig in project gocd by gocd.
the class ParamConfigTest method createAndValidate.
private ParamConfig createAndValidate(final String name) {
ParamConfig config = new ParamConfig(name, "value");
config.validate(null);
return config;
}
use of com.thoughtworks.go.config.ParamConfig in project gocd by gocd.
the class ParamConfigTest method shouldReturnValueForDisplay.
@Test
public void shouldReturnValueForDisplay() {
ParamConfig paramConfig = new ParamConfig("foo", "bar");
assertThat(paramConfig.getValueForDisplay(), is("bar"));
}
use of com.thoughtworks.go.config.ParamConfig in project gocd by gocd.
the class ParamConfigTest method shouldValidateName.
@Test
public void shouldValidateName() {
ParamConfig paramConfig = new ParamConfig();
ValidationContext validationContext = mock(ValidationContext.class);
when(validationContext.getPipeline()).thenReturn(new PipelineConfig(new CaseInsensitiveString("p"), null));
paramConfig.validateName(new HashMap<>(), validationContext);
assertThat(paramConfig.errors().on(ParamConfig.NAME), is("Parameter cannot have an empty name for pipeline 'p'."));
}
use of com.thoughtworks.go.config.ParamConfig in project gocd by gocd.
the class ParamsConfigTest method shouldThrowAnErrorWhenNameIsEmpty.
@Test
public void shouldThrowAnErrorWhenNameIsEmpty() {
paramsConfig = new ParamsConfig();
ParamConfig empty = new ParamConfig("", "value");
paramsConfig.add(empty);
paramsConfig.validate(context);
assertThat(empty.errors().isEmpty(), is(false));
assertThat(empty.errors().firstError(), contains("Parameter cannot have an empty name for pipeline 'some-pipeline'."));
}
use of com.thoughtworks.go.config.ParamConfig in project gocd by gocd.
the class ParamsConfigTest method shouldThrowAnErrorWhenDuplicateNameIsInserted.
@Test
public void shouldThrowAnErrorWhenDuplicateNameIsInserted() {
paramsConfig = new ParamsConfig();
ParamConfig one = new ParamConfig("name", "value");
paramsConfig.add(one);
ParamConfig two = new ParamConfig("name", "other-value");
paramsConfig.add(two);
paramsConfig.validate(context);
assertThat(one.errors().isEmpty(), is(false));
assertThat(one.errors().firstError(), contains("Param name 'name' is not unique for pipeline 'some-pipeline'."));
assertThat(two.errors().isEmpty(), is(false));
assertThat(two.errors().firstError(), contains("Param name 'name' is not unique for pipeline 'some-pipeline'."));
}
Aggregations