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:comsat.sample.actuator.SampleController.java

private Callable<Map<String, String>> helloCallable(final DeferredResult<Map<String, String>> optDeferred)
        throws SuspendExecution {
    return new Callable<Map<String, String>>() {
        @Override/*  w w  w.  j  a  v a2  s. co m*/
        @Suspendable
        public Map<String, String> call() throws Exception {
            try {
                Fiber.sleep(10);
                Map<String, String> ret = Collections.singletonMap("message",
                        helloWorldService.getHelloMessage());
                if (optDeferred != null)
                    optDeferred.setResult(ret);
                return ret;
            } catch (Throwable t) {
                if (optDeferred != null)
                    optDeferred.setErrorResult(t);
                throw t;
            }
        }
    };
}

From source file:com.gm.bamboo.dao.BuyHibernateDao.java

/**
 * {@inheritDoc}/* w ww  .  j a  v  a 2  s. co m*/
 * 
 * @since 2012-9-10
 * @see com.gm.bamboo.api.BuyDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Buy where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:com.gm.bamboo.dao.CompanyHibernateDao.java

/**
 * {@inheritDoc}/*w  w w .  jav  a 2  s . co  m*/
 * 
 * @since 2012-9-15
 * @see com.gm.bamboo.api.CompanyDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Company where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:com.gm.machine.dao.EnquiryHibernateDao.java

/**
 * {@inheritDoc}//  ww w. ja v  a 2  s  .c o  m
 * 
 * @since 2012-11-25
 * @see com.gm.machine.api.AdvertDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Enquiry where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:org.elasticsearch.smoketest.SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java

@Before
public void startWatcher() throws Exception {
    // delete the watcher history to not clutter with entries from other test
    getAdminExecutionContext().callApi("indices.delete",
            Collections.singletonMap("index", ".watcher-history-*"), emptyList(), emptyMap());

    // create one document in this index, so we can test in the YAML tests, that the index cannot be accessed
    Response resp = adminClient().performRequest("PUT", "/index_not_allowed_to_read/doc/1",
            Collections.emptyMap(), new StringEntity("{\"foo\":\"bar\"}", ContentType.APPLICATION_JSON));
    assertThat(resp.getStatusLine().getStatusCode(), is(201));

    assertBusy(() -> {//from  w  w  w  . j  ava  2s  .  co  m
        ClientYamlTestResponse response = getAdminExecutionContext().callApi("xpack.watcher.stats", emptyMap(),
                emptyList(), emptyMap());
        String state = (String) response.evaluate("stats.0.watcher_state");

        switch (state) {
        case "stopped":
            ClientYamlTestResponse startResponse = getAdminExecutionContext().callApi("xpack.watcher.start",
                    emptyMap(), emptyList(), emptyMap());
            boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
            assertThat(isAcknowledged, is(true));
            break;
        case "stopping":
            throw new AssertionError("waiting until stopping state reached stopped state to start again");
        case "starting":
            throw new AssertionError("waiting until starting state reached started state");
        case "started":
            // all good here, we are done
            break;
        default:
            throw new AssertionError("unknown state[" + state + "]");
        }
    });

    assertBusy(() -> {
        for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES) {
            ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi(
                    "indices.exists_template", singletonMap("name", template), emptyList(), emptyMap());
            assertThat(templateExistsResponse.getStatusCode(), is(200));
        }
    });
}

From source file:io.lavagna.common.LavagnaEnvironment.java

private static void setSystemPropertyIfNull(ConfigurableEnvironment env, String name, String value) {
    if (!env.containsProperty(name) || StringUtils.isBlank(env.getProperty(name))) {
        LOG.warn("Property {} is not set, using default value: {}", name, value);
        Map<String, Object> source = Collections.singletonMap(name, (Object) value);
        env.getPropertySources().addFirst(new MapPropertySource(name, source));
    }/*from   w  ww.java  2 s . com*/
}

From source file:com.gm.bamboo.dao.BusinessHibernateDao.java

/**
 * {@inheritDoc}/* ww w. j av  a  2  s.c  om*/
 * 
 * @since 2012-9-15
 * @see com.gm.bamboo.api.BusinessDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Business where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:com.gm.bamboo.dao.SupplyHibernateDao.java

/**
 * {@inheritDoc}/*from   www .  j ava  2  s . com*/
 * 
 * @since 2012-9-10
 * @see com.gm.bamboo.api.SupplyDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Supply where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:com.gm.bamboo.dao.LinksHibernateDao.java

/**
 * {@inheritDoc}/*w ww. ja v  a  2 s . co m*/
 * 
 * @since 2012-7-28
 * @see com.drcl.yz.api.LinksDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from Links where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}

From source file:com.gm.bamboo.dao.NewsHibernateDao.java

/**
 * {@inheritDoc}/*from w  w  w. j  a  v  a2s  .c  o m*/
 * 
 * @since 2012-7-28
 * @see com.gm.bamboo.api.NewsDao#batchDelete(java.util.List)
 */
@Override
public void batchDelete(List<Long> ids) {
    String hql = "delete from News where id in(:ids)";
    Map<String, List<Long>> values = Collections.singletonMap("ids", ids);
    super.batchExecute(hql, values);

}