use of com.nixmash.blog.jpa.dto.PostDTO in project nixmash-blog by mintster.
the class PostCachingTests method savedPostIsRetrievedFromCache.
@Test
public void savedPostIsRetrievedFromCache() throws Exception {
String appender = "post-cache";
PostDTO postDTO = PostTestUtils.createPostDTO(appender);
String savedPostName = String.format("%s-%s", POST_NAME, appender);
assertThat(postCache.get(savedPostName)).isNull();
Post post = postService.add(postDTO);
long postId = post.getPostId();
String postName = post.getPostName();
assertNull(postCache.get(post.getPostName()));
assertNull(postCache.get(postId));
Post postById = postService.getPostById(postId);
Post postByName = postService.getPost(postName);
assertThat((Post) postCache.get(postName).get()).isEqualTo(postByName);
assertThat((Post) postCache.get(postId).get()).isEqualTo(postById);
}
use of com.nixmash.blog.jpa.dto.PostDTO 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.dto.PostDTO 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.dto.PostDTO 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.dto.PostDTO in project nixmash-blog by mintster.
the class PostServiceTests method postDtoToPostShouldRetainPostSource.
@Test
public void postDtoToPostShouldRetainPostSource() {
PostDTO postDTO = PostDTO.getBuilder(USER_ID, POST_TITLE, POST_NAME, "http://wellformed.link", POST_CONTENT, POST_TYPE, DISPLAY_TYPE, CATEGORY_ID, TWITTER_CARD_SUMMARY).build();
assertEquals(postDTO.getPostSource(), "wellformed.link");
Post post = postDtoToPost(postDTO);
assertEquals(post.getPostSource(), "wellformed.link");
}
Aggregations