Search in sources :

Example 11 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) Test(org.junit.Test)

Example 12 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 13 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 14 with SingletonMap

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

the class StageConfigTest method shouldSetApprovalFromConfigAttrs.

@Test
public void shouldSetApprovalFromConfigAttrs() throws Exception {
    StageConfig config = new StageConfig();
    config.setConfigAttributes(new SingletonMap(StageConfig.APPROVAL, new SingletonMap(Approval.TYPE, Approval.MANUAL)));
    assertThat(config.getApproval().getType(), is(Approval.MANUAL));
    config.setConfigAttributes(new HashMap());
    assertThat(config.getApproval().getType(), is(Approval.MANUAL));
    config.setConfigAttributes(new SingletonMap(StageConfig.APPROVAL, new SingletonMap(Approval.TYPE, Approval.SUCCESS)));
    assertThat(config.getApproval().getType(), is(Approval.SUCCESS));
    config.setConfigAttributes(new HashMap());
    assertThat(config.getApproval().getType(), is(Approval.SUCCESS));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) Test(org.junit.Test)

Example 15 with SingletonMap

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

the class MingleConfigTest method shouldSetMingleConfigFromConfigAttributes.

@Test
public void shouldSetMingleConfigFromConfigAttributes() {
    MingleConfig mingleConfig = new MingleConfig();
    Map configMap = new HashMap();
    configMap.put(MingleConfig.BASE_URL, "http://mingle01.tw.com/mingle");
    configMap.put(MingleConfig.PROJECT_IDENTIFIER, "go");
    configMap.put(MingleConfig.MQL_GROUPING_CONDITIONS, new SingletonMap(MqlCriteria.MQL, "Some MQL"));
    mingleConfig.setConfigAttributes(configMap);
    assertThat(mingleConfig.getBaseUrl(), is("http://mingle01.tw.com/mingle"));
    assertThat(mingleConfig.getProjectIdentifier(), is("go"));
    assertThat(mingleConfig.getMqlCriteria().getMql(), is("Some MQL"));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) HashMap(java.util.HashMap) MingleConfig(com.thoughtworks.go.config.MingleConfig) Map(java.util.Map) HashMap(java.util.HashMap) SingletonMap(org.apache.commons.collections.map.SingletonMap) Test(org.junit.Test)

Aggregations

SingletonMap (org.apache.commons.collections.map.SingletonMap)15 Test (org.junit.Test)15 HashMap (java.util.HashMap)3 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