Search in sources :

Example 6 with MethodParameter

use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.

the class TypeDescriptorTests method nestedMethodParameterTypeNotNestable.

@Test
public void nestedMethodParameterTypeNotNestable() throws Exception {
    TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0), 2);
    assertNull(t1);
}
Also used : MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 7 with MethodParameter

use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.

the class TypeDescriptorTests method nestedNotParameterized.

@Test
public void nestedNotParameterized() throws Exception {
    TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test6", List.class), 0), 1);
    assertEquals(List.class, t1.getType());
    assertEquals("java.util.List<?>", t1.toString());
    TypeDescriptor t2 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test6", List.class), 0), 2);
    assertNull(t2);
}
Also used : MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 8 with MethodParameter

use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.

the class TypeDescriptorTests method nestedMethodParameterTypeMapTwoLevels.

@Test
public void nestedMethodParameterTypeMapTwoLevels() throws Exception {
    TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0), 2);
    assertEquals(String.class, t1.getType());
}
Also used : MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 9 with MethodParameter

use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.

the class TypeDescriptorTests method parameterScalar.

@Test
public void parameterScalar() throws Exception {
    TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterScalar", String.class), 0));
    assertEquals(String.class, desc.getType());
    assertEquals(String.class, desc.getObjectType());
    assertEquals("java.lang.String", desc.getName());
    assertEquals("java.lang.String", desc.toString());
    assertTrue(!desc.isPrimitive());
    assertEquals(0, desc.getAnnotations().length);
    assertFalse(desc.isCollection());
    assertFalse(desc.isArray());
    assertFalse(desc.isMap());
}
Also used : MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 10 with MethodParameter

use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.

the class TypeDescriptorTests method parameterListNoParamTypes.

@Test
public void parameterListNoParamTypes() throws Exception {
    MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterListNoParamTypes", List.class), 0);
    TypeDescriptor desc = new TypeDescriptor(methodParameter);
    assertEquals(List.class, desc.getType());
    assertEquals(List.class, desc.getObjectType());
    assertEquals("java.util.List", desc.getName());
    assertEquals("java.util.List<?>", desc.toString());
    assertTrue(!desc.isPrimitive());
    assertEquals(0, desc.getAnnotations().length);
    assertTrue(desc.isCollection());
    assertFalse(desc.isArray());
    assertNull(desc.getElementTypeDescriptor());
    assertFalse(desc.isMap());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Aggregations

MethodParameter (org.springframework.core.MethodParameter)320 Test (org.junit.Test)251 Method (java.lang.reflect.Method)64 ArrayList (java.util.ArrayList)35 RequestParam (org.springframework.web.bind.annotation.RequestParam)30 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)27 HandlerMethod (org.springframework.web.method.HandlerMethod)27 Before (org.junit.Before)25 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)25 ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)23 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)23 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)23 ResolvableType (org.springframework.core.ResolvableType)21 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)21 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)21 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)20 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)20 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)20 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)20 Mono (reactor.core.publisher.Mono)19