Search in sources :

Example 46 with MultiValueMap

use of org.springframework.util.MultiValueMap in project geode by apache.

the class ClientHttpRequestJUnitTest method testCreateRequestEntityOnPut.

@Test
public void testCreateRequestEntityOnPut() throws Exception {
    final Book mockBook = mockContext.mock(Book.class, "testCreateRequestEntityOnPut.Book");
    final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{id}"), HttpMethod.PUT);
    final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
    assertEquals(expectedLink, request.getLink());
    assertTrue(request.isPut());
    assertNull(request.getContent());
    request.setContent(mockBook);
    request.addParameterValues("isbn", "0-123456789");
    request.addParameterValues("category", "science-fiction", "sci-fi", "fiction");
    assertSame(mockBook, request.getContent());
    assertEquals("0-123456789", request.getParameterValue("isbn"));
    assertTrue(request.getParameterValues("category").containsAll(Arrays.asList("science-fiction", "sci-fi", "fiction")));
    final HttpEntity<?> requestEntity = request.createRequestEntity();
    assertNotNull(requestEntity);
    assertTrue(requestEntity.getBody() instanceof MultiValueMap);
    assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType());
}
Also used : Link(org.apache.geode.management.internal.web.domain.Link) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

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