Search in sources :

Example 11 with RequestMappingInfo

use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.

the class RequestMappingHandlerMappingTests method getMappingOverridesConsumesFromTypeLevelAnnotation.

// SPR-14988
@Test
public void getMappingOverridesConsumesFromTypeLevelAnnotation() throws Exception {
    RequestMappingInfo requestMappingInfo = assertComposedAnnotationMapping(RequestMethod.GET);
    assertArrayEquals(new MediaType[] { MediaType.ALL }, new ArrayList<>(requestMappingInfo.getConsumesCondition().getConsumableMediaTypes()).toArray());
}
Also used : RequestMappingInfo(org.springframework.web.reactive.result.method.RequestMappingInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with RequestMappingInfo

use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.

the class RequestMappingHandlerMappingTests method assertComposedAnnotationMapping.

private RequestMappingInfo assertComposedAnnotationMapping(String methodName, String path, RequestMethod requestMethod) throws Exception {
    Class<?> clazz = ComposedAnnotationController.class;
    Method method = clazz.getMethod(methodName);
    RequestMappingInfo info = this.handlerMapping.getMappingForMethod(method, clazz);
    assertNotNull(info);
    Set<String> paths = info.getPatternsCondition().getPatterns();
    assertEquals(1, paths.size());
    assertEquals(path, paths.iterator().next());
    Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
    assertEquals(1, methods.size());
    assertEquals(requestMethod, methods.iterator().next());
    return info;
}
Also used : RequestMappingInfo(org.springframework.web.reactive.result.method.RequestMappingInfo) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Method(java.lang.reflect.Method) RequestMethod(org.springframework.web.bind.annotation.RequestMethod)

Example 13 with RequestMappingInfo

use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.

the class RequestMappingHandlerMappingTests method resolveRequestMappingViaComposedAnnotation.

@Test
public void resolveRequestMappingViaComposedAnnotation() throws Exception {
    RequestMappingInfo info = assertComposedAnnotationMapping("postJson", "/postJson", RequestMethod.POST);
    assertEquals(MediaType.APPLICATION_JSON_VALUE, info.getConsumesCondition().getConsumableMediaTypes().iterator().next().toString());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, info.getProducesCondition().getProducibleMediaTypes().iterator().next().toString());
}
Also used : RequestMappingInfo(org.springframework.web.reactive.result.method.RequestMappingInfo) Test(org.junit.Test)

Aggregations

RequestMappingInfo (org.springframework.web.reactive.result.method.RequestMappingInfo)13 Test (org.junit.Test)12 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)8 ServerWebExchange (org.springframework.web.server.ServerWebExchange)6 Ignore (org.junit.Ignore)2 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 HttpHeaders (org.springframework.http.HttpHeaders)1 MediaType (org.springframework.http.MediaType)1 MockServerHttpRequest (org.springframework.mock.http.server.reactive.test.MockServerHttpRequest)1