Search in sources :

Example 1 with SingletonMap

use of org.apache.commons.collections.map.SingletonMap in project gocd by gocd.

the class ApprovalTest method shouldValidateApprovalType.

@Test
public void shouldValidateApprovalType() throws Exception {
    Approval approval = new Approval();
    approval.setConfigAttributes(new SingletonMap(Approval.TYPE, "not-manual-or-success"));
    assertThat(approval.getType(), is("not-manual-or-success"));
    approval.validate(ConfigSaveValidationContext.forChain(new BasicCruiseConfig(), new BasicPipelineConfigs()));
    assertThat(approval.errors().firstError(), is("You have defined approval type as 'not-manual-or-success'. Approval can only be of the type 'manual' or 'success'."));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) Test(org.junit.Test)

Example 2 with SingletonMap

use of org.apache.commons.collections.map.SingletonMap in project gocd by gocd.

the class ApprovalTest method shouldNotAssignType.

@Test
public void shouldNotAssignType() throws Exception {
    Approval approval = new Approval();
    approval.setConfigAttributes(new SingletonMap(Approval.TYPE, Approval.SUCCESS));
    assertThat(approval.getType(), is(Approval.SUCCESS));
    approval.setConfigAttributes(new HashMap());
    assertThat(approval.getType(), is(Approval.SUCCESS));
    approval.setConfigAttributes(new SingletonMap(Approval.TYPE, Approval.MANUAL));
    assertThat(approval.getType(), is(Approval.MANUAL));
    approval.setConfigAttributes(new HashMap());
    assertThat(approval.getType(), is(Approval.MANUAL));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with SingletonMap

use of org.apache.commons.collections.map.SingletonMap in project gocd by gocd.

the class StageConfigTest method shouldSetArtifactCleanupOptOutAttribute.

@Test
public void shouldSetArtifactCleanupOptOutAttribute() throws Exception {
    StageConfig config = new StageConfig();
    assertThat(config.isArtifactCleanupProhibited(), is(false));
    config.setConfigAttributes(new SingletonMap(StageConfig.ARTIFACT_CLEANUP_PROHIBITED, "1"));
    assertThat(config.isArtifactCleanupProhibited(), is(true));
    config.setConfigAttributes(new HashMap());
    assertThat(config.isArtifactCleanupProhibited(), is(true));
    config.setConfigAttributes(new SingletonMap(StageConfig.ARTIFACT_CLEANUP_PROHIBITED, "0"));
    assertThat(config.isArtifactCleanupProhibited(), is(false));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with SingletonMap

use of org.apache.commons.collections.map.SingletonMap in project gocd by gocd.

the class StageConfigTest method shouldSetPrimitiveAttributes.

@Test
public void shouldSetPrimitiveAttributes() throws Exception {
    StageConfig config = new StageConfig();
    config.setConfigAttributes(new SingletonMap(StageConfig.NAME, "foo_bar"));
    config.setConfigAttributes(new SingletonMap(StageConfig.FETCH_MATERIALS, "0"));
    config.setConfigAttributes(new SingletonMap(StageConfig.CLEAN_WORKING_DIR, "1"));
    assertThat(config.name(), is(new CaseInsensitiveString("foo_bar")));
    assertThat(config.isFetchMaterials(), is(false));
    assertThat(config.isCleanWorkingDir(), is(true));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) Test(org.junit.Test)

Example 5 with SingletonMap

use of org.apache.commons.collections.map.SingletonMap in project gocd by gocd.

the class MergeEnvironmentConfigTest method shouldUpdateEnvironmentVariablesWhenSourceIsEditable.

@Test
public void shouldUpdateEnvironmentVariablesWhenSourceIsEditable() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    uatLocalPart.addEnvironmentVariable("hello", "world");
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    environmentConfig.setConfigAttributes(new SingletonMap(BasicEnvironmentConfig.VARIABLES_FIELD, Arrays.asList(envVar("foo", "bar"), envVar("baz", "quux"), envVar("hello", "you"))));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat(environmentConfig.getVariables().size(), is(3));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables().size(), is(3));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Aggregations

SingletonMap (org.apache.commons.collections.map.SingletonMap)15 Test (org.junit.Test)15 HashMap (java.util.HashMap)5 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)1 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)1 Map (java.util.Map)1