use of com.thoughtworks.go.config.ParamsConfig 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.ParamsConfig in project gocd by gocd.
the class ParamsConfigTest method getIndex_shouldThrowExceptionIfNameNotFound.
@Test
public void getIndex_shouldThrowExceptionIfNameNotFound() {
try {
new ParamsConfig().getIndex(null);
fail("should throw exception if param not found");
} catch (IllegalArgumentException e) {
// ok
}
}
use of com.thoughtworks.go.config.ParamsConfig in project gocd by gocd.
the class ParamsConfigTest method getIndex.
@Test
public void getIndex() {
paramsConfig = new ParamsConfig();
ParamConfig one = new ParamConfig("name", "value");
paramsConfig.add(one);
ParamConfig two = new ParamConfig("other", "other-value");
paramsConfig.add(two);
assertThat(paramsConfig.getIndex("other"), is(1));
assertThat(paramsConfig.getIndex("name"), is(0));
}
use of com.thoughtworks.go.config.ParamsConfig in project gocd by gocd.
the class ParamsConfigTest method shouldPopulateParamFromMapIgnoringEmptyPairs.
@Test
public void shouldPopulateParamFromMapIgnoringEmptyPairs() {
paramsConfig = new ParamsConfig();
List<Map> paramsMap = new ArrayList<>();
paramsMap.add(createParamMap("param-name", "param-value"));
paramsMap.add(createParamMap("", ""));
paramsMap.add(createParamMap("", "bar"));
paramsConfig.setConfigAttributes(paramsMap);
assertThat(paramsConfig.size(), is(2));
assertThat(paramsConfig.getParamNamed("param-name").getValue(), is("param-value"));
}
use of com.thoughtworks.go.config.ParamsConfig 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