use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method returns415IfNoFormatIsPresent.
@Test
void returns415IfNoFormatIsPresent() throws Exception {
final ContainerRequestFilter filter = new MessageExportFormatFilter(Collections.emptySet());
final ContainerRequestContext requestContext = mockRequestContext();
filter.filter(requestContext);
verifyRequestAborted(requestContext);
}
use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method returns415IfNoAcceptedFormatIsSpecified.
@Test
void returns415IfNoAcceptedFormatIsSpecified() throws Exception {
final ContainerRequestFilter filter = new MessageExportFormatFilter(Collections.singleton(() -> MoreMediaTypes.TEXT_PLAIN_TYPE));
final ContainerRequestContext requestContext = mockRequestContext(Collections.emptyList());
filter.filter(requestContext);
verifyRequestAborted(requestContext);
}
use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method filtersAcceptedMediaTypesToEnabledOnes.
@Test
void filtersAcceptedMediaTypesToEnabledOnes() throws Exception {
final ExportFormat plainTextExportFormat = () -> MoreMediaTypes.TEXT_PLAIN_TYPE;
final ContainerRequestFilter filter = new MessageExportFormatFilter(ImmutableSet.of(disabledJsonExportFormat, plainTextExportFormat));
final ContainerRequestContext requestContext = mockRequestContext(ImmutableList.of(MoreMediaTypes.TEXT_CSV_TYPE, MoreMediaTypes.TEXT_PLAIN_TYPE, MoreMediaTypes.APPLICATION_JSON_TYPE));
filter.filter(requestContext);
verifyRequestNotAborted(requestContext);
assertThat(requestContext.getHeaders().get(HttpHeaders.ACCEPT)).containsExactly(MoreMediaTypes.TEXT_PLAIN);
}
use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method filtersAcceptedMediaTypesToExistingOnes.
@Test
void filtersAcceptedMediaTypesToExistingOnes() throws Exception {
final ExportFormat jsonExportFormat = () -> MoreMediaTypes.APPLICATION_JSON_TYPE;
final ExportFormat plainTextExportFormat = () -> MoreMediaTypes.TEXT_PLAIN_TYPE;
final ContainerRequestFilter filter = new MessageExportFormatFilter(ImmutableSet.of(jsonExportFormat, plainTextExportFormat));
final ContainerRequestContext requestContext = mockRequestContext(ImmutableList.of(MoreMediaTypes.TEXT_CSV_TYPE, MoreMediaTypes.TEXT_PLAIN_TYPE, MoreMediaTypes.APPLICATION_JSON_TYPE));
filter.filter(requestContext);
verifyRequestNotAborted(requestContext);
assertThat(requestContext.getHeaders().get(HttpHeaders.ACCEPT)).containsExactly(MoreMediaTypes.APPLICATION_JSON, MoreMediaTypes.TEXT_PLAIN);
}
use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method returns415IfNoCompatibleFormatIsFound.
@Test
void returns415IfNoCompatibleFormatIsFound() throws Exception {
final ContainerRequestFilter filter = new MessageExportFormatFilter(Collections.singleton(() -> MoreMediaTypes.TEXT_PLAIN_TYPE));
final ContainerRequestContext requestContext = mockRequestContext(Collections.singletonList(MoreMediaTypes.APPLICATION_JSON_TYPE));
filter.filter(requestContext);
verifyRequestAborted(requestContext);
}
Aggregations