AppendCommandParser extends AbstractImapCommandParser { @VisibleForTesting LocalDateTime parseDateTime(ImapRequestLineReader request) throws DecodingException { char next = request.nextWordChar(); if (next == '"') { return request.dateTime(); } return LocalDateTime.now(clock); } AppendCommandParser(StatusResponseFactory statusResponseFactory, Clock clock);   }
@Test void parseDateTimeShouldReturnNowWhenNotADate() throws Exception { ImapRequestStreamLineReader request = toRequest("any\n"); assertThat(testee.parseDateTime(request).toInstant(ZoneOffset.UTC)).isEqualTo(DATE); }
@Test void parseDateTimeShouldNotConsumeNonDateLiteral() throws Exception { ImapRequestStreamLineReader request = toRequest("any\n"); testee.parseDateTime(request); assertThat(request.atom()).isEqualTo("any"); }
@Test void parseDateTimeShouldConsumeDateLiteral() throws Exception { ImapRequestStreamLineReader request = toRequest("\"09-Apr-2008 15:17:51 +0200\" any\n"); testee.parseDateTime(request); assertThat(request.atom()).isEqualTo("any"); }
@Test void parseDateTimeShouldReturnSuppliedValue() throws Exception { ImapRequestStreamLineReader request = toRequest("\"09-Apr-2008 15:17:51 +0000\""); assertThat( testee.parseDateTime(request) .atZone(ZoneOffset.systemDefault()) .withZoneSameInstant(ZoneOffset.UTC)) .isEqualTo("2008-04-09T15:17:51Z"); }