Search in sources :

Example 81 with ContainerRequestContext

use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.

the class MessageExportFormatFilterTest method mockRequestContext.

private ContainerRequestContext mockRequestContext(List<MediaType> acceptedMediaTypes) {
    final UriInfo uriInfo = uriInfo(VALID_PATH);
    final ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(acceptedMediaTypes);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    final MultivaluedMap<String, String> headers = new MultivaluedStringMap(1);
    headers.put(HttpHeaders.ACCEPT, acceptedMediaTypes.stream().map(MediaType::toString).collect(Collectors.toList()));
    when(requestContext.getHeaders()).thenReturn(headers);
    return requestContext;
}
Also used : MultivaluedStringMap(org.glassfish.jersey.internal.util.collection.MultivaluedStringMap) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo)

Aggregations

ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)81 Test (org.junit.Test)40 Response (javax.ws.rs.core.Response)32 UriInfo (javax.ws.rs.core.UriInfo)23 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)22 Test (org.junit.jupiter.api.Test)18 Resource (org.glassfish.jersey.server.model.Resource)15 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)14 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)12 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)10 File (java.io.File)8 ContainerResponseContext (javax.ws.rs.container.ContainerResponseContext)8 ResourceInfo (javax.ws.rs.container.ResourceInfo)8 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)8 IOException (java.io.IOException)7 URI (java.net.URI)6 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)6 FF4jAuthenticationFilter (org.ff4j.web.api.security.FF4jAuthenticationFilter)6 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)6 ApiKeyValidatorFilter (org.ff4j.web.api.filter.ApiKeyValidatorFilter)5