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

@Override
public ImageInfoDto findById(Integer imageId) {
    try {//from   w ww . j a va  2  s  .  c o  m
        return jdbcTemplate.queryForObject(findByIdSql, Collections.singletonMap("id", imageId),
                RowMappers::forImageInfoDto);
    } catch (EmptyResultDataAccessException ignored) {
        return null;
    }
}

From source file:com.erudika.scoold.core.Comment.java

public String create() {
    if (StringUtils.isBlank(comment) || StringUtils.isBlank(getParentid())) {
        return null;
    }//from  w ww  . j  a v a2 s. c  o  m
    int count = client().getCount(getType(), Collections.singletonMap(Config._PARENTID, getParentid()))
            .intValue();
    if (count > MAX_COMMENTS_PER_ID) {
        return null;
    }
    Comment c = client().create(this);
    if (c != null) {
        setId(c.getId());
        setTimestamp(c.getTimestamp());
        return c.getId();
    }
    return null;
}

From source file:org.suren.autotest.web.framework.selenium.action.SeleniumJqGridSequenceOperation.java

/**
 * @param absEle//from  w w w.  j  ava  2s  . c o m
 * @return
 */
private Text buildSearchText(AbstractElement absEle) {
    Map<String, String> map = Collections.singletonMap(absEle.getDataStr(KW_SEARCH_BY),
            absEle.getDataStr(KW_SEARCH_INFO));
    map.put("strategy", "priority");

    LocatorUtil.setLocator(map, searchText);

    return searchText;
}

From source file:ws.salient.model.commands.CommandTest.java

@Test
public void completeWorkItemCommand() throws Exception {

    Command command = new CompleteWorkItem(1L, "session")
            .withResult(Collections.singletonMap("success", Boolean.TRUE)).withTimestamp(now);

    String jsonCommand = json.writeValueAsString(command);
    command = json.readValue(jsonCommand, Command.class);

    assertTrue(command instanceof CompleteWorkItem);
    CompleteWorkItem completeWorkItem = (CompleteWorkItem) command;

    assertEquals("session", completeWorkItem.getSessionId());
    assertEquals(now, command.getTimestamp());
    assertEquals(new Long(1), completeWorkItem.getWorkItemId());
    assertNotNull(completeWorkItem.getResult());
    assertTrue(completeWorkItem.getResult().containsKey("success"));
    assertTrue((Boolean) completeWorkItem.getResult().get("success"));

}

From source file:io.fabric8.maven.enricher.fabric8.AutoTLSEnricherTest.java

@Test
public void testSecretName() throws Exception {
    final SecretNameTestConfig[] data = new SecretNameTestConfig[] {
            new SecretNameTestConfig(PlatformMode.kubernetes, null, null),
            new SecretNameTestConfig(PlatformMode.openshift, null, "projectA-tls"),
            new SecretNameTestConfig(PlatformMode.openshift, "custom-secret", "custom-secret") };

    for (final SecretNameTestConfig tc : data) {
        final ProcessorConfig config = new ProcessorConfig(null, null,
                Collections.singletonMap(AutoTLSEnricher.ENRICHER_NAME, new TreeMap(Collections
                        .singletonMap(AutoTLSEnricher.Config.tlsSecretName.name(), tc.tlsSecretNameConfig))));

        final Properties projectProps = new Properties();
        projectProps.put(PlatformMode.FABRIC8_EFFECTIVE_PLATFORM_MODE, tc.mode.name());

        // Setup mock behaviour
        new Expectations() {
            {//  ww w . ja va  2s.c om
                project.getProperties();
                result = projectProps;
                project.getArtifactId();
                result = "projectA";
                minTimes = 0;
                context.getProject();
                result = project;
                context.getConfig();
                result = config;
            }
        };

        AutoTLSEnricher enricher = new AutoTLSEnricher(context);
        Map<String, String> annotations = enricher.getAnnotations(Kind.SERVICE);
        if (tc.mode == PlatformMode.kubernetes) {
            assertNull(annotations);
            continue;
        }

        assertEquals(1, annotations.size());
        assertEquals(tc.tlsSecretName, annotations.get(AutoTLSEnricher.AUTOTLS_ANNOTATION_KEY));
    }
}

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

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

    tpl.sendBodyAndProperty("direct:start", Collections.singletonMap("var1", "ala"),
            CAMUNDA_BPM_PROCESS_DEFINITION_KEY, "key1");

    String instanceId = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("key1")
            .singleResult().getProcessInstanceId();
    tpl.sendBodyAndProperty("direct:receive", null, CAMUNDA_BPM_PROCESS_DEFINITION_KEY, "key1");

    assertProcessEnded(instanceId);//from w  w  w  .  j  av a2 s  .c  o m

    me.assertIsSatisfied();
}

From source file:com.ylw.template.model.ModelConfig.java

private Map<String, String> jpaProperties() {
    return Collections.singletonMap("org.hibernate.envers.audit_strategy",
            ValidityAuditStrategy.class.getName());
}

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

/**
 * Get the values of a given query with a given %topic% parameter as a List
 * @param topic The topic parameter represened by %topic% in the query.
 * @param parsedQuery The query./*from   w  ww.ja  va  2  s  . co  m*/
 * @return the first result column values of the query, as a List.
 */
public static List getResultValues(TopicIF topic, ParsedQueryIF parsedQuery) {
    List topics = new ArrayList();
    QueryResultIF qr = null;
    try {
        qr = parsedQuery.execute(Collections.singletonMap("topic", topic));
        while (qr.next()) {
            topics.add(qr.getValue(0));
        }
    } catch (InvalidQueryException e) {
        throw new OntopiaRuntimeException(e);
    } finally {
        if (qr != null)
            qr.close();
    }
    return topics;
}

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

@Override
public long countByActivationKey(String activationKey) {
    return jdbcTemplate.queryForObject(countByActivationKeySql,
            Collections.singletonMap("activation_key", activationKey), Long.class);
}

From source file:org.yamj.core.database.service.CommonStorageService.java

@Transactional(readOnly = true)
public List<Long> getStageFilesToDelete() {
    final StringBuilder sb = new StringBuilder();
    sb.append("SELECT f.id FROM StageFile f ");
    sb.append("WHERE f.status = :delete ");

    Map<String, Object> params = Collections.singletonMap("delete", (Object) StatusType.DELETED);
    return stagingDao.findByNamedParameters(sb, params);
}