### Question:
QualityEmailService { String formatDate(Date date) { if (date == null) { return StringUtils.EMPTY; } return new SimpleDateFormat("MMM d, yyyy - HH:mm", Locale.US).format(date); }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId);  }### Answer:
@Test public void formatDate_should_return_empty_string_when_date_is_null() { final String formattedDate = cut.formatDate(null); assertThat(formattedDate).isEmpty(); }
@Test public void formatDate_should_return_formatted_date() { final Locale initialDefaultLocale = Locale.getDefault(); try { Locale.setDefault(Locale.ENGLISH); final String formattedDate = cut.formatDate(THE_APRIL_25TH_2017_AT_12_H_57_MIN_56_S); assertThat(formattedDate).isEqualTo("Apr 25, 2017 - 12:57"); } finally { Locale.setDefault(initialDefaultLocale); } }
@Test public void formatDate_should_return_formatted_date_in_english_locale() { final Locale initialDefaultLocale = Locale.getDefault(); try { Locale.setDefault(Locale.FRENCH); final String formattedDate = cut.formatDate(THE_APRIL_25TH_2017_AT_12_H_57_MIN_56_S); assertThat(formattedDate).isEqualTo("Apr 25, 2017 - 12:57"); } finally { Locale.setDefault(initialDefaultLocale); } }