use of org.springframework.util.LinkedMultiValueMap in project geode by apache.
the class ClientHttpRequestJUnitTest method testCreateRequestEntityForPost.
@Test
@SuppressWarnings("unchecked")
public void testCreateRequestEntityForPost() throws Exception {
final Link expectedLink = new Link("post", toUri("http://host.domain.com:8080/app/libraries/{name}/books"), HttpMethod.POST);
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertEquals(expectedLink, request.getLink());
final MultiValueMap<String, Object> expectedRequestParameters = new LinkedMultiValueMap<String, Object>(4);
expectedRequestParameters.add("author", "Douglas Adams");
expectedRequestParameters.add("title", "The Hitchhiker's Guide to the Galaxy");
expectedRequestParameters.add("year", "1979");
expectedRequestParameters.add("isbn", "0345453743");
request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE);
request.addParameterValues("author", expectedRequestParameters.getFirst("author"));
request.addParameterValues("title", expectedRequestParameters.getFirst("title"));
request.addParameterValues("year", expectedRequestParameters.getFirst("year"));
request.addParameterValues("isbn", expectedRequestParameters.getFirst("isbn"));
final HttpEntity<MultiValueMap<String, Object>> requestEntity = (HttpEntity<MultiValueMap<String, Object>>) request.createRequestEntity();
assertNotNull(requestEntity);
assertNotNull(requestEntity.getHeaders());
assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType());
assertEquals(expectedRequestParameters, requestEntity.getBody());
}
Aggregations