@Test public void resolveArgumentReturnsDefaultProjectionWhenProjectionNotNullOrEmpty() { var expectedProjection = (Class) Iterable.class; var expectedTarget = (Class) String.class; var expectedRequestParamValue = "cool-projection"; given(nativeWebRequestMock.getParameter(REQUEST_PARAM_NAME)).willReturn(expectedRequestParamValue); given(methodParameterMock.getParameterAnnotation(ProjectionType.class)).willReturn(projectionTypeMock); given(projectionTypeMock.value()).willReturn(expectedTarget); given(projectionServiceMock.getByNameOrDefault(expectedRequestParamValue, expectedTarget)) .willReturn(expectedProjection); var actualProjection = argumentResolver.resolveArgument(methodParameterMock, null, nativeWebRequestMock, null); assertThat(actualProjection).isEqualTo(expectedProjection); }
@Override public Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { var desiredProjectionName = webRequest.getParameter(projectionParamName); var projectionTarget = parameter.getParameterAnnotation(ProjectionType.class).value(); if(Objects.isNull(desiredProjectionName) || desiredProjectionName.isEmpty()) { return projectionService.getDefault(projectionTarget); } return projectionService.getByNameOrDefault(desiredProjectionName, projectionTarget); }
ProjectionTypeArgumentResolver implements HandlerMethodArgumentResolver { @Override public Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { var desiredProjectionName = webRequest.getParameter(projectionParamName); var projectionTarget = parameter.getParameterAnnotation(ProjectionType.class).value(); if(Objects.isNull(desiredProjectionName) || desiredProjectionName.isEmpty()) { return projectionService.getDefault(projectionTarget); } return projectionService.getByNameOrDefault(desiredProjectionName, projectionTarget); } }
ProjectionTypeArgumentResolver implements HandlerMethodArgumentResolver { @Override public Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { var desiredProjectionName = webRequest.getParameter(projectionParamName); var projectionTarget = parameter.getParameterAnnotation(ProjectionType.class).value(); if(Objects.isNull(desiredProjectionName) || desiredProjectionName.isEmpty()) { return projectionService.getDefault(projectionTarget); } return projectionService.getByNameOrDefault(desiredProjectionName, projectionTarget); } @Autowired  ProjectionTypeArgumentResolver(ProjectionService projectionService, ProjectBoardConfigurationProperties properties); }
ProjectionTypeArgumentResolver implements HandlerMethodArgumentResolver { @Override public Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { var desiredProjectionName = webRequest.getParameter(projectionParamName); var projectionTarget = parameter.getParameterAnnotation(ProjectionType.class).value(); if(Objects.isNull(desiredProjectionName) || desiredProjectionName.isEmpty()) { return projectionService.getDefault(projectionTarget); } return projectionService.getByNameOrDefault(desiredProjectionName, projectionTarget); } @Autowired  ProjectionTypeArgumentResolver(ProjectionService projectionService, ProjectBoardConfigurationProperties properties); @Override boolean supportsParameter(MethodParameter parameter); @Override Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory); }
ProjectionTypeArgumentResolver implements HandlerMethodArgumentResolver { @Override public Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { var desiredProjectionName = webRequest.getParameter(projectionParamName); var projectionTarget = parameter.getParameterAnnotation(ProjectionType.class).value(); if(Objects.isNull(desiredProjectionName) || desiredProjectionName.isEmpty()) { return projectionService.getDefault(projectionTarget); } return projectionService.getByNameOrDefault(desiredProjectionName, projectionTarget); } @Autowired  ProjectionTypeArgumentResolver(ProjectionService projectionService, ProjectBoardConfigurationProperties properties); @Override boolean supportsParameter(MethodParameter parameter); @Override Class<?> resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory);  }