use of org.springframework.web.context.request.ServletWebRequest in project spring-data-commons by spring-projects.
the class SortHandlerMethodArgumentResolverUnitTests method fallbackToGivenDefaultSort.
// DATACMNS-351
@Test
public void fallbackToGivenDefaultSort() throws Exception {
MethodParameter parameter = TestUtils.getParameterOfMethod(getControllerClass(), "unsupportedMethod", String.class);
SortHandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
Sort fallbackSort = Sort.by(Direction.ASC, "ID");
resolver.setFallbackSort(fallbackSort);
Sort sort = resolver.resolveArgument(parameter, null, new ServletWebRequest(new MockHttpServletRequest()), null);
assertThat(sort).isEqualTo(fallbackSort);
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-data-commons by spring-projects.
the class QuerydslPredicateArgumentResolverUnitTests method resolveArgumentShouldResolveTypePropertyFromPageCorrectly.
// DATACMNS-669
@Test
public void resolveArgumentShouldResolveTypePropertyFromPageCorrectly() throws Exception {
request.addParameter("address.city", "tar valon");
Predicate predicate = resolver.resolveArgument(getMethodParameterFor("pagedFind", Predicate.class, Pageable.class), null, new ServletWebRequest(request), null);
assertThat(predicate).isEqualTo((Predicate) QUser.user.address.city.eq("tar valon"));
}
use of org.springframework.web.context.request.ServletWebRequest in project profile by craftercms.
the class ProviderLoginSupportImpl method completeConnection.
protected Connection<?> completeConnection(ConnectSupport connectSupport, String providerId, HttpServletRequest request) throws OAuth2Exception {
if (StringUtils.isNotEmpty(request.getParameter(PARAM_OAUTH_TOKEN))) {
OAuth1ConnectionFactory<?> connectionFactory = (OAuth1ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_CODE))) {
OAuth2ConnectionFactory<?> connectionFactory = (OAuth2ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_ERROR))) {
String error = request.getParameter(PARAM_ERROR);
String errorDescription = request.getParameter(PARAM_ERROR_DESCRIPTION);
String errorUri = request.getParameter(PARAM_ERROR_URI);
throw new OAuth2Exception(error, errorDescription, errorUri);
} else {
return null;
}
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-security by spring-projects.
the class OAuth2AuthorizedClientArgumentResolverTests method resolveArgumentWhenRegistrationIdInvalidThenThrowIllegalArgumentException.
@Test
public void resolveArgumentWhenRegistrationIdInvalidThenThrowIllegalArgumentException() {
MethodParameter methodParameter = this.getMethodParameter("registrationIdInvalid", OAuth2AuthorizedClient.class);
assertThatIllegalArgumentException().isThrownBy(() -> this.argumentResolver.resolveArgument(methodParameter, null, new ServletWebRequest(this.request, this.response), null)).withMessage("Could not find ClientRegistration with id 'invalid'");
}
use of org.springframework.web.context.request.ServletWebRequest in project spring-security by spring-projects.
the class OAuth2AuthorizedClientArgumentResolverTests method resolveArgumentWhenAuthorizedClientNotFoundForAuthorizationCodeClientThenThrowClientAuthorizationRequiredException.
@Test
public void resolveArgumentWhenAuthorizedClientNotFoundForAuthorizationCodeClientThenThrowClientAuthorizationRequiredException() {
given(this.authorizedClientRepository.loadAuthorizedClient(anyString(), any(), any(HttpServletRequest.class))).willReturn(null);
MethodParameter methodParameter = this.getMethodParameter("paramTypeAuthorizedClient", OAuth2AuthorizedClient.class);
assertThatExceptionOfType(ClientAuthorizationRequiredException.class).isThrownBy(() -> this.argumentResolver.resolveArgument(methodParameter, null, new ServletWebRequest(this.request, this.response), null));
}
Aggregations