List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:org.jasig.services.persondir.support.ldap.LdapPersonAttributeDaoTest.java
public void testNotFoundQuery() throws Exception { LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map<String, Object> ldapAttribsToPortalAttribs = new HashMap<String, Object>(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setResultAttributeMapping(ldapAttribsToPortalAttribs); impl.setContextSource(this.getContextSource()); impl.setQueryAttributeMapping(Collections.singletonMap("uid", null)); impl.afterPropertiesSet();//from w w w . j a va 2 s. co m Map<String, List<Object>> queryMap = new HashMap<String, List<Object>>(); queryMap.put("uid", Util.list("unknown")); try { Map<String, List<Object>> attribs = impl.getMultivaluedUserAttributes(queryMap); assertNull(attribs); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } }
From source file:com.logsniffer.reader.grok.GrokTest.java
@Test public void testSubPatternAttributes() throws GrokException { GroksRegistry r = new GroksRegistry(); r.registerPatternBlocks(Collections.singletonMap("base", new String[] { "USERNAME [a-zA-Z0-9_-]+", "USER (%{USERNAME:a}-)" })); assertEquals(2, r.getGroks().size()); assertNotNull(r.getGroks().get("USER")); assertEquals(1, r.getGroks().get("USER").getGroupNames().size()); assertEquals("a", r.getGroks().get("USER").getGroupNames().keySet().iterator().next()); assertEquals(2, r.getGroks().get("USER").getGroupNames().values().iterator().next().intValue()); Grok g = r.getGroks().get("USER"); assertEquals(true, g.matcher("mbok-").matches()); // Test sub groks with attribute projection assertEquals(2, g.getGroupNames().get("a").intValue()); GrokMatcher m = g.matcher("mbok-"); assertEquals(true, m.matches());/*from w w w. j a v a 2s .c om*/ assertEquals("mbok", m.group(g.getGroupNames().get("a"))); assertEquals("mbok", m.group("a")); assertEquals(false, g.matcher("mbok").matches()); }
From source file:ru.mystamps.web.dao.impl.JdbcCollectionDao.java
@Override public List<LinkEntityDto> findLastCreated(int quantity) { return jdbcTemplate.query(findLastCreatedCollectionsSql, Collections.singletonMap("quantity", quantity), RowMappers::forLinkEntityDto); }
From source file:ru.mystamps.web.dao.impl.JdbcUsersActivationDao.java
@Override public long countCreatedSince(Date date) { return jdbcTemplate.queryForObject(countCreatedSinceSql, Collections.singletonMap("date", date), Long.class); }
From source file:org.terasoluna.gfw.common.date.jodatime.JdbcAdjustedJodaTimeDateFactoryTest.java
@Test public void testNewDateTime03() throws Exception { jdbcTemplate.update("INSERT INTO system_adjusted_date(diff) VALUES (:diff)", Collections.singletonMap("diff", 30)); // plus 30 minute JdbcAdjustedJodaTimeDateFactory dateFactory = new JdbcAdjustedJodaTimeDateFactory(); dateFactory.setDataSource(dataSource); dateFactory.setUseCache(false);/*from w w w .jav a2s . co m*/ dateFactory.setAdjustedValueQuery("SELECT diff * 60 * 1000 FROM system_adjusted_date"); // returns diff as milliseconds dateFactory.afterPropertiesSet(); { DateTime now = new DateTime(); DateTime result = dateFactory.newDateTime(); assertThat((int) (Math.round(result.getMillis() - now.getMillis()) / 60.0 / 1000.0), is(30)); // plus 30 minute } { jdbcTemplate.update("UPDATE system_adjusted_date SET diff = :diff", Collections.singletonMap("diff", 60)); // minus 60 minute DateTime now = new DateTime(); DateTime result = dateFactory.newDateTime(); assertThat((int) (Math.round(result.getMillis() - now.getMillis()) / 60.0 / 1000.0), is(60));// plus 60 minute } }
From source file:ru.mystamps.web.dao.impl.JdbcImageDao.java
@Override public List<Integer> findBySeriesId(Integer seriesId) { return jdbcTemplate.queryForList(findBySeriesIdSql, Collections.singletonMap("series_id", seriesId), Integer.class); }
From source file:ch.cyberduck.ui.cocoa.controller.DuplicateFileController.java
@Override public void callback(final int returncode, final Path file) { file.setType(selected.getType());/*from w w w . j av a2s .c o m*/ callback.callback(Collections.singletonMap(selected, file)); }
From source file:com.graphaware.server.TxParticipationIntegrationTest.java
@Test public void moduleApiShouldParticipateInOpenTransaction() throws IOException { //First transaction over Cypher transactional rest endpoint, keep open: String response = post(baseUrl() + "/db/data/transaction", "{\n" + " \"statements\" : [ {\n" + " \"statement\" : \"CREATE (p:Person {props}) RETURN id(p)\",\n" + " \"parameters\" : {\n" + " \"props\" : {\n" + " \"name\" : \"Michal\"\n" + " }\n" + " }\n" + " } ]\n" + "}", HttpStatus.SC_CREATED);/* w ww . ja v a 2 s. co m*/ String commitUrl = new ObjectMapper().readTree(response).get("commit").asText(); String txUrl = commitUrl.substring(0, commitUrl.length() - "commit".length()); //Second transaction over Cypher transactional rest endpoint, keep open: post(txUrl, "{\n" + " \"statements\" : [ {\n" + " \"statement\" : \"CREATE (p:Person {props}) RETURN id(p)\",\n" + " \"parameters\" : {\n" + " \"props\" : {\n" + " \"name\" : \"Daniela\"\n" + " }\n" + " }\n" + " } ]\n" + "}", HttpStatus.SC_OK); //Third transaction over REST to an extension post(baseUrl() + "/graphaware/link/0/1", null, Collections.singletonMap("_GA_TX_ID", "1"), HttpStatus.SC_CREATED); //Commit transaction over transactional endpoint post(commitUrl, HttpStatus.SC_OK); post(baseUrl() + "/graphaware/resttest/assertSameGraph", "{\"cypher\": \"CREATE (m:Person {name:'Michal'})-[:TEST]->(d:Person {name:'Daniela'})\"}", HttpStatus.SC_OK); }