Search in sources :

Example 21 with UriInfo

use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.

the class WebAppNotFoundResponseFilterTest method filterDoesNotFilterApplicationJson.

@Test
public void filterDoesNotFilterApplicationJson() throws Exception {
    final UriInfo uriInfo = mock(UriInfo.class);
    final List<MediaType> mediaTypes = Collections.singletonList(MediaType.APPLICATION_JSON_TYPE);
    when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
    when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
    when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
    filter.filter(requestContext, responseContext);
    verify(responseContext, never()).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Also used : MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 22 with UriInfo

use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.

the class WebAppNotFoundResponseFilterTest method filterDoesNotFilterRestApiPrefix.

@Test
public void filterDoesNotFilterRestApiPrefix() throws Exception {
    final UriInfo uriInfo = mock(UriInfo.class);
    final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
    when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/api/search"));
    when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
    when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
    filter.filter(requestContext, responseContext);
    verify(responseContext, never()).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Also used : MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 23 with UriInfo

use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.

the class WebAppNotFoundResponseFilterTest method filterDoesNotFilterPostRequests.

@Test
public void filterDoesNotFilterPostRequests() throws Exception {
    final UriInfo uriInfo = mock(UriInfo.class);
    final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
    when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/nonexisting"));
    when(requestContext.getMethod()).thenReturn(CK_METHOD_POST);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
    when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
    filter.filter(requestContext, responseContext);
    verify(responseContext, never()).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Also used : MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 24 with UriInfo

use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.

the class WebAppNotFoundResponseFilterTest method filterDoesFilterCompatibleAcceptMimeTypes.

@Test
public void filterDoesFilterCompatibleAcceptMimeTypes() throws Exception {
    final UriInfo uriInfo = mock(UriInfo.class);
    final List<MediaType> mediaTypes = Collections.singletonList(MediaType.WILDCARD_TYPE);
    when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
    when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
    when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
    filter.filter(requestContext, responseContext);
    verify(responseContext, times(1)).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Also used : MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 25 with UriInfo

use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.

the class WebAppNotFoundResponseFilterTest method filterDoesNotFilterResponseStatusOk.

@Test
public void filterDoesNotFilterResponseStatusOk() throws Exception {
    final UriInfo uriInfo = mock(UriInfo.class);
    final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
    when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
    when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
    when(responseContext.getStatusInfo()).thenReturn(Response.Status.OK);
    filter.filter(requestContext, responseContext);
    verify(responseContext, never()).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Also used : MediaType(javax.ws.rs.core.MediaType) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

UriInfo (javax.ws.rs.core.UriInfo)86 Response (javax.ws.rs.core.Response)44 Test (org.junit.Test)43 URI (java.net.URI)31 Test (org.testng.annotations.Test)21 Request (org.apache.atlas.catalog.Request)12 ResourceProvider (org.apache.atlas.catalog.ResourceProvider)12 TaxonomyResourceProvider (org.apache.atlas.catalog.TaxonomyResourceProvider)12 MetadataService (org.apache.atlas.services.MetadataService)12 AtlasTypeDefStore (org.apache.atlas.store.AtlasTypeDefStore)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 MediaType (javax.ws.rs.core.MediaType)10 Api (io.swagger.annotations.Api)8 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiParam (io.swagger.annotations.ApiParam)8 ApiResponse (io.swagger.annotations.ApiResponse)8 ApiResponses (io.swagger.annotations.ApiResponses)8 InputStream (java.io.InputStream)8