use of com.nixmash.blog.jpa.model.Post 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);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostServiceTests method addPostDTO.
// region Posts
@Test
public void addPostDTO() throws DuplicatePostNameException {
PostDTO postDTO = PostTestUtils.createPostDTO(1);
Post post = postService.add(postDTO);
assertNotNull(post);
}
use of com.nixmash.blog.jpa.model.Post 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");
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostServiceTests method addPostWithTags.
// endregion
// region Tags
@Test
public void addPostWithTags() throws DuplicatePostNameException, PostNotFoundException {
PostDTO postDTO = PostTestUtils.createPostDTO(3);
postDTO.getTags().add(new TagDTO("addPostWithTags1"));
postDTO.getTags().add(new TagDTO("addPostWithTags2"));
Post post = postService.add(postDTO);
assertEquals(post.getTags().size(), 2);
Post retrieved = postService.getPostById(post.getPostId());
assertEquals(retrieved.getTags().size(), 2);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostServiceTests method getAllPostsIsGreaterThanPagedTotal.
@Test
public void getAllPostsIsGreaterThanPagedTotal() {
List<Post> posts = postService.getAllPosts();
assertThat(posts.size(), Matchers.greaterThan(3));
ZonedDateTime firstPostDate = posts.get(0).getPostDate();
ZonedDateTime secondPostDate = posts.get(1).getPostDate();
// firstPostDate is higher (more recent) than secondPostDate with [sort: postDate: DESC]
assertTrue(firstPostDate.compareTo(secondPostDate) > 0);
}
Aggregations