@Test public void shouldNotGetCategory() { doThrow(new CategoryNotFoundException(UNKNOWN_CATEGORY)).when(categoryService).findNotHiddenById(UNKNOWN_CATEGORY); final Response response = target(UNKNOWN_CATEGORY).request().get(); assertEquals(NOT_FOUND_404, response.getStatus()); ErrorResponse errorResponse = response.readEntity(ErrorResponse.class); List<Error> errors = errorResponse.getErrors(); assertNotNull(errors); assertEquals(1, errors.size()); Error error = errors.get(0); assertNotNull(error); assertEquals("errors.category.notFound", error.getCode()); assertEquals("404", error.getStatus()); assertEquals("Category ["+UNKNOWN_CATEGORY+"] can not be found.", error.getMessage()); }
@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);  }