Search in sources :

Example 46 with Post

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

the class AdminPostsControllerTests method updatedPostContainsNewCategory.

@Test
public void updatedPostContainsNewCategory() throws Exception {
    Post post = postService.getPostById(1L);
    post.setCategory(PostTestUtils.getUncategorizedCategory());
    assert (post.getCategory().getCategoryId().equals(1L));
    RequestBuilder request = post("/admin/posts/update").param("postId", "1").param("displayType", String.valueOf(post.getDisplayType())).param("postContent", post.getPostContent()).param("postTitle", post.getPostTitle()).param("twitterCardType", post.getPostMeta().getTwitterCardType().name()).param("tags", "one, two").param("categoryId", "3").with(csrf());
    mvc.perform(request);
    post = postService.getPostById(1L);
    assert (post.getCategory().getCategoryId().equals(3L));
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) Post(com.nixmash.blog.jpa.model.Post) Test(org.junit.Test)

Example 47 with Post

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

the class AdminPostsControllerTests method newPostContainsTwitterCardInfo.

// endregion
// region Post MetaData
@Test
public void newPostContainsTwitterCardInfo() throws Exception {
    mvc.perform(addTwitterCardPostRequest("bigtwitter", TwitterCardType.SUMMARY_LARGE_IMAGE, PostDisplayType.POST));
    Post post = postService.getPost("my-title-bigtwitter");
    assertEquals(post.getPostMeta().getTwitterCardType(), TwitterCardType.SUMMARY_LARGE_IMAGE);
    PostMeta postMeta = postService.getPostMetaById(post.getPostId());
    assertNotNull(postMeta);
}
Also used : PostMeta(com.nixmash.blog.jpa.model.PostMeta) Post(com.nixmash.blog.jpa.model.Post) Test(org.junit.Test)

Example 48 with Post

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

the class FmServiceTests method rssPostDisplayTypeContentTest.

// endregion
// region Rss Content Tests
@Test
public void rssPostDisplayTypeContentTest() throws PostNotFoundException {
    // H2 POST 10L 'solr-rama' normal POST PostDisplayType
    Post post = postService.getPost("solr-rama");
    String result = fmService.createRssPostContent(post);
    assertThat(result, containsString("<strong>This is a post</strong>"));
}
Also used : Post(com.nixmash.blog.jpa.model.Post) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 49 with Post

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

the class FmServiceTests method twitterSummaryLargeImageTemplate.

@Test
public void twitterSummaryLargeImageTemplate() throws PostNotFoundException {
    // H2 Post 10L SolrRama is SUMMARY_LARGE_IMAGE
    Post post = postService.getPostById(10L);
    PostMeta postMeta = postService.buildTwitterMetaTagsForDisplay(post);
    String result = fmService.getTwitterTemplate(postMeta);
    assertThat(result, containsString("summary_large_image"));
}
Also used : PostMeta(com.nixmash.blog.jpa.model.PostMeta) Post(com.nixmash.blog.jpa.model.Post) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 50 with Post

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

the class FmServiceTests method rssSinglePhotoPostDisplayTypeContentTest.

@Test
public void rssSinglePhotoPostDisplayTypeContentTest() throws PostNotFoundException {
    // H2 POST 11L 'singlephoto-post' SINGLEPHOTO_POST PostDisplayType
    Post post = postService.getPost("singlephoto-post");
    String result = fmService.createRssPostContent(post);
    assertThat(result, containsString("src=\"http://"));
}
Also used : Post(com.nixmash.blog.jpa.model.Post) Matchers.containsString(org.hamcrest.Matchers.containsString) 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