### Question:
ImageUploadController { public Date getIfModifiedSinceDate(String ifModifiedSinceHeader) { Date ifModifiedSinceDate = new Date(0); if (ifModifiedSinceHeader != null) { try { DateFormat dateFormat = new SimpleDateFormat( HTTP_HEADER_DATETIME_PATTERN, Locale.US); ifModifiedSinceDate = dateFormat.parse(ifModifiedSinceHeader); } catch (ParseException e) { LOGGER.error("Failed to parse value of 'If-Modified-Since' header from string form.", e); } } return ifModifiedSinceDate; } 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 testGetIfModifiedSinceDate() { long currentMillis = System.currentTimeMillis(); long currentTimeIgnoreMillis = (currentMillis / 1000) * 1000; Date date = new Date(currentTimeIgnoreMillis); String dateAsString = DateFormatUtils.format(date, ImageUploadController.HTTP_HEADER_DATETIME_PATTERN, Locale.US); Date result = imageUploadController.getIfModifiedSinceDate(dateAsString); assertEquals(result.getTime(), date.getTime()); }
@Test public void testGetIfModifiedSinceDateNullHeader() { Date result = imageUploadController.getIfModifiedSinceDate(null); assertEquals(result, new Date(0)); }