Search in sources :

Example 1 with MultiValueMap

use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.

the class CandidateComponentsIndex method parseIndex.

private static MultiValueMap<String, String> parseIndex(List<Properties> content) {
    MultiValueMap<String, String> index = new LinkedMultiValueMap<>();
    for (Properties entry : content) {
        for (Map.Entry<Object, Object> entries : entry.entrySet()) {
            String type = (String) entries.getKey();
            String[] stereotypes = ((String) entries.getValue()).split(",");
            for (String stereotype : stereotypes) {
                index.add(stereotype, type);
            }
        }
    }
    return index;
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Properties(java.util.Properties) Map(java.util.Map) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Example 2 with MultiValueMap

use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.

the class AnnotationMetadataReadingVisitor method getAllAnnotationAttributes.

@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
    MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<>();
    List<AnnotationAttributes> attributes = this.attributesMap.get(annotationName);
    if (attributes == null) {
        return null;
    }
    for (AnnotationAttributes raw : attributes) {
        for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues("class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) {
            allAttributes.add(entry.getKey(), entry.getValue());
        }
    }
    return allAttributes;
}
Also used : AnnotationAttributes(org.springframework.core.annotation.AnnotationAttributes) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) MultiValueMap(org.springframework.util.MultiValueMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Example 3 with MultiValueMap

use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.

the class MapToMapConverterTests method mapToMultiValueMap.

@Test
@SuppressWarnings("unchecked")
public void mapToMultiValueMap() throws Exception {
    DefaultConversionService.addDefaultConverters(conversionService);
    Map<String, Integer> source = new HashMap<>();
    source.put("a", 1);
    source.put("b", 2);
    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")));
    assertThat(converted.get("b"), equalTo(Arrays.asList("2")));
}
Also used : TypeDescriptor(org.springframework.core.convert.TypeDescriptor) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test)

Example 4 with MultiValueMap

use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.

the class AsyncRestTemplateIntegrationTests method multipart.

@Test
public void multipart() throws Exception {
    MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
    parts.add("name 1", "value 1");
    parts.add("name 2", "value 2+1");
    parts.add("name 2", "value 2+2");
    Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg");
    parts.add("logo", logo);
    HttpEntity<MultiValueMap<String, Object>> requestBody = new HttpEntity<>(parts);
    Future<URI> future = template.postForLocation(baseUrl + "/multipart", requestBody);
    future.get();
}
Also used : HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) URI(java.net.URI) ClassPathResource(org.springframework.core.io.ClassPathResource) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test)

Example 5 with MultiValueMap

use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.

the class RequestParamMapMethodArgumentResolverTests method resolveMultiValueMapArgument.

@Test
public void resolveMultiValueMapArgument() throws Exception {
    MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class);
    ServerWebExchange exchange = MockServerHttpRequest.get("/path?foo=bar&foo=baz").toExchange();
    Object result = resolve(param, exchange);
    assertTrue(result instanceof MultiValueMap);
    assertEquals(Collections.singletonMap("foo", Arrays.asList("bar", "baz")), result);
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) RequestParam(org.springframework.web.bind.annotation.RequestParam) MethodParameter(org.springframework.core.MethodParameter) MultiValueMap(org.springframework.util.MultiValueMap) Test(org.junit.Test)

Aggregations

MultiValueMap (org.springframework.util.MultiValueMap)46 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)33 Test (org.junit.Test)18 Map (java.util.Map)17 HttpHeaders (org.springframework.http.HttpHeaders)17 List (java.util.List)9 HttpEntity (org.springframework.http.HttpEntity)9 RestTemplate (org.springframework.web.client.RestTemplate)6 URI (java.net.URI)4 LinkedHashMap (java.util.LinkedHashMap)4 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)4 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)4 HttpRequestHandler (org.springframework.web.HttpRequestHandler)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Link (org.apache.geode.management.internal.web.domain.Link)3 UnitTest (org.apache.geode.test.junit.categories.UnitTest)3 MethodParameter (org.springframework.core.MethodParameter)3 DefaultHandshakeHandler (org.springframework.web.socket.server.support.DefaultHandshakeHandler)3 HttpSessionHandshakeInterceptor (org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor)3