use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostRepoTests method newLinkHasPostSourceDomain.
@Test
public void newLinkHasPostSourceDomain() {
Post post = Post.getBuilder(1L, "New Link", "new-link", "http://linksource.com", "New link content!", PostType.LINK, PostDisplayType.LINK_SUMMARY).tags(getTestTags(2)).category(getTestCategory()).build();
Post saved = postRepository.save(post);
assertNotNull(saved);
assertEquals(saved.getPostType(), PostType.LINK);
// postSource is domain of url passed to builder
assertEquals(saved.getPostSource(), "linksource.com");
}
use of com.nixmash.blog.jpa.model.Post 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.model.Post in project nixmash-blog by mintster.
the class PostCachingTests method validateCacheByPostId.
@Test
public void validateCacheByPostId() throws Exception {
assertThat(postCache.get(1L)).isNull();
Post post = postService.getPostById(1L);
assertThat((Post) postCache.get(post.getPostId()).get()).isEqualTo(post);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostServiceTests method postContainsAuthorObject.
@Test
public void postContainsAuthorObject() throws Exception {
Post post = postService.getPostById(1L);
assertNotNull(post.author);
}
use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.
the class PostServiceTests method findAllWithPaging.
@Test
public void findAllWithPaging() {
Slice<Post> posts = postService.getPosts(0, 3);
assertEquals(posts.getSize(), 3);
ZonedDateTime firstPostDate = posts.getContent().get(0).getPostDate();
ZonedDateTime secondPostDate = posts.getContent().get(1).getPostDate();
// firstPostDate is higher (more recent) than secondPostDate with [sort: postDate: DESC]
assertTrue(firstPostDate.compareTo(secondPostDate) > 0);
}
Aggregations