Search in sources :

Example 1 with ParamConfig

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;
}
Also used : ParamConfig(com.thoughtworks.go.config.ParamConfig)

Example 2 with ParamConfig

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

Example 3 with ParamConfig

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

Example 4 with ParamConfig

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

Example 5 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