@Test public void shouldDateFormatterFromReturnProperFormatter() throws Exception { Date date = new Date(); Function<Date, String> expectedPlainTextOperator = null; Function<Date, String> expectedHiddenOperator = null; Function<Date, String> expectedFirstDozenThenStartsOperator = null; ; Function<Date, String> expectedFullTextFromCommercialAtOperator = null; Function<Date, String> expectedFullTextUpToCommercialAtOperator = null; Function<Date, String> expectedStandardDateOperator = EmailFieldFormat::dateFormat; Function<Date, String> expectedStandardDateWithZoneIdOperator = EmailFieldFormat::dateFormatWithZoneId; Function<Date, String> givenPlainTextOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.PLAIN_TEXT); Function<Date, String> givenHiddenOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.HIDDEN); Function<Date, String> givenFirstDozenThenStartsOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.FIRST_DOZEN_THEN_STARS); Function<Date, String> givenFullTextFromCommercialAtOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.FULL_TEXT_FROM_COMMERCIAL_AT); Function<Date, String> givenFullTextUpToCommercialAtOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.FULL_TEXT_UP_TO_COMMERCIAL_AT); Function<Date, String> givenStandardDateOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.STANDARD_DATE_FORMAT); Function<Date, String> givenStandardDateWithZoneIdOperator = EmailFieldFormat.dateFormatterFrom(LoggingStrategy.STANDARD_DATE_FORMAT_WITH_ZONE_ID); assertions.assertThat(givenPlainTextOperator).isEqualTo(expectedPlainTextOperator).isNull(); assertions.assertThat(givenHiddenOperator).isEqualTo(expectedHiddenOperator).isNull(); assertions.assertThat(givenFirstDozenThenStartsOperator).isEqualTo(expectedFirstDozenThenStartsOperator).isNull(); assertions.assertThat(givenFullTextFromCommercialAtOperator).isEqualTo(expectedFullTextFromCommercialAtOperator).isNull(); assertions.assertThat(givenFullTextUpToCommercialAtOperator).isEqualTo(expectedFullTextUpToCommercialAtOperator).isNull(); assertions.assertThat(givenStandardDateOperator.apply(date)).isEqualTo(expectedStandardDateOperator.apply(date)); assertions.assertThat(givenStandardDateWithZoneIdOperator.apply(date)).isEqualTo(expectedStandardDateWithZoneIdOperator.apply(date)); }
public static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy) { switch (loggingStrategy) { case PLAIN_TEXT: break; case HIDDEN: break; case STANDARD_DATE_FORMAT: return EmailFieldFormat::dateFormat; case STANDARD_DATE_FORMAT_WITH_ZONE_ID: return EmailFieldFormat::dateFormatWithZoneId; case FIRST_DOZEN_THEN_STARS: case FULL_TEXT_FROM_COMMERCIAL_AT: case FULL_TEXT_UP_TO_COMMERCIAL_AT: default: logUnsupportedLoggingStrategy(loggingStrategy, "Date"); } return null; }
EmailFieldFormat { public static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy) { switch (loggingStrategy) { case PLAIN_TEXT: break; case HIDDEN: break; case STANDARD_DATE_FORMAT: return EmailFieldFormat::dateFormat; case STANDARD_DATE_FORMAT_WITH_ZONE_ID: return EmailFieldFormat::dateFormatWithZoneId; case FIRST_DOZEN_THEN_STARS: case FULL_TEXT_FROM_COMMERCIAL_AT: case FULL_TEXT_UP_TO_COMMERCIAL_AT: default: logUnsupportedLoggingStrategy(loggingStrategy, "Date"); } return null; } }
EmailFieldFormat { public static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy) { switch (loggingStrategy) { case PLAIN_TEXT: break; case HIDDEN: break; case STANDARD_DATE_FORMAT: return EmailFieldFormat::dateFormat; case STANDARD_DATE_FORMAT_WITH_ZONE_ID: return EmailFieldFormat::dateFormatWithZoneId; case FIRST_DOZEN_THEN_STARS: case FULL_TEXT_FROM_COMMERCIAL_AT: case FULL_TEXT_UP_TO_COMMERCIAL_AT: default: logUnsupportedLoggingStrategy(loggingStrategy, "Date"); } return null; }  }
EmailFieldFormat { public static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy) { switch (loggingStrategy) { case PLAIN_TEXT: break; case HIDDEN: break; case STANDARD_DATE_FORMAT: return EmailFieldFormat::dateFormat; case STANDARD_DATE_FORMAT_WITH_ZONE_ID: return EmailFieldFormat::dateFormatWithZoneId; case FIRST_DOZEN_THEN_STARS: case FULL_TEXT_FROM_COMMERCIAL_AT: case FULL_TEXT_UP_TO_COMMERCIAL_AT: default: logUnsupportedLoggingStrategy(loggingStrategy, "Date"); } return null; }  static UnaryOperator<String> textFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<InternetAddress, String> emailFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<Locale, String> localeFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static String plainText(final Locale locale); static String plainText(final InternetAddress internetAddress); static String plainText(final String text); static String firstDozenThenStars(final InternetAddress internetAddress); static String firstDozenThenStars(final String text); static String textFromAt(final InternetAddress internetAddress); static String textFromAt(final String text); static String textUpToAt(final InternetAddress internetAddress); static String textUpToAt(final String text); static String dateFormat(final Date date); static String dateFormatWithZoneId(final Date date); static String nullValue(); }
EmailFieldFormat { public static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy) { switch (loggingStrategy) { case PLAIN_TEXT: break; case HIDDEN: break; case STANDARD_DATE_FORMAT: return EmailFieldFormat::dateFormat; case STANDARD_DATE_FORMAT_WITH_ZONE_ID: return EmailFieldFormat::dateFormatWithZoneId; case FIRST_DOZEN_THEN_STARS: case FULL_TEXT_FROM_COMMERCIAL_AT: case FULL_TEXT_UP_TO_COMMERCIAL_AT: default: logUnsupportedLoggingStrategy(loggingStrategy, "Date"); } return null; }  static UnaryOperator<String> textFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<InternetAddress, String> emailFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<Locale, String> localeFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static Function<Date, String> dateFormatterFrom(@NonNull final LoggingStrategy loggingStrategy); static String plainText(final Locale locale); static String plainText(final InternetAddress internetAddress); static String plainText(final String text); static String firstDozenThenStars(final InternetAddress internetAddress); static String firstDozenThenStars(final String text); static String textFromAt(final InternetAddress internetAddress); static String textFromAt(final String text); static String textUpToAt(final InternetAddress internetAddress); static String textUpToAt(final String text); static String dateFormat(final Date date); static String dateFormatWithZoneId(final Date date); static String nullValue();  }