@Test(expected = WebApplicationException.class) public void getCategoryThrowsExceptionWhenCategoryNameIsBlank() { this.component.getCategory(" "); verify(this.logger).error("The category should not be blank."); Assert.fail("An exception should have been thrown for blank category."); }
@Override public Category getCategory(@Nonnull final String categoryName) { if (StringUtils.isBlank(categoryName)) { this.logger.error("The category should not be blank."); throw new WebApplicationException(Response.Status.BAD_REQUEST); } if (!this.vm.hasCategory(categoryName)) { this.logger.error("Could not find specified category: {}", categoryName); throw new WebApplicationException(Response.Status.NOT_FOUND); } return this.objectFactory.createLinkedCategoryRepresentation(categoryName, getCategoryLinks(), this::getVocabulariesForCategory); }
DefaultCategoryResource extends XWikiResource implements CategoryResource { @Override public Category getCategory(@Nonnull final String categoryName) { if (StringUtils.isBlank(categoryName)) { this.logger.error("The category should not be blank."); throw new WebApplicationException(Response.Status.BAD_REQUEST); } if (!this.vm.hasCategory(categoryName)) { this.logger.error("Could not find specified category: {}", categoryName); throw new WebApplicationException(Response.Status.NOT_FOUND); } return this.objectFactory.createLinkedCategoryRepresentation(categoryName, getCategoryLinks(), this::getVocabulariesForCategory); } }
DefaultCategoryResource extends XWikiResource implements CategoryResource { @Override public Category getCategory(@Nonnull final String categoryName) { if (StringUtils.isBlank(categoryName)) { this.logger.error("The category should not be blank."); throw new WebApplicationException(Response.Status.BAD_REQUEST); } if (!this.vm.hasCategory(categoryName)) { this.logger.error("Could not find specified category: {}", categoryName); throw new WebApplicationException(Response.Status.NOT_FOUND); } return this.objectFactory.createLinkedCategoryRepresentation(categoryName, getCategoryLinks(), this::getVocabulariesForCategory); }  }
DefaultCategoryResource extends XWikiResource implements CategoryResource { @Override public Category getCategory(@Nonnull final String categoryName) { if (StringUtils.isBlank(categoryName)) { this.logger.error("The category should not be blank."); throw new WebApplicationException(Response.Status.BAD_REQUEST); } if (!this.vm.hasCategory(categoryName)) { this.logger.error("Could not find specified category: {}", categoryName); throw new WebApplicationException(Response.Status.NOT_FOUND); } return this.objectFactory.createLinkedCategoryRepresentation(categoryName, getCategoryLinks(), this::getVocabulariesForCategory); }  @Override Category getCategory(@Nonnull final String categoryName); }
DefaultCategoryResource extends XWikiResource implements CategoryResource { @Override public Category getCategory(@Nonnull final String categoryName) { if (StringUtils.isBlank(categoryName)) { this.logger.error("The category should not be blank."); throw new WebApplicationException(Response.Status.BAD_REQUEST); } if (!this.vm.hasCategory(categoryName)) { this.logger.error("Could not find specified category: {}", categoryName); throw new WebApplicationException(Response.Status.NOT_FOUND); } return this.objectFactory.createLinkedCategoryRepresentation(categoryName, getCategoryLinks(), this::getVocabulariesForCategory); }  @Override Category getCategory(@Nonnull final String categoryName);  }