Search in sources :

Example 1 with AllEncompassingFormHttpMessageConverter

use of cn.taketoday.http.converter.AllEncompassingFormHttpMessageConverter in project today-framework by TAKETODAY.

the class RequestResponseBodyMethodProcessorTests method resolveArgumentRawTypeFromParameterizedType.

@Test
public void resolveArgumentRawTypeFromParameterizedType() throws Throwable {
    String content = "fruit=apple&vegetable=kale";
    this.servletRequest.setMethod("GET");
    this.servletRequest.setContent(content.getBytes(StandardCharsets.UTF_8));
    this.servletRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    List<HttpMessageConverter<?>> converters = new ArrayList<>();
    converters.add(new AllEncompassingFormHttpMessageConverter());
    RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
    @SuppressWarnings("unchecked") MultiValueMap<String, String> result = (MultiValueMap<String, String>) processor.resolveArgument(request, paramMultiValueMap);
    assertThat(result).isNotNull();
    assertThat(result.getFirst("fruit")).isEqualTo("apple");
    assertThat(result.getFirst("vegetable")).isEqualTo("kale");
}
Also used : HttpMessageConverter(cn.taketoday.http.converter.HttpMessageConverter) ByteArrayHttpMessageConverter(cn.taketoday.http.converter.ByteArrayHttpMessageConverter) StringHttpMessageConverter(cn.taketoday.http.converter.StringHttpMessageConverter) AllEncompassingFormHttpMessageConverter(cn.taketoday.http.converter.AllEncompassingFormHttpMessageConverter) MappingJackson2XmlHttpMessageConverter(cn.taketoday.http.converter.xml.MappingJackson2XmlHttpMessageConverter) MappingJackson2HttpMessageConverter(cn.taketoday.http.converter.json.MappingJackson2HttpMessageConverter) ResourceHttpMessageConverter(cn.taketoday.http.converter.ResourceHttpMessageConverter) ArrayList(java.util.ArrayList) AllEncompassingFormHttpMessageConverter(cn.taketoday.http.converter.AllEncompassingFormHttpMessageConverter) MultiValueMap(cn.taketoday.core.MultiValueMap) Test(org.junit.jupiter.api.Test)

Aggregations

MultiValueMap (cn.taketoday.core.MultiValueMap)1 AllEncompassingFormHttpMessageConverter (cn.taketoday.http.converter.AllEncompassingFormHttpMessageConverter)1 ByteArrayHttpMessageConverter (cn.taketoday.http.converter.ByteArrayHttpMessageConverter)1 HttpMessageConverter (cn.taketoday.http.converter.HttpMessageConverter)1 ResourceHttpMessageConverter (cn.taketoday.http.converter.ResourceHttpMessageConverter)1 StringHttpMessageConverter (cn.taketoday.http.converter.StringHttpMessageConverter)1 MappingJackson2HttpMessageConverter (cn.taketoday.http.converter.json.MappingJackson2HttpMessageConverter)1 MappingJackson2XmlHttpMessageConverter (cn.taketoday.http.converter.xml.MappingJackson2XmlHttpMessageConverter)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1