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'."));
}
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));
}
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));
}
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));
}
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));
}
Aggregations