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.JdbcUserDao.java

@Override
public UserDetails findUserDetailsByLogin(String login) {
    try {/*  www.  java  2  s .  co m*/
        return jdbcTemplate.queryForObject(findUserDetailsByLoginSql, Collections.singletonMap("login", login),
                RowMappers::forUserDetails);
    } catch (EmptyResultDataAccessException ignored) {
        return null;
    }
}

From source file:com.consol.citrus.admin.web.SpringBeanController.java

@RequestMapping(value = "/{type}", method = { RequestMethod.GET })
@ResponseBody/*from   w w w .  j  av  a  2  s .c o  m*/
public List<SpringBean> listBeans(@PathVariable("type") String type) {
    return springBeanService.getBeanDefinitions(projectService.getProjectContextConfigFile(),
            projectService.getActiveProject(), SpringBean.class, Collections.singletonMap("class", type));
}

From source file:org.jboss.as.test.integration.logging.perdeploy.Log4jPropertiesTestCase.java

@Test
public void logsTest() throws IOException {
    final String msg = "logTest: log4j.properties message";
    final int statusCode = getResponse(msg, Collections.singletonMap("includeLevel", "true"));
    assertTrue("Invalid response statusCode: " + statusCode, statusCode == HttpStatus.SC_OK);
    boolean trace = false;
    boolean fatal = false;
    String traceLine = msg + " - trace";
    String fatalLine = msg + " - fatal";
    try (final BufferedReader reader = Files.newBufferedReader(logFile, StandardCharsets.UTF_8)) {
        String line;//from w w  w  . ja va  2 s .  c  om
        while ((line = reader.readLine()) != null) {
            if (line.contains(traceLine)) {
                trace = true;
            }
            if (line.contains(fatalLine)) {
                fatal = true;
            }
        }
    }
    Assert.assertTrue("Log file should contain line: " + traceLine, trace);
    Assert.assertTrue("Log file should contain line: " + fatalLine, fatal);
}

From source file:com.it.j2ee.modules.email.MimeMailService.java

/**
 * Freemarker?html?.//from   ww  w . java2 s  . c  om
 */
private String generateContent(String userName) throws MessagingException {

    try {
        Map context = Collections.singletonMap("userName", userName);
        return FreeMarkerTemplateUtils.processTemplateIntoString(template, context);
    } catch (IOException e) {
        logger.error("?, FreeMarker??", e);
        throw new MessagingException("FreeMarker??", e);
    } catch (TemplateException e) {
        logger.error("?, FreeMarker?", e);
        throw new MessagingException("FreeMarker?", e);
    }
}

From source file:fr.landel.utils.commons.StringUtilsPerf.java

/**
 * Test method for/*  ww w . j av a2s. c  o  m*/
 * {@link StringUtils#injectKeys(CharSequence, java.util.Map.Entry...)}.
 */
@Benchmark
public void testInjectKeys() {
    StringUtils.injectKeys("I'll go to {where} this {when}", Pair.of("where", "beach"),
            Pair.of("when", "afternoon"));
    StringUtils.injectKeys("I'll go to {where} this {when} {{when}}", Pair.of("where", "beach"),
            Pair.of("when", "afternoon"));
    StringUtils.injectKeys("I'll go to {where} this {when}",
            MapUtils2.newHashMap(Pair.of("where", "beach"), Pair.of("when", "afternoon")));
    StringUtils.injectKeys("I'll go to {where}", Collections.singletonMap("where", "beach"));
}

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

@RequestMapping(value = "/leer-semaforo", method = RequestMethod.GET, headers = { "Accept=Application/json" })
public @ResponseBody String buscarTodosSemaforos() throws Exception {
    /*/* w w w.ja v a  2s.  c  om*/
          Hay que refactorizar lo siguiente
          */

    Map<String, ArrayList<Semaforo>> singletonMap = Collections.singletonMap("semaforos",
            (ArrayList<Semaforo>) servicioSemaforo.obtenerTodos());
    ObjectMapper maper = new ObjectMapper();
    return maper.writeValueAsString(singletonMap);
}

From source file:org.apereo.openlrs.controllers.StatementControllerGetCombinationsTest.java

@Before
public void before() {
    //set up data   
    XApiActor actor1 = new XApiActor();
    actor1.setMbox("mailto:" + statement1Id + "@test.com");
    XApiVerb verb1 = new XApiVerb();
    verb1.setId("http://example.com/" + statement1Id);
    verb1.setDisplay(Collections.singletonMap("en-US", "verb"));
    XApiObject object1 = new XApiObject();
    object1.setId("http://example.com/" + statement1Id);
    Statement statement1 = new Statement();
    statement1.setId(statement1Id);/*from w ww.  j a va  2s.com*/
    statement1.setActor(actor1);
    statement1.setVerb(verb1);
    statement1.setObject(object1);

    elasticSearchStatementSpringDataRepository.save(statement1);
}

From source file:ru.mystamps.web.dao.impl.JdbcUsersActivationDao.java

@Override
public List<UsersActivationFullDto> findOlderThan(Date date) {
    return jdbcTemplate.query(findOlderThanDateSql, Collections.singletonMap("date", date),
            RowMappers::forUsersActivationFullDto);
}

From source file:jenkins.util.xstream.XStreamDOMTest.java

private Foo createSomeFoo() {
    Foo foo = new Foo();
    foo.bar = new XStreamDOM("test1", Collections.singletonMap("key", "value"), "text!");
    foo.zot = new XStreamDOM("test2", Collections.singletonMap("key", "value"),
            Collections.singletonList(foo.bar));
    return foo;//ww  w  .  j ava2 s.co  m
}