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:ru.mystamps.web.dao.impl.JdbcImageDataDao.java

@Override
public DbImageDto findByImageId(Integer imageId) {
    try {/*from   w w w .  ja  va2  s.co  m*/
        return jdbcTemplate.queryForObject(findByImageIdSql, Collections.singletonMap("image_id", imageId),
                RowMappers::forDbImageDto);
    } catch (EmptyResultDataAccessException ignored) {
        return null;
    }
}

From source file:com.graphaware.test.integration.GraphAwareIntegrationTest.java

@Override
protected Map<String, String> thirdPartyJaxRsPackageMappings() {
    return Collections.singletonMap("com.graphaware.server", "/graphaware");
}

From source file:com.arpnetworking.metrics.vertx.SinkVerticleTest.java

@Before
public void setUp(final TestContext context) {
    _rule.vertx().deployVerticle(TARGET_WORKER_VERTICLE_NAME,
            new DeploymentOptions()
                    .setConfig(new JsonObject(Collections.singletonMap("sinkAddress", SINK_ADDRESS)))
                    .setInstances(1).setWorker(true).setMultiThreaded(false),
            context.asyncAssertSuccess());
}

From source file:com.netflix.spinnaker.orca.clouddriver.tasks.image.FindImageFromTagsTask.java

@Override
public TaskResult execute(Stage stage) {
    String cloudProvider = getCloudProvider(stage);
    ImageFinder imageFinder = imageFinders.stream().filter(it -> it.getCloudProvider().equals(cloudProvider))
            .findFirst().orElseThrow(() -> new IllegalStateException(
                    "ImageFinder not found for cloudProvider " + cloudProvider));

    StageData stageData = (StageData) stage.mapTo(StageData.class);
    return new DefaultTaskResult(ExecutionStatus.SUCCEEDED, Collections.singletonMap("amiDetails",
            imageFinder.byTags(stage, stageData.packageName, stageData.tags)));
}

From source file:de.tntinteractive.portalsammler.engine.MapReaderTest.java

@Test
public void testSingleEntryMap() throws Exception {
    final String input = "test123\n" + " e1\n" + " w1\n" + ".";
    final MapReader r = createReader(input);
    final Pair<String, Map<String, String>> p = r.readNext();
    assertEquals("test123", p.getLeft());
    assertEquals(Collections.singletonMap("e1", "w1"), p.getRight());
    assertNull(r.readNext());/*from  w  ww. ja v  a2  s  .  c  o m*/
}

From source file:org.camunda.bpm.camel.spring.CustomContextTest.java

@Deployment(resources = { "process/custom.bpmn20.xml" })
public void testRunProcess() throws Exception {
    //CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    service1.expectedBodiesReceived("ala");

    String instanceId = (String) tpl.requestBody("direct:start", Collections.singletonMap("var1", "ala"));

    tpl.sendBodyAndProperty("direct:receive", null, CAMUNDA_BPM_PROCESS_INSTANCE_ID, instanceId);

    assertProcessEnded(instanceId);/*from  ww  w .j  a v  a 2 s.co m*/

    service1.assertIsSatisfied();
    Map m = service2.getExchanges().get(0).getIn().getBody(Map.class);
    assertEquals("ala", m.get("var1"));
    assertEquals("var2", m.get("var2"));

}

From source file:org.camunda.bpm.camel.spring.SimpleProcessTest.java

@Deployment(resources = { "process/example.bpmn20.xml" })
public void testRunProcess() throws Exception {
    //CamelContext ctx = applicationContext.getBean(CamelContext.class);
    ProducerTemplate tpl = ctx.createProducerTemplate();
    service1.expectedBodiesReceived("ala");

    String instanceId = (String) tpl.requestBody("direct:start", Collections.singletonMap("var1", "ala"));

    tpl.sendBodyAndProperty("direct:receive", null, CAMUNDA_BPM_PROCESS_INSTANCE_ID, instanceId);

    assertProcessEnded(instanceId);/* w w w . j ava 2 s.  c  om*/

    service1.assertIsSatisfied();
    Map m = service2.getExchanges().get(0).getIn().getBody(Map.class);
    assertEquals("ala", m.get("var1"));
    assertEquals("var2", m.get("var2"));

}

From source file:net.ontopia.topicmaps.nav2.portlets.pojos.MenuUtils.java

/**
 * Runs the given query with the given topic as parameter %topic% and returns
 * the first value (of the first collumn) in the result collection.
 * @param topic The parameter refered to as %topic% in the query.
 * @param pq The query that genereates the result.
 * @return The first value returned by the query.
 *///from   w w w  . j  a va2s.  c  o m
public static Object getFirstValue(TopicIF topic, ParsedQueryIF pq) {
    QueryResultIF qr = null;
    try {
        qr = pq.execute(Collections.singletonMap("topic", topic));
        while (qr.next()) {
            return qr.getValue(0);
        }
    } catch (InvalidQueryException e) {
        throw new OntopiaRuntimeException(e);
    } finally {
        if (qr != null)
            qr.close();
    }
    return null;
}

From source file:org.craftercms.security.processors.impl.UrlAccessRestrictionCheckingProcessorTest.java

@Before
public void setUp() throws Exception {
    processor = new UrlAccessRestrictionCheckingProcessor();
    processor.setUrlRestrictions(Collections.singletonMap(URL, "hasRole('" + ADMIN_ROLE + "')"));
}

From source file:org.appcomponents.platform.context.PlatformWebIntegrationTest.java

@Test
public void moduleIntegrationTest() {
    when().get("/echo").then().contentType(ContentType.TEXT).statusCode(HttpStatus.SC_OK)
            .content(Matchers.is("echo"));
    /** Module 1 */
    when().get("/?component={component}",
            Collections.singletonMap(PlatformComponent.PARAM_COMPONENT, BasicPlatform.MODULE_1)).then()
            .contentType(ContentType.TEXT).statusCode(HttpStatus.SC_OK).content(Matchers.is("main"));
    when().get("/hello?component={component}",
            Collections.singletonMap(PlatformComponent.PARAM_COMPONENT, BasicPlatform.MODULE_1)).then()
            .contentType(ContentType.TEXT).statusCode(HttpStatus.SC_OK).content(Matchers.is("hello"));
    /** Module 2 */
    when().get("/?component={component}",
            Collections.singletonMap(PlatformComponent.PARAM_COMPONENT, BasicPlatform.MODULE_2)).then()
            .contentType(ContentType.TEXT).statusCode(HttpStatus.SC_OK).content(Matchers.is("main2"));
    when().get("/hello?component={component}",
            Collections.singletonMap(PlatformComponent.PARAM_COMPONENT, BasicPlatform.MODULE_2)).then()
            .contentType(ContentType.TEXT).statusCode(HttpStatus.SC_OK).content(Matchers.is("hello2"));
}