use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class PostServiceTests method updatePostWithTags.
@Test
public void updatePostWithTags() throws DuplicatePostNameException, PostNotFoundException {
// Post(5L) is loaded with 2 tags in H2
Post post = postService.getPostById(5L);
PostDTO postDTO = PostUtils.postToPostDTO(post);
postDTO.getTags().add(new TagDTO("updatePostWithTags1"));
Post updated = postService.update(postDTO);
assertEquals(updated.getTags().size(), 3);
Post retrieved = postService.getPostById(5L);
assertEquals(retrieved.getTags().size(), 3);
}
use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class PostServiceTests method builderShouldReturn_Null_ForNullLink.
@Test
public void builderShouldReturn_Null_ForNullLink() {
PostDTO postDTO = PostDTO.getBuilder(USER_ID, POST_TITLE, POST_NAME, null, POST_CONTENT, POST_TYPE, DISPLAY_TYPE, CATEGORY_ID, TWITTER_CARD_SUMMARY).build();
assertEquals(postDTO.getPostSource(), null);
}
use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class PostServiceTests method postDtoToPostShouldRetainPostSourceOf_NA_ForNullLink.
@Test
public void postDtoToPostShouldRetainPostSourceOf_NA_ForNullLink() {
PostDTO postDTO = PostDTO.getBuilder(USER_ID, POST_TITLE, POST_NAME, null, POST_CONTENT, POST_TYPE, DISPLAY_TYPE, CATEGORY_ID, TWITTER_CARD_SUMMARY).build();
assertEquals(postDTO.getPostSource(), null);
Post post = postDtoToPost(postDTO);
assertEquals(post.getPostSource(), null);
}
use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class PostCachingTests method updatedPostIsRetrievedFromCache.
@Test
public void updatedPostIsRetrievedFromCache() throws Exception {
// Confirm our pagedPosts Cache is populated
postService.getPublishedPosts(0, 10);
assertThat(pagedPostsCache.get("0-10")).isNotNull();
// Update Post Title and call Post Update Service
String newTitle = "Something Wonderful";
Post post = postService.getPostById(1L);
String originalPostName = post.getPostName();
PostDTO postDTO = PostUtils.postToPostDTO(post);
postDTO.setPostTitle(newTitle);
postService.update(postDTO);
// Updated Post with New Title in Post Caches by Name and PostId
// AFTER it is evicted - Updated v0.4.5
assertNull(postCache.get(post.getPostName()));
postService.getPost(originalPostName);
Post postByName = (Post) postCache.get(post.getPostName()).get();
assertThat(postByName.getPostTitle()).isEqualTo(newTitle);
assertNull(postCache.get(post.getPostId()));
postService.getPostById(1L);
Post postById = (Post) postCache.get(post.getPostId()).get();
assertThat(postById.getPostTitle()).isEqualTo(newTitle);
// Paged Posts cache evicted on Post Update, rebuilt on next call
assertThat(pagedPostsCache.get("0-10")).isNull();
postService.getPublishedPosts(0, 10);
assertThat(pagedPostsCache.get("0-10")).isNotNull();
}
use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class SolrPostTests method updatedPost.
private Post updatedPost(String postTitle) throws PostNotFoundException {
Post post = postService.getPostById(10L);
PostDTO postDTO = PostUtils.postToPostDTO(post);
postDTO.setPostTitle(postTitle);
return postService.update(postDTO);
}
Aggregations