Search in sources :

Example 66 with Post

use of com.nixmash.blog.jpa.model.Post 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)

Example 67 with Post

use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.

the class PostServiceTests method updatedPostContainsNewlyAssignedCategory.

@Test
public void updatedPostContainsNewlyAssignedCategory() throws DuplicatePostNameException, PostNotFoundException {
    Post post = postService.getPostById(1L);
    assertEquals(post.getCategory().getCategoryValue(), "Uncategorized");
    PostDTO postDTO = PostUtils.postToPostDTO(post);
    postDTO.setCategoryId(2L);
    post = postService.update(postDTO);
    assertEquals(post.getCategory().getCategoryValue(), "Java");
}
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 68 with Post

use of com.nixmash.blog.jpa.model.Post in project nixmash-blog by mintster.

the class PostServiceTests method negativePostIdStub_NotYetSelected.

// endregion
// region Misc tests
@Test(expected = PostNotFoundException.class)
public void negativePostIdStub_NotYetSelected() throws PostNotFoundException {
    Post post = postService.getPostById(-1L);
    assertEquals(post.getPostName(), "not-yet-selected");
}
Also used : Post(com.nixmash.blog.jpa.model.Post) PostUtils.postDtoToPost(com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost) Test(org.junit.Test)

Aggregations

Post (com.nixmash.blog.jpa.model.Post)68 Test (org.junit.Test)48 PostUtils.postDtoToPost (com.nixmash.blog.jpa.utils.PostUtils.postDtoToPost)15 PostDTO (com.nixmash.blog.jpa.dto.PostDTO)14 PostMeta (com.nixmash.blog.jpa.model.PostMeta)8 PostDoc (com.nixmash.blog.solr.model.PostDoc)8 Matchers.containsString (org.hamcrest.Matchers.containsString)5 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)5 ArrayList (java.util.ArrayList)4 Query (org.springframework.data.solr.core.query.Query)4 SimpleQuery (org.springframework.data.solr.core.query.SimpleQuery)4 SimpleStringCriteria (org.springframework.data.solr.core.query.SimpleStringCriteria)4 ZonedDateTime (java.time.ZonedDateTime)3 Date (java.util.Date)3 Before (org.junit.Before)3 TagDTO (com.nixmash.blog.jpa.dto.TagDTO)2 PostNotFoundException (com.nixmash.blog.jpa.exceptions.PostNotFoundException)2 SiteImage (com.nixmash.blog.jpa.model.SiteImage)2 JsonPostDTO (com.nixmash.blog.mvc.dto.JsonPostDTO)2 File (java.io.File)2