### Question:
DuplicateRequestParameterValidator implements AuthorizeRequestValidator { public void validateRequest(OAuth2Request request) throws InvalidClientException, InvalidRequestException, RedirectUriMismatchException, UnsupportedResponseTypeException, ServerException, BadRequestException, InvalidScopeException, NotFoundException, DuplicateRequestParameterException { Set<String> parameterNames = request.getParameterNames(); for (String parameterName : parameterNames) { if (request.getParameterCount(parameterName) > 1) { throw new DuplicateRequestParameterException("Invalid Request, duplicate request parameter found : " + parameterName); } } }  void validateRequest(OAuth2Request request);  }### Answer:
@Test(expectedExceptions = {DuplicateRequestParameterException.class}) public void shouldThrowInvalidRequestExceptionWhenDuplicateParameterFound() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameterNames()).willReturn(new HashSet<String>(Arrays.asList("someParam"))); given(request.getParameterCount("someParam")).willReturn(2); duplicateParamValidator.validateRequest(request); }
@Test public void shouldPassValidationWhenNoDuplicatesFound() throws Exception { OAuth2Request request = mock(OAuth2Request.class); given(request.getParameterNames()).willReturn(new HashSet<String>(Arrays.asList("someParam"))); given(request.getParameterCount("someParam")).willReturn(1); duplicateParamValidator.validateRequest(request); }