List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java
@Test public void testGetQueryNotFound() throws IOException { Assertions.assertThrows(IllegalArgumentException.class, () -> { MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add("createdTime", LocalDateTime.now().plusDays(1).toString()); namedQueryService.get("getAttributesCreatedBefore", params); });//from www. j a v a 2s . com }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.MarketTemplate.java
@Override public OptionQuote getQuoteForOption(String ticker, LocalDate expirationDate, OptionQuote.OptionType type, double strikePrice) throws OptionQuoteNotFoundException { String timeString = expirationDate.toString("yyMMdd"); String optionType = (type == OptionQuote.OptionType.CALL) ? "C" : "P"; String paddedPrice = String.format("%08d", (int) (strikePrice * 1000)); String optionSymbol = ticker + timeString + optionType + paddedPrice; String tickersParamString = this.buildCommaSeparatedParameterValue(new String[] { optionSymbol }); MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(); parameters.set("symbols", tickersParamString); try {/*from w ww.ja v a 2 s . c o m*/ URI url = this.buildUri(URL_QUOTES, parameters); ResponseEntity<TKOptionQuoteResponse> response = this.getRestTemplate().getForEntity(url, TKOptionQuoteResponse.class); if (null != response.getBody().getError()) throw new ApiException(TradeKingServiceProvider.PROVIDER_ID, response.getBody().getError()); return response.getBody().getQuotes()[0]; } catch (Exception e) { throw new OptionQuoteNotFoundException("Ticker: " + ticker, e); } }
From source file:com.faujnet.mongo.repository.MongoConnectionRepository.java
/** * Find all connections the current user has across all providers *///from www. ja v a2 s .c o m @Override public MultiValueMap<String, Connection<?>> findAllConnections() { List<Connection<?>> resultList = connService.getConnections(this.userId); MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<String, Connection<?>>(); Set<String> registeredProviderIds = this.connectionFactoryLocator.registeredProviderIds(); for (String registeredProviderId : registeredProviderIds) { connections.put(registeredProviderId, Collections.<Connection<?>>emptyList()); } for (Connection<?> connection : resultList) { String providerId = connection.getKey().getProviderId(); if (connections.get(providerId).size() == 0) { connections.put(providerId, new LinkedList<Connection<?>>()); } connections.add(providerId, connection); } return connections; }
From source file:org.cloudfoundry.identity.uaa.login.feature.ImplicitGrantIT.java
@Test public void testDefaultScopes() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); LinkedMultiValueMap<String, String> postBody = new LinkedMultiValueMap<>(); postBody.add("client_id", "cf"); postBody.add("redirect_uri", "https://uaa.cloudfoundry.com/redirect/cf"); postBody.add("response_type", "token"); postBody.add("source", "credentials"); postBody.add("username", testAccounts.getUserName()); postBody.add("password", testAccounts.getPassword()); ResponseEntity<Void> responseEntity = restOperations.exchange(baseUrl + "/oauth/authorize", HttpMethod.POST, new HttpEntity<>(postBody, headers), Void.class); Assert.assertEquals(HttpStatus.FOUND, responseEntity.getStatusCode()); UriComponents locationComponents = UriComponentsBuilder.fromUri(responseEntity.getHeaders().getLocation()) .build();/*from www . ja v a 2s.c om*/ Assert.assertEquals("uaa.cloudfoundry.com", locationComponents.getHost()); Assert.assertEquals("/redirect/cf", locationComponents.getPath()); MultiValueMap<String, String> params = parseFragmentParams(locationComponents); Assert.assertThat(params.get("jti"), not(empty())); Assert.assertEquals("bearer", params.getFirst("token_type")); Assert.assertThat(Integer.parseInt(params.getFirst("expires_in")), Matchers.greaterThan(40000)); String[] scopes = UriUtils.decode(params.getFirst("scope"), "UTF-8").split(" "); Assert.assertThat(Arrays.asList(scopes), containsInAnyOrder("scim.userids", "password.write", "cloud_controller.write", "openid", "cloud_controller.read")); Jwt access_token = JwtHelper.decode(params.getFirst("access_token")); Map<String, Object> claims = new ObjectMapper().readValue(access_token.getClaims(), new TypeReference<Map<String, Object>>() { }); Assert.assertThat((String) claims.get("jti"), is(params.getFirst("jti"))); Assert.assertThat((String) claims.get("client_id"), is("cf")); Assert.assertThat((String) claims.get("cid"), is("cf")); Assert.assertThat((String) claims.get("user_name"), is(testAccounts.getUserName())); Assert.assertThat(((List<String>) claims.get("scope")), containsInAnyOrder(scopes)); Assert.assertThat(((List<String>) claims.get("aud")), containsInAnyOrder("cf", "scim", "openid", "cloud_controller", "password")); }
From source file:com.art4ul.jcoon.context.RestClientContext.java
@Override public Context addHttpBodyParam(String key, Object value) { if (httpBodyParams == null) { httpBodyParams = new LinkedMultiValueMap<String, Object>(); }/* w w w .jav a 2 s . co m*/ httpBodyParams.add(key, value); return this; }
From source file:com.onedrive.api.resource.support.UploadSession.java
public UploadSession uploadFragment(long startIndex, long endIndex, long totalSize, byte[] data) { Assert.notNull(uploadUrl, "UploadSession instance invalid. The uploadUrl is not defined."); Assert.notNull(data, "The data is required."); MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>(); headers.add("Content-Range", "bytes " + startIndex + "-" + endIndex + "/" + totalSize); ResponseEntity<UploadSession> response = getOneDrive().getRestTemplate().exchange(uploadUri(), HttpMethod.PUT, new HttpEntity<ByteArrayResource>(new ByteArrayResource(data), headers), UploadSession.class); UploadSession session = response.getBody(); session.setUploadUrl(uploadUrl);//from w w w .j a v a 2 s. c o m session.complete = response.getStatusCode().equals(HttpStatus.CREATED) || response.getStatusCode().equals(HttpStatus.OK); return session; }
From source file:com.seajas.search.codex.service.social.SocialFacade.java
@Override @Cacheable("facebookPageSearchCache") public List<Reference> searchFacebookPages(final String person) { MultiValueMap<String, String> queryMap = new LinkedMultiValueMap<String, String>(); queryMap.add("q", person); queryMap.add("type", "page"); return getFacebookTemplate().fetchConnections("search", null, Reference.class, queryMap); }
From source file:io.syndesis.runtime.APITokenRule.java
@Override protected void before() throws Throwable { MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.set("username", "user"); map.set("password", "password"); map.set("grant_type", "password"); map.set("client_id", "admin-cli"); ResponseEntity<JsonNode> json = restTemplate.postForEntity(keycloakScheme + "://" + keycloakHost + ":" + keycloakPort + "/auth/realms/" + keycloakRealm + "/protocol/" + keycloakProtocol + "/token", map, JsonNode.class); assertThat(json.getStatusCode()).as("get token status code").isEqualTo(HttpStatus.OK); String token = json.getBody().get("access_token").textValue(); assertThat(token).as("access token").isNotEmpty(); accessToken = token;//from w w w . j ava2s . c o m String refreshToken = json.getBody().get("refresh_token").textValue(); assertThat(token).as("refresh token").isNotEmpty(); this.refreshToken = refreshToken; }
From source file:com.seajas.search.codex.social.connection.InMemoryConnectionRepository.java
@Override public MultiValueMap<String, Connection<?>> findAllConnections() { List<ConnectionData> connectionData = new ArrayList<ConnectionData>(); for (Map.Entry<String, InMemoryProviderConnectionRepository> providerConnectionRepository : providerRepositories .entrySet()) {//from w w w . ja v a 2 s. co m connectionData.addAll(providerConnectionRepository.getValue().findAllOrderByRank()); } List<Connection<?>> resultList = createConnections(connectionData); MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<String, Connection<?>>(); Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds(); for (String registeredProviderId : registeredProviderIds) { connections.put(registeredProviderId, Collections.<Connection<?>>emptyList()); } for (Connection<?> connection : resultList) { String providerId = connection.getKey().getProviderId(); if (connections.get(providerId).size() == 0) { connections.put(providerId, new LinkedList<Connection<?>>()); } connections.add(providerId, connection); } return connections; }
From source file:com.interop.webapp.WebAppTests.java
@Test public void testLogin() throws Exception { HttpHeaders headers = getHeaders();//from w ww .j a va 2s .c om headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("username", "user"); form.set("password", "user"); ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/login", HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(form, headers), String.class); assertEquals(HttpStatus.FOUND, entity.getStatusCode()); assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders().getLocation().toString().endsWith(port + "/")); assertNotNull("Missing cookie:\n" + entity.getHeaders(), entity.getHeaders().get("Set-Cookie")); }