SentDateComparator extends AbstractHeaderComparator { @VisibleForTesting static String sanitizeDateStringHeaderValue(String value) { Matcher sanitizerMatcher = DATE_SANITIZING_PATTERN.matcher(value); if (sanitizerMatcher.find()) { return value.substring(0, sanitizerMatcher.start()); } return value; }  static Optional<ZonedDateTime> toISODate(String value); @Override int compare(MailboxMessage o1, MailboxMessage o2); static final Comparator<MailboxMessage> SENTDATE; }
@Test void sanitizeDateStringHeaderValueShouldRemoveCESTPart() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200 (CEST)")) .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200"); }
@Test void sanitizeDateStringHeaderValueShouldRemoveUTCPart() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200 (UTC) ")) .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200"); }
@Test void sanitizeDateStringHeaderValueShouldNotChangeAcceptableString() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200")) .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200"); }
@Test void sanitizeDateStringHeaderValueShouldRemoveBrackets() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe)")) .isEqualTo("invalid"); }
@Test void sanitizeDateStringHeaderValueShouldKeepUnclosedBrackets() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe")) .isEqualTo("invalid (removeMe"); }
@Test void sanitizeDateStringHeaderValueShouldNotChangeEmptyString() { assertThat(SentDateComparator.sanitizeDateStringHeaderValue("")) .isEqualTo(""); }