### Question:
StaticContentHandler { static void processModifyHeaders(Instant modified, RequestHeaders requestHeaders, ResponseHeaders responseHeaders) { if (modified == null) { return; } responseHeaders.lastModified(modified); Optional<Instant> ifModSince = requestHeaders .ifModifiedSince() .map(ChronoZonedDateTime::toInstant); if (ifModSince.isPresent() && !ifModSince.get().isBefore(modified)) { throw new HttpException("Not valid for If-Modified-Since header!", Http.Status.NOT_MODIFIED_304); } Optional<Instant> ifUnmodSince = requestHeaders .ifUnmodifiedSince() .map(ChronoZonedDateTime::toInstant); if (ifUnmodSince.isPresent() && ifUnmodSince.get().isBefore(modified)) { throw new HttpException("Not valid for If-Unmodified-Since header!", Http.Status.PRECONDITION_FAILED_412); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector);   }### Answer:
@Test public void ifModifySince_Accept() throws Exception { ZonedDateTime modified = ZonedDateTime.now(); RequestHeaders req = mock(RequestHeaders.class); Mockito.doReturn(Optional.of(modified.minusSeconds(60))).when(req).ifModifiedSince(); Mockito.doReturn(Optional.empty()).when(req).ifUnmodifiedSince(); ResponseHeaders res = mock(ResponseHeaders.class); StaticContentHandler.processModifyHeaders(modified.toInstant(), req, res); }
@Test public void ifModifySince_NotAccept() throws Exception { ZonedDateTime modified = ZonedDateTime.now(); RequestHeaders req = mock(RequestHeaders.class); Mockito.doReturn(Optional.of(modified)).when(req).ifModifiedSince(); Mockito.doReturn(Optional.empty()).when(req).ifUnmodifiedSince(); ResponseHeaders res = mock(ResponseHeaders.class); assertHttpException(() -> StaticContentHandler.processModifyHeaders(modified.toInstant(), req, res), Http.Status.NOT_MODIFIED_304); }
@Test public void ifUnmodifySince_Accept() throws Exception { ZonedDateTime modified = ZonedDateTime.now(); RequestHeaders req = mock(RequestHeaders.class); Mockito.doReturn(Optional.of(modified)).when(req).ifUnmodifiedSince(); Mockito.doReturn(Optional.empty()).when(req).ifModifiedSince(); ResponseHeaders res = mock(ResponseHeaders.class); StaticContentHandler.processModifyHeaders(modified.toInstant(), req, res); }
@Test public void ifUnmodifySince_NotAccept() throws Exception { ZonedDateTime modified = ZonedDateTime.now(); RequestHeaders req = mock(RequestHeaders.class); Mockito.doReturn(Optional.of(modified.minusSeconds(60))).when(req).ifUnmodifiedSince(); Mockito.doReturn(Optional.empty()).when(req).ifModifiedSince(); ResponseHeaders res = mock(ResponseHeaders.class); assertHttpException(() -> StaticContentHandler.processModifyHeaders(modified.toInstant(), req, res), Http.Status.PRECONDITION_FAILED_412); }