use of com.nixmash.blog.jpa.dto.CategoryDTO in project nixmash-blog by mintster.
the class PostServiceTests method createCategory.
@Test
public void createCategory() {
CategoryDTO categoryDTO = new CategoryDTO(WOW_CATEGORY_NAME);
long categoryId = postService.createCategory(categoryDTO).getCategoryId();
Category category = postService.getCategoryById(categoryId);
assertTrue(category.getCategoryValue().equals(WOW_CATEGORY_NAME));
}
use of com.nixmash.blog.jpa.dto.CategoryDTO in project nixmash-blog by mintster.
the class PostServiceTests method startCount_isEqual_to_endCount.
private boolean startCount_isEqual_to_endCount(long categoryId) {
int startCount = postService.getAllCategories().size();
Category category = postService.getCategoryById(categoryId);
postService.deleteCategory(new CategoryDTO(categoryId, "something", 0, true, false), null);
int endCount = postService.getAllCategories().size();
return startCount == endCount;
}
use of com.nixmash.blog.jpa.dto.CategoryDTO in project nixmash-blog by mintster.
the class PostServiceTests method uncategorizedCategoryIsNotUpdated.
@Test
public void uncategorizedCategoryIsNotUpdated() throws Exception {
// H2Data Status: Uncategorized is CategoryId 1
Category uncategorized = postService.getCategoryById(1L);
assertEquals(uncategorized.getCategoryValue(), "Uncategorized");
Category updated = postService.updateCategory(new CategoryDTO(1L, "Categorized", 0, true, false));
uncategorized = postService.getCategoryById(1L);
assertEquals(uncategorized.getCategoryValue(), "Uncategorized");
}
use of com.nixmash.blog.jpa.dto.CategoryDTO in project nixmash-blog by mintster.
the class AdminPostsController method categoryList.
// endregion
// region Categories
@RequestMapping(value = "/categories", method = GET)
public ModelAndView categoryList(Model model) {
ModelAndView mav = new ModelAndView();
List<CategoryDTO> categories = postService.getAdminCategories();
mav.addObject("categories", categories);
mav.addObject("newCategory", new Category());
mav.setViewName(ADMIN_CATEGORIES_VIEW);
return mav;
}
use of com.nixmash.blog.jpa.dto.CategoryDTO in project nixmash-blog by mintster.
the class PostServiceTests method deletedCategoryIncreasesUncategorizedBySame.
@Test
public void deletedCategoryIncreasesUncategorizedBySame() throws Exception {
// H2 "ShortTimer" category removed, existing posts assigned "uncategorized"
int startCount = postService.getAllPostsByCategoryId(1L).size();
List<Post> posts = postService.getAllPostsByCategoryId(6L);
int postCount = posts.size();
postService.deleteCategory(new CategoryDTO(6L, "shorttimer", 1, true, false), posts);
int endCount = postService.getAllPostsByCategoryId(1L).size();
assertEquals(endCount, startCount + postCount);
}
Aggregations