@Test void testCreateEnglishMailText() { ImportRun importRun = mock(ImportRun.class); when(importRun.getMessage()).thenReturn("Entity already exists."); when(importRun.getStatus()).thenReturn(FAILED.toString()); Instant startDate = Instant.parse("2016-02-13T12:34:56.217Z"); when(importRun.getStartDate()).thenReturn(startDate); Instant endDate = Instant.parse("2016-02-13T12:35:12.231Z"); when(importRun.getEndDate()).thenReturn(Optional.of(endDate)); String mailText = importRunService.createEnglishMailText(importRun, ZoneId.of("Europe/Amsterdam")); assertEquals( "The import started by you on Saturday, February 13, 2016 at 1:34:56 PM Central European Standard Time finished on 1:35:12 PM with status: FAILED\n" + "Message:\n" + "Entity already exists.", mailText); }
@SuppressWarnings("java:S3457") String createEnglishMailText(ImportRun importRun, ZoneId zone) { ZonedDateTime start = importRun.getStartDate().atZone(zone); ZonedDateTime end = importRun .getEndDate() .orElseThrow(() -> new IllegalStateException("ImportRun must have an end date")) .atZone(zone); String startDateTimeString = ofLocalizedDateTime(FULL).withLocale(ENGLISH).format(start); String endTimeString = ofLocalizedTime(MEDIUM).withLocale(ENGLISH).format(end); return String.format( "The import started by you on %1s finished on %2s with status: %3s\nMessage:\n%4s", startDateTimeString, endTimeString, importRun.getStatus(), importRun.getMessage()); }
ImportRunService { @SuppressWarnings("java:S3457") String createEnglishMailText(ImportRun importRun, ZoneId zone) { ZonedDateTime start = importRun.getStartDate().atZone(zone); ZonedDateTime end = importRun .getEndDate() .orElseThrow(() -> new IllegalStateException("ImportRun must have an end date")) .atZone(zone); String startDateTimeString = ofLocalizedDateTime(FULL).withLocale(ENGLISH).format(start); String endTimeString = ofLocalizedTime(MEDIUM).withLocale(ENGLISH).format(end); return String.format( "The import started by you on %1s finished on %2s with status: %3s\nMessage:\n%4s", startDateTimeString, endTimeString, importRun.getStatus(), importRun.getMessage()); } }
ImportRunService { @SuppressWarnings("java:S3457") String createEnglishMailText(ImportRun importRun, ZoneId zone) { ZonedDateTime start = importRun.getStartDate().atZone(zone); ZonedDateTime end = importRun .getEndDate() .orElseThrow(() -> new IllegalStateException("ImportRun must have an end date")) .atZone(zone); String startDateTimeString = ofLocalizedDateTime(FULL).withLocale(ENGLISH).format(start); String endTimeString = ofLocalizedTime(MEDIUM).withLocale(ENGLISH).format(end); return String.format( "The import started by you on %1s finished on %2s with status: %3s\nMessage:\n%4s", startDateTimeString, endTimeString, importRun.getStatus(), importRun.getMessage()); } ImportRunService(
      DataService dataService,
      MailSender mailSender,
      UserService userService,
      ContextMessageSource contextMessageSource,
      ImportRunFactory importRunFactory); }
ImportRunService { @SuppressWarnings("java:S3457") String createEnglishMailText(ImportRun importRun, ZoneId zone) { ZonedDateTime start = importRun.getStartDate().atZone(zone); ZonedDateTime end = importRun .getEndDate() .orElseThrow(() -> new IllegalStateException("ImportRun must have an end date")) .atZone(zone); String startDateTimeString = ofLocalizedDateTime(FULL).withLocale(ENGLISH).format(start); String endTimeString = ofLocalizedTime(MEDIUM).withLocale(ENGLISH).format(end); return String.format( "The import started by you on %1s finished on %2s with status: %3s\nMessage:\n%4s", startDateTimeString, endTimeString, importRun.getStatus(), importRun.getMessage()); } ImportRunService(
      DataService dataService,
      MailSender mailSender,
      UserService userService,
      ContextMessageSource contextMessageSource,
      ImportRunFactory importRunFactory); ImportRun addImportRun(String userName, boolean notify); }
ImportRunService { @SuppressWarnings("java:S3457") String createEnglishMailText(ImportRun importRun, ZoneId zone) { ZonedDateTime start = importRun.getStartDate().atZone(zone); ZonedDateTime end = importRun .getEndDate() .orElseThrow(() -> new IllegalStateException("ImportRun must have an end date")) .atZone(zone); String startDateTimeString = ofLocalizedDateTime(FULL).withLocale(ENGLISH).format(start); String endTimeString = ofLocalizedTime(MEDIUM).withLocale(ENGLISH).format(end); return String.format( "The import started by you on %1s finished on %2s with status: %3s\nMessage:\n%4s", startDateTimeString, endTimeString, importRun.getStatus(), importRun.getMessage()); } ImportRunService(
      DataService dataService,
      MailSender mailSender,
      UserService userService,
      ContextMessageSource contextMessageSource,
      ImportRunFactory importRunFactory); ImportRun addImportRun(String userName, boolean notify);  }