Example usage for org.apache.commons.collections.map SingletonMap SingletonMap

List of usage examples for org.apache.commons.collections.map SingletonMap SingletonMap

Introduction

In this page you can find the example usage for org.apache.commons.collections.map SingletonMap SingletonMap.

Prototype

public SingletonMap(Object key, Object value) 

Source Link

Document

Constructor specifying the key and value.

Usage

From source file:com.thoughtworks.go.config.materials.ScmMaterialConfigTest.java

@Test
public void shouldSetFilterToNullWhenBlank() {
    material.setFilter(new Filter(new IgnoredFiles("*.*")));
    material.setConfigAttributes(new SingletonMap(ScmMaterialConfig.FILTER, ""));
    assertThat(material.filter(), is(new Filter()));
    assertThat(material.getFilterAsString(), is(""));
}

From source file:com.thoughtworks.go.config.EnvironmentConfigBasicTest.java

@Test
public void shouldUpdateName() {
    environmentConfig.setConfigAttributes(new SingletonMap(BasicEnvironmentConfig.NAME_FIELD, "PROD"));
    assertThat(environmentConfig.name(), is(new CaseInsensitiveString("PROD")));
}

From source file:com.thoughtworks.go.domain.ApprovalTest.java

@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));
}

From source file:com.thoughtworks.go.domain.StageConfigTest.java

@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));
}

From source file:com.thoughtworks.go.domain.ApprovalTest.java

@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(ValidationContext.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'."));
}

From source file:com.thoughtworks.go.config.materials.ScmMaterialConfigTest.java

@Test
public void shouldSetFolderToNullWhenBlank() {
    material.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "foo"));
    assertThat(material.getFolder(), is(not(nullValue())));

    material.setConfigAttributes(new SingletonMap(ScmMaterialConfig.FOLDER, ""));
    assertThat(material.getFolder(), is(nullValue()));
}

From source file:com.thoughtworks.go.domain.StageConfigTest.java

@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));
}

From source file:com.thoughtworks.go.config.materials.ScmMaterialConfigTest.java

@Test
public void shouldUpdateAutoUpdateFieldFromConfigAttributes() {
    material.setConfigAttributes(new SingletonMap(AUTO_UPDATE, "false"));
    assertThat(material.isAutoUpdate(), is(false));
    material.setConfigAttributes(new SingletonMap(AUTO_UPDATE, null));
    assertThat(material.isAutoUpdate(), is(false));
    material.setConfigAttributes(new SingletonMap(AUTO_UPDATE, "true"));
    assertThat(material.isAutoUpdate(), is(true));
    material.setConfigAttributes(new HashMap());
    assertThat(material.isAutoUpdate(), is(false));
    material.setConfigAttributes(new SingletonMap(AUTO_UPDATE, null));
    assertThat(material.isAutoUpdate(), is(false));
    material.setConfigAttributes(new SingletonMap(AUTO_UPDATE, "random-stuff"));
    assertThat(material.isAutoUpdate(), is(false));
}

From source file:com.thoughtworks.go.config.merge.MergeEnvironmentConfigTest.java

@Test
public void shouldFailUpdateName() {
    try {//from  ww  w.  j a va  2s.c  om
        environmentConfig.setConfigAttributes(new SingletonMap(EnvironmentConfig.NAME_FIELD, "PROD"));
    } catch (RuntimeException ex) {
        assertThat(ex.getMessage(), is("Cannot update name of environment defined in multiple sources"));
        return;
    }
    fail("should have thrown");
}

From source file:de.hybris.platform.servicelayer.model.ModelServiceMapTest.java

@Test
public void testSetArticleStatusGenericWay() {
    modelService.setAttributeValue(product, ProductModel.ARTICLESTATUS,
            new SingletonMap(commonI18NService.getLanguage("en"), testMap));
    modelService.save(product);/*from ww  w .j  a  v a 2  s . co  m*/

    final Map<ArticleStatus, String> returnMap = product.getArticleStatus();
    assertEquals("map does not contain one single element", 1, returnMap.size());
    assertTrue("map does not contain expected key", returnMap.containsKey(ArticleStatus.BARGAIN));
    assertEquals("map does not contain expected value", "that's a bargain no doubt!",
            returnMap.get(ArticleStatus.BARGAIN));
}