use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestParamMapMethodArgumentResolverTests method supportsParameter.
@Test
public void supportsParameter() {
MethodParameter param = this.testMethod.annot(requestParam().noName()).arg(Map.class);
assertTrue(resolver.supportsParameter(param));
param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class);
assertTrue(resolver.supportsParameter(param));
param = this.testMethod.annot(requestParam().name("name")).arg(Map.class);
assertFalse(resolver.supportsParameter(param));
param = this.testMethod.annotNotPresent(RequestParam.class).arg(Map.class);
assertFalse(resolver.supportsParameter(param));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class HandlerMethodArgumentResolverCompositeTests method setUp.
@Before
public void setUp() throws Exception {
resolvers = new HandlerMethodArgumentResolverComposite();
Method method = getClass().getDeclaredMethod("handle", Integer.class, String.class);
paramInt = new MethodParameter(method, 0);
paramStr = new MethodParameter(method, 1);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class HandlerMethodReturnValueHandlerCompositeTests method handleReturnValueWithAsyncHandler.
// SPR-13083
@Test
public void handleReturnValueWithAsyncHandler() throws Exception {
Promise<Integer> promise = new Promise<>();
MethodParameter promiseType = new MethodParameter(getClass().getDeclaredMethod("handlePromise"), -1);
HandlerMethodReturnValueHandler responseBodyHandler = mock(HandlerMethodReturnValueHandler.class);
when(responseBodyHandler.supportsReturnType(promiseType)).thenReturn(true);
this.handlers.addHandler(responseBodyHandler);
AsyncHandlerMethodReturnValueHandler promiseHandler = mock(AsyncHandlerMethodReturnValueHandler.class);
when(promiseHandler.supportsReturnType(promiseType)).thenReturn(true);
when(promiseHandler.isAsyncReturnValue(promise, promiseType)).thenReturn(true);
this.handlers.addHandler(promiseHandler);
this.handlers.handleReturnValue(promise, promiseType, this.mavContainer, null);
verify(promiseHandler).isAsyncReturnValue(promise, promiseType);
verify(promiseHandler).supportsReturnType(promiseType);
verify(promiseHandler).handleReturnValue(promise, promiseType, this.mavContainer, null);
verifyNoMoreInteractions(promiseHandler);
verifyNoMoreInteractions(responseBodyHandler);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class HandlerMethodReturnValueHandlerCompositeTests method setUp.
@Before
public void setUp() throws Exception {
this.integerType = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1);
this.stringType = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1);
this.integerHandler = mock(HandlerMethodReturnValueHandler.class);
when(this.integerHandler.supportsReturnType(this.integerType)).thenReturn(true);
this.handlers = new HandlerMethodReturnValueHandlerComposite();
this.handlers.addHandler(this.integerHandler);
mavContainer = new ModelAndViewContainer();
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestParamMethodArgumentResolverTests method resolveSimpleTypeParamToNull.
// SPR-8561
@Test
public void resolveSimpleTypeParamToNull() throws Exception {
MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertNull(result);
}
Aggregations