use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class MapToMapConverterTests method multiValueMapToMultiValueMap.
@Test
@SuppressWarnings("unchecked")
public void multiValueMapToMultiValueMap() throws Exception {
DefaultConversionService.addDefaultConverters(conversionService);
MultiValueMap<String, Integer> source = new LinkedMultiValueMap<>();
source.put("a", Arrays.asList(1, 2, 3));
source.put("b", Arrays.asList(4, 5, 6));
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget"));
MultiValueMap<String, String> converted = (MultiValueMap<String, String>) conversionService.convert(source, targetType);
assertThat(converted.size(), equalTo(2));
assertThat(converted.get("a"), equalTo(Arrays.asList("1", "2", "3")));
assertThat(converted.get("b"), equalTo(Arrays.asList("4", "5", "6")));
}
use of org.springframework.util.MultiValueMap in project spring-data-document-examples by spring-projects.
the class FormHttpMessageConverter method writeParts.
private void writeParts(OutputStream os, MultiValueMap<String, Object> parts, byte[] boundary) throws IOException {
for (Map.Entry<String, List<Object>> entry : parts.entrySet()) {
String name = entry.getKey();
for (Object part : entry.getValue()) {
writeBoundary(boundary, os);
HttpEntity entity = getEntity(part);
writePart(name, entity, os);
writeNewLine(os);
}
}
}
use of org.springframework.util.MultiValueMap in project pinpoint by naver.
the class HttpRemoteService method createPost.
private HttpPost createPost(String url, MultiValueMap<String, String> params) throws UnsupportedEncodingException {
HttpPost post = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
String key = entry.getKey();
for (String value : entry.getValue()) {
nvps.add(new BasicNameValuePair(key, value));
}
}
post.setEntity(new UrlEncodedFormEntity(nvps));
return post;
}
use of org.springframework.util.MultiValueMap in project spring-security-oauth by spring-projects.
the class AbstractRefreshTokenSupportTests method refreshAccessToken.
private OAuth2AccessToken refreshAccessToken(String refreshToken) {
MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
formData.add("grant_type", "refresh_token");
formData.add("client_id", "my-trusted-client");
formData.add("refresh_token", refreshToken);
formData.add("scope", "read");
HttpHeaders headers = getTokenHeaders("my-trusted-client");
@SuppressWarnings("rawtypes") ResponseEntity<Map> response = http.postForMap(tokenPath(), headers, formData);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue("Wrong cache control: " + response.getHeaders().getFirst("Cache-Control"), response.getHeaders().getFirst("Cache-Control").contains("no-store"));
@SuppressWarnings("unchecked") OAuth2AccessToken newAccessToken = DefaultOAuth2AccessToken.valueOf(response.getBody());
return newAccessToken;
}
use of org.springframework.util.MultiValueMap in project spring-security-oauth by spring-projects.
the class HttpTestUtils method postForStatus.
private ResponseEntity<Void> postForStatus(RestOperations client, String path, HttpHeaders headers, MultiValueMap<String, String> formData) {
HttpHeaders actualHeaders = new HttpHeaders();
actualHeaders.putAll(headers);
actualHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
return client.exchange(getUrl(path), HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(formData, actualHeaders), (Class<Void>) null);
}
Aggregations