List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:com.graphaware.server.EnterpriseTxParticipationIntegrationTest.java
@Test public void moduleApiShouldParticipateInOpenTransaction() throws IOException { //First transaction over Cypher transactional rest endpoint, keep open: String response = httpClient.post(baseNeoUrl() + "/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);/*from ww w . j ava2 s . c om*/ 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: httpClient.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 httpClient.post(baseUrl() + "/link/0/1", null, Collections.singletonMap("_GA_TX_ID", "1"), HttpStatus.SC_CREATED); //Commit transaction over transactional endpoint httpClient.post(commitUrl, HttpStatus.SC_OK); //todo re-enable // httpClient.post(baseUrl() + "/graphaware/resttest/assertSameGraph", "{\"cypher\": \"CREATE (m:Person {name:'Michal'})-[:TEST]->(d:Person {name:'Daniela'})\"}", HttpStatus.SC_OK); }
From source file:org.craftercms.core.controller.rest.CacheRestController.java
@RequestMapping(value = URL_CLEAR_ALL_SCOPES, method = RequestMethod.GET) @ResponseBody/*from w w w. j a v a 2 s . c om*/ public Map<String, String> clearAllScopes() throws CacheException { cacheTemplate.getCacheService().clearAll(); if (logger.isInfoEnabled()) { logger.info("[CACHE] All scopes have been cleared"); } return Collections.singletonMap(MODEL_ATTRIBUTE_MESSAGE, "All cache scopes have been cleared"); }
From source file:org.cloudfoundry.identity.uaa.oauth.ClientAdminBootstrapTests.java
@Test public void testSimpleAddClientWithAutoApprove() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put("id", "foo"); map.put("secret", "bar"); map.put("scope", "openid"); map.put("authorized-grant-types", "authorization_code"); map.put("authorities", "uaa.none"); BaseClientDetails output = new BaseClientDetails("foo", "none", "openid", "authorization_code,refresh_token", "uaa.none"); output.setClientSecret("bar"); bootstrap.setAutoApproveClients(Arrays.asList("foo")); when(clientRegistrationService.listClientDetails()).thenReturn(Collections.<ClientDetails>emptyList()) .thenReturn(Collections.<ClientDetails>singletonList(output)); bootstrap.setClients(Collections.singletonMap((String) map.get("id"), map)); bootstrap.afterPropertiesSet();//from ww w. j a v a 2 s . co m verify(clientRegistrationService).addClientDetails(output); BaseClientDetails updated = new BaseClientDetails(output); updated.setAdditionalInformation(Collections.singletonMap("autoapprove", true)); verify(clientRegistrationService).updateClientDetails(updated); }
From source file:com.netflix.discovery.shared.transport.jersey.JerseyEurekaHttpClientFactory.java
/** * @deprecated {@link EurekaJerseyClient} is deprecated and will be removed *//*from w w w . j av a 2s . c om*/ @Deprecated public JerseyEurekaHttpClientFactory(EurekaJerseyClient jerseyClient, boolean allowRedirects) { this(jerseyClient, null, -1, Collections.singletonMap(HTTP_X_DISCOVERY_ALLOW_REDIRECT, allowRedirects ? "true" : "false")); }
From source file:io.openshift.booster.BoosterApplicationTest.java
@Test public void testPostWithWrongPayload() { given().contentType(ContentType.JSON).body(Collections.singletonMap("id", 0)).when().post().then() .statusCode(422); }
From source file:org.cloudfoundry.identity.uaa.oauth.UaaUserApprovalHandlerTests.java
@Test public void testAutoApproveByScope() { BaseClientDetails client = new BaseClientDetails("client", "none", "read,write", "authorization_code", "uaa.none"); Mockito.when(clientDetailsService.loadClientByClientId("client")).thenReturn(client); client.setAdditionalInformation(Collections.singletonMap("autoapprove", Collections.singleton("read"))); assertTrue(handler.isApproved(authorizationRequest, userAuthentication)); client.setAdditionalInformation(Collections.singletonMap("autoapprove", Collections.singleton("write"))); assertFalse(handler.isApproved(authorizationRequest, userAuthentication)); }
From source file:com.olacabs.fabric.compute.sources.kafka.impl.ZookeeperOffsetSource.java
@Override public void saveOffset(String topic, int partition, long offset) throws Exception { //TODO BATCH THIS final String path = partitionPath(topologyName, topicName, partition); if (!ensuredPaths.contains(path)) { if (null == curatorFramework.checkExists().forPath(path)) { curatorFramework.create().creatingParentContainersIfNeeded().forPath(path); }/* www. j a v a2 s . c om*/ } ensuredPaths.add(path); curatorFramework.setData().forPath(path, objectMapper.writeValueAsBytes(Collections.singletonMap("offset", offset))); }
From source file:com.github.jrh3k5.flume.sink.http.server.FlumeSinkServerITest.java
/** * Test that the location header from posting events resolves to the correct location. * /*from w w w . j a v a2 s . c om*/ * @throws Exception * If any errors occur during the test run. */ @Test public void testPostLocation() throws Exception { final SimpleEvent toPost = new SimpleEvent(); toPost.setHeaders(Collections.singletonMap("a-header", UUID.randomUUID().toString())); toPost.setBody(UUID.randomUUID().toString().getBytes("utf-8")); final Response postResponse = client.target(server.getBaseUri()).path("events").request() .post(Entity.entity(new Event[] { toPost }, MediaType.APPLICATION_JSON_TYPE)); assertThat(postResponse.getStatus()).isEqualTo(Response.Status.CREATED.getStatusCode()); final URI postLocation = postResponse.getLocation(); assertThat(postLocation).isNotNull(); final Event[] gottenEvents = client.target(postLocation).request(MediaType.APPLICATION_JSON_TYPE) .get(SimpleEvent[].class); assertThat(gottenEvents).hasSize(1); assertThat(gottenEvents[0].getHeaders()).isEqualTo(toPost.getHeaders()); assertThat(gottenEvents[0].getBody()).isEqualTo(toPost.getBody()); }
From source file:edu.sampleu.krms.impl.CampusAgendaTypeService.java
private RemotableAttributeField createCampusField() { String campusBoClassName = CampusBo.class.getName(); String baseLookupUrl = LookupUtils.getBaseLookupUrl(); RemotableQuickFinder.Builder quickFinderBuilder = RemotableQuickFinder.Builder.create(baseLookupUrl, campusBoClassName);/* ww w . j av a 2 s. c o m*/ quickFinderBuilder.setLookupParameters(Collections.singletonMap("Campus", "code")); quickFinderBuilder.setFieldConversions(Collections.singletonMap("code", "Campus")); RemotableTextInput.Builder controlBuilder = RemotableTextInput.Builder.create(); controlBuilder.setSize(30); controlBuilder = RemotableTextInput.Builder.create(); controlBuilder.setSize(Integer.valueOf(40)); controlBuilder.setWatermark("campus code"); RemotableAttributeLookupSettings.Builder lookupSettingsBuilder = RemotableAttributeLookupSettings.Builder .create(); lookupSettingsBuilder.setCaseSensitive(Boolean.TRUE); lookupSettingsBuilder.setInCriteria(true); lookupSettingsBuilder.setInResults(true); lookupSettingsBuilder.setRanged(false); RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create(CAMPUS_FIELD_NAME); builder.setAttributeLookupSettings(lookupSettingsBuilder); builder.setRequired(true); builder.setDataType(DataType.STRING); builder.setControl(controlBuilder); builder.setLongLabel("Campus"); builder.setShortLabel("Campus"); builder.setMinLength(Integer.valueOf(1)); builder.setMaxLength(Integer.valueOf(40)); builder.setWidgets(Collections.<RemotableAbstractWidget.Builder>singletonList(quickFinderBuilder)); return builder.build(); }
From source file:ru.mystamps.web.dao.impl.JdbcUsersActivationDao.java
@Override public void removeByActivationKey(String activationKey) { int affected = jdbcTemplate.update(removeByActivationKeySql, Collections.singletonMap("activation_key", activationKey)); Validate.validState(affected == 1,// w w w. java2s . c o m "Unexpected number of affected rows after removing activation key '%s': %d", activationKey, affected); }