Example usage for java.util Collections singletonMap

List of usage examples for java.util Collections singletonMap

Introduction

In this page you can find the example usage for java.util Collections singletonMap.

Prototype

public static <K, V> Map<K, V> singletonMap(K key, V value) 

Source Link

Document

Returns an immutable map, mapping only the specified key to the specified value.

Usage

From source file:io.fabric8.maven.enricher.standard.ImageEnricherTest.java

@Before
public void prepareMock() {
    // Setup mock behaviour
    new Expectations() {
        {//from ww w  . j ava  2s .c  o m
            context.getResources();
            result = new ResourceConfig.Builder().env(Collections.singletonMap("MY_KEY", "MY_VALUE")).build();

            imageConfiguration.getName();
            result = "busybox";
            imageConfiguration.getAlias();
            result = "busybox";
            context.getImages();
            result = Arrays.asList(imageConfiguration);
        }
    };

    imageEnricher = new ImageEnricher(context);
}

From source file:com.testritegroup.ec.core.category.dao.impl.ECPBrandDaoImpl.java

@Override
public List<ECPBrandModel> findECPBrandModelByCode(String brandCode) {
    validateParameterNotNull(brandCode, "Product code must not be null!");
    return find(Collections.singletonMap(ECPBrandModel.CODE, (Object) brandCode));
}

From source file:net.sourceforge.vulcan.spring.SpringProjectDomBuilderTest.java

public void testCreate() throws Exception {
    builder.setTransformResources(Collections.singletonMap("foo", "foo.xsl"));

    assertNotNull(builder.createTransformer("foo"));
}

From source file:com.mcleodmoores.mvn.natives.UnpackDependenciesMojoTest.java

private UnpackDependenciesMojo executeInstance(final File tmp, final Set<Artifact> artifacts) {
    final UnpackDependenciesMojo instance = new UnpackDependenciesMojo();
    instance.setLog(Mockito.mock(Log.class));
    final MavenProject project = new MavenProject();
    project.getBuild().setDirectory(tmp.getAbsolutePath());
    project.setArtifacts(artifacts);/*from  w  ww . java  2  s  . c o m*/
    instance.setPluginContext(Collections.singletonMap("project", project));
    return instance;
}

From source file:newcontroller.handler.impl.DefaultResponseTest.java

@Test
public void testBodyJson() throws Exception {
    MockHttpServletResponse response = new MockHttpServletResponse();
    Response res = new DefaultResponse(response,
            Arrays.asList(new StringHttpMessageConverter(), new GsonHttpMessageConverter()));
    HandlerBridge handlerBridge = res.body(Collections.singletonMap("name", "Joy"));
    handlerBridge.bridge(new DefaultRequest(new MockHttpServletRequest()), res);
    assertThat(response.getContentAsString(), is("{\"name\":\"Joy\"}"));
}

From source file:com.graphaware.common.representation.GraphDetachedNodeTest.java

@Test
public void nodeRepresentationIsCorrectlyConvertedFromJson() throws IOException, JSONException {
    String json = "{\"graphId\":0,\"properties\":{\"key\":\"value\"},\"labels\":[\"Label1, Label2\"]}";
    Assert.assertEquals(new GraphDetachedNode(0, new String[] { "Label1, Label2" },
            Collections.singletonMap("key", "value")), mapper.readValue(json, GraphDetachedNode.class));
}

From source file:com.graphaware.common.representation.GraphDetachedRelationshipTest.java

@Test
public void relationshipRepresentationIsCorrectlyConvertedFromJson() throws IOException, JSONException {
    String json = "{\"graphId\":0,\"properties\":{\"key\":\"value\"},\"startNodeGraphId\":1,\"endNodeGraphId\":2,\"type\":\"TYPE\"}";
    Assert.assertEquals(/*from www .  jav a2s  . c  o  m*/
            new GraphDetachedRelationship(0, 1, 2, "TYPE", Collections.singletonMap("key", "value")),
            mapper.readValue(json, GraphDetachedRelationship.class));
}

From source file:com.jelastic.campitos.ControladorArduino.java

@RequestMapping(value = "/leer-codigo", method = RequestMethod.GET, headers = { "Accept=Application/json" })
public @ResponseBody String buscarTodosCodigos() throws Exception {
    /*// ww w  . j  a  va  2s  .co m
          Hay que refactorizar lo siguiente
          */

    Map<String, ArrayList<Codigo>> singletonMap = Collections.singletonMap("codigos",
            (ArrayList<Codigo>) servicioCodigo.obtenerTodos());
    ObjectMapper maper = new ObjectMapper();
    return maper.writeValueAsString(singletonMap);
}

From source file:locksdemo.LocksController.java

@RequestMapping(value = "{name}/{value}", method = RequestMethod.DELETE)
public Map<String, Object> release(@PathVariable String name, @PathVariable String value) {
    if (!service.release(name, value)) {
        throw new NoSuchLockException();
    }/*from w  w  w  .  j  av a  2  s.  co  m*/
    return Collections.singletonMap("status", (Object) "OK");
}

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

@Test
public void shouldNotValidateEmptyDestinationFolder() {
    material.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, ""));
    material.validate(new ValidationContext(null));
    assertThat(material.errors.isEmpty(), is(true));
}