Search in sources :

Example 6 with Category

use of com.nixmash.blog.jpa.model.Category 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;
}
Also used : CategoryDTO(com.nixmash.blog.jpa.dto.CategoryDTO) Category(com.nixmash.blog.jpa.model.Category) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 7 with Category

use of com.nixmash.blog.jpa.model.Category in project nixmash-blog by mintster.

the class PostServiceTests method uncategorizedCategory.

@Test
public void uncategorizedCategory() throws CategoryNotFoundException {
    Category category = postService.getCategory(UNCATEGORIZED);
    assertEquals(category.getCategoryValue(), UNCATEGORIZED);
}
Also used : Category(com.nixmash.blog.jpa.model.Category) Test(org.junit.Test)

Example 8 with Category

use of com.nixmash.blog.jpa.model.Category in project nixmash-blog by mintster.

the class PostServiceTests method newPostContainsAssignedCategory.

@Test
public void newPostContainsAssignedCategory() throws DuplicatePostNameException {
    PostDTO postDTO = PostTestUtils.createPostDTO(100);
    postDTO.setCategoryId(2L);
    Post post = postService.add(postDTO);
    assertNotNull(post);
    assertNotNull(post.getCategory());
    Category category = post.getCategory();
    assertEquals(category.getCategoryValue(), "Java");
}
Also used : Category(com.nixmash.blog.jpa.model.Category) Post(com.nixmash.blog.jpa.model.Post) PostUtils.postDtoToPost(com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost) PostDTO(com.nixmash.blog.jpa.dto.PostDTO) Test(org.junit.Test)

Example 9 with Category

use of com.nixmash.blog.jpa.model.Category in project nixmash-blog by mintster.

the class PostServiceTests method setDefaultCategoryResultsInSingleDefault.

@Test
public void setDefaultCategoryResultsInSingleDefault() throws Exception {
    // H2Data Status: Java Category is Sole Default
    Category category = postService.getCategory("wannabe");
    assertEquals(category.getIsDefault(), false);
    assertEquals(defaultCategoryCount(), 1);
    // Sole Default will be Wannabe Category
    Category updated = postService.updateCategory(new CategoryDTO(5L, "Wannabe", 0, true, true));
    assertEquals(category.getIsDefault(), true);
    assertEquals(defaultCategoryCount(), 1);
}
Also used : CategoryDTO(com.nixmash.blog.jpa.dto.CategoryDTO) Category(com.nixmash.blog.jpa.model.Category) Test(org.junit.Test)

Aggregations

Category (com.nixmash.blog.jpa.model.Category)9 Test (org.junit.Test)6 CategoryDTO (com.nixmash.blog.jpa.dto.CategoryDTO)5 PostDTO (com.nixmash.blog.jpa.dto.PostDTO)1 Post (com.nixmash.blog.jpa.model.Post)1 PostUtils.postDtoToPost (com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1