Search in sources :

Example 16 with PostDTO

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);
}
Also used : Post(com.nixmash.blog.jpa.model.Post) PostDTO(com.nixmash.blog.jpa.dto.PostDTO) Test(org.junit.Test)

Example 17 with PostDTO

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);
}
Also used : 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 18 with PostDTO

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");
}
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 19 with PostDTO

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);
}
Also used : Post(com.nixmash.blog.jpa.model.Post) PostUtils.postDtoToPost(com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost) TagDTO(com.nixmash.blog.jpa.dto.TagDTO) PostDTO(com.nixmash.blog.jpa.dto.PostDTO) Test(org.junit.Test)

Example 20 with PostDTO

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");
}
Also used : 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)

Aggregations

PostDTO (com.nixmash.blog.jpa.dto.PostDTO)24 Test (org.junit.Test)15 Post (com.nixmash.blog.jpa.model.Post)14 PostUtils.postDtoToPost (com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost)9 TagDTO (com.nixmash.blog.jpa.dto.TagDTO)2 PostType (com.nixmash.blog.jpa.enums.PostType)1 Category (com.nixmash.blog.jpa.model.Category)1 PostMeta (com.nixmash.blog.jpa.model.PostMeta)1 JsoupPostDTO (com.nixmash.blog.jsoup.dto.JsoupPostDTO)1 PostLink (com.nixmash.blog.mvc.containers.PostLink)1 ArrayList (java.util.ArrayList)1 FlatFileItemWriter (org.springframework.batch.item.file.FlatFileItemWriter)1 BeanWrapperFieldExtractor (org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor)1 DelimitedLineAggregator (org.springframework.batch.item.file.transform.DelimitedLineAggregator)1 Bean (org.springframework.context.annotation.Bean)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1