@Test public void shouldGetCategoryPicture() throws IOException { final Response response = target(CATEGORY_ID).path("picture").request().get(); assertEquals(OK_200, response.getStatus()); MultivaluedMap<String, Object> headers = response.getHeaders(); String contentType = (String) headers.getFirst(HttpHeader.CONTENT_TYPE.asString()); String etag = (String) headers.getFirst("ETag"); assertEquals(mockImage.getType(), contentType); File result = response.readEntity(File.class); byte[] fileContent = Files.readAllBytes(Paths.get(result.getAbsolutePath())); assertTrue(Arrays.equals(fileContent, apiLogoContent)); String expectedTag = '"'+Integer.toString(new String(fileContent).hashCode())+'"'; assertEquals(expectedTag, etag); final Response cachedResponse = target(CATEGORY_ID).path("picture").request().header(HttpHeader.IF_NONE_MATCH.asString(), etag).get(); assertEquals(NOT_MODIFIED_304, cachedResponse.getStatus()); }
@GET @Produces(APPLICATION_JSON) public Response get(@PathParam("categoryId") String categoryId) { CategoryEntity category = categoryService.findNotHiddenById(categoryId); Set<ApiEntity> apis = apiService.findPublishedByUser(getAuthenticatedUserOrNull()); category.setTotalApis(categoryService.getTotalApisByCategory(apis, category)); return Response .ok(categoryMapper.convert(category, uriInfo.getBaseUriBuilder())) .build(); }
CategoryResource extends AbstractResource { @GET @Produces(APPLICATION_JSON) public Response get(@PathParam("categoryId") String categoryId) { CategoryEntity category = categoryService.findNotHiddenById(categoryId); Set<ApiEntity> apis = apiService.findPublishedByUser(getAuthenticatedUserOrNull()); category.setTotalApis(categoryService.getTotalApisByCategory(apis, category)); return Response .ok(categoryMapper.convert(category, uriInfo.getBaseUriBuilder())) .build(); } }
CategoryResource extends AbstractResource { @GET @Produces(APPLICATION_JSON) public Response get(@PathParam("categoryId") String categoryId) { CategoryEntity category = categoryService.findNotHiddenById(categoryId); Set<ApiEntity> apis = apiService.findPublishedByUser(getAuthenticatedUserOrNull()); category.setTotalApis(categoryService.getTotalApisByCategory(apis, category)); return Response .ok(categoryMapper.convert(category, uriInfo.getBaseUriBuilder())) .build(); }  }
CategoryResource extends AbstractResource { @GET @Produces(APPLICATION_JSON) public Response get(@PathParam("categoryId") String categoryId) { CategoryEntity category = categoryService.findNotHiddenById(categoryId); Set<ApiEntity> apis = apiService.findPublishedByUser(getAuthenticatedUserOrNull()); category.setTotalApis(categoryService.getTotalApisByCategory(apis, category)); return Response .ok(categoryMapper.convert(category, uriInfo.getBaseUriBuilder())) .build(); }  @GET @Produces(APPLICATION_JSON) Response get(@PathParam("categoryId") String categoryId); @GET @Path("picture") Response picture(@Context Request request, @PathParam("categoryId") String categoryId); @GET @Path("background") Response background(@Context Request request, @PathParam("categoryId") String categoryId); }
CategoryResource extends AbstractResource { @GET @Produces(APPLICATION_JSON) public Response get(@PathParam("categoryId") String categoryId) { CategoryEntity category = categoryService.findNotHiddenById(categoryId); Set<ApiEntity> apis = apiService.findPublishedByUser(getAuthenticatedUserOrNull()); category.setTotalApis(categoryService.getTotalApisByCategory(apis, category)); return Response .ok(categoryMapper.convert(category, uriInfo.getBaseUriBuilder())) .build(); }  @GET @Produces(APPLICATION_JSON) Response get(@PathParam("categoryId") String categoryId); @GET @Path("picture") Response picture(@Context Request request, @PathParam("categoryId") String categoryId); @GET @Path("background") Response background(@Context Request request, @PathParam("categoryId") String categoryId);  }