### Question:
ImageUploadController { @ExceptionHandler(value = ImageSizeException.class) @ResponseBody public FailJsonResponse handleImageSizeException(ImageSizeException e, Locale locale) { Object[] parameters = new Object[]{e.getMaxSize()}; String errorMessage = messageSource.getMessage(WRONG_SIZE_RESOURCE_MESSAGE, parameters, locale); return new FailJsonResponse(JsonResponseReason.VALIDATION, errorMessage); } ImageUploadController(MessageSource messageSource); @ExceptionHandler(value = ImageSizeException.class) @ResponseBody FailJsonResponse handleImageSizeException(ImageSizeException e, Locale locale); @ExceptionHandler(value = ImageFormatException.class) @ResponseBody FailJsonResponse handleImageFormatException(ImageFormatException e, Locale locale); @ExceptionHandler(value = ImageProcessException.class) @ResponseBody FailJsonResponse handleImageProcessException(ImageProcessException e, Locale locale); MessageSource getMessageSource(); Date getIfModifiedSinceDate(String ifModifiedSinceHeader);  }### Answer:
@Test public void handleImageSizeExceptionShouldReturnValidationErrorAndErrorMessage() { int maxSize = 1000; ImageSizeException exception = new ImageSizeException(maxSize); Locale locale = Locale.ENGLISH; String expectedMessage = "a message " + maxSize; when(messageSource.getMessage( Matchers.anyString(), Matchers.any(Object[].class), Matchers.any(Locale.class)) ).thenReturn(expectedMessage); FailJsonResponse result = imageUploadController.handleImageSizeException(exception, locale); assertEquals(result.getStatus(), JsonResponseStatus.FAIL, "We have an exception, so we should get false value."); assertEquals(result.getReason(), JsonResponseReason.VALIDATION, "Failture reason should be validation"); assertEquals(result.getResult(), expectedMessage, "Result contains incorrect message."); }