Search in sources :

Example 6 with ParamConfig

use of com.thoughtworks.go.config.ParamConfig 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));
}
Also used : ParamsConfig(com.thoughtworks.go.config.ParamsConfig) ParamConfig(com.thoughtworks.go.config.ParamConfig) Test(org.junit.Test)

Example 7 with ParamConfig

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'."));
}
Also used : ParamsConfig(com.thoughtworks.go.config.ParamsConfig) ParamConfig(com.thoughtworks.go.config.ParamConfig) Test(org.junit.Test)

Aggregations

ParamConfig (com.thoughtworks.go.config.ParamConfig)7 Test (org.junit.Test)5 ParamsConfig (com.thoughtworks.go.config.ParamsConfig)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ValidationContext (com.thoughtworks.go.config.ValidationContext)1