use of org.graylog.plugins.views.search.export.ExportFormat 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 org.graylog.plugins.views.search.export.ExportFormat 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);
}
Aggregations