Search in sources :

Example 1 with PostMeta

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

the class AdminPostsControllerTests method multiPhotoPostTwitterCardIsSaved.

@Test
public void multiPhotoPostTwitterCardIsSaved() throws Exception {
    mvc.perform(addTwitterCardPostRequest("multiphoto twitter post", TwitterCardType.SUMMARY, PostDisplayType.MULTIPHOTO_POST));
    Post post = postService.getPost("my-title-multiphoto-twitter-post");
    assertEquals(post.getPostMeta().getTwitterCardType(), TwitterCardType.SUMMARY);
    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 2 with PostMeta

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

the class AdminPostsControllerTests method newPostWithTwitterCardTypeNoneIsSaved.

@Test
public void newPostWithTwitterCardTypeNoneIsSaved() throws Exception {
    mvc.perform(addTwitterCardPostRequest("notwitter", TwitterCardType.NONE, PostDisplayType.POST));
    Post post = postService.getPost("my-title-notwitter");
    assertEquals(post.getPostMeta().getTwitterCardType(), TwitterCardType.NONE);
    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 3 with PostMeta

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

the class JsoupServiceImpl method updateAllPostMeta.

// endregion
// region TwitterCards
@Override
public void updateAllPostMeta(List<Post> posts) {
    for (Post post : posts) {
        PostMeta updated = updatePostMeta(PostUtils.postToPostDTO(post));
        post.setPostMeta(updated);
    }
}
Also used : PostMeta(com.nixmash.blog.jpa.model.PostMeta) Post(com.nixmash.blog.jpa.model.Post)

Example 4 with PostMeta

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

the class FmServiceTests method twitterSummaryTemplate.

@Test
public void twitterSummaryTemplate() throws PostNotFoundException {
    Post post = postService.getPostById(1L);
    PostMeta postMeta = postService.buildTwitterMetaTagsForDisplay(post);
    String result = fmService.getTwitterTemplate(postMeta);
    assertThat(result, containsString("summary"));
}
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 5 with PostMeta

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

the class FmServiceTests method noneTwitterTypeTemplateIsNull.

@Test
public void noneTwitterTypeTemplateIsNull() throws PostNotFoundException {
    // H2 POST 9L is twitterCardType=NONE
    // postService.buildTwitterMetaTagsForDisplay(post) returns NULL PostMeta object
    Post post = postService.getPostById(9L);
    PostMeta postMeta = postService.buildTwitterMetaTagsForDisplay(post);
    assertNull(postMeta);
}
Also used : PostMeta(com.nixmash.blog.jpa.model.PostMeta) Post(com.nixmash.blog.jpa.model.Post) Test(org.junit.Test)

Aggregations

PostMeta (com.nixmash.blog.jpa.model.PostMeta)10 Post (com.nixmash.blog.jpa.model.Post)8 Test (org.junit.Test)7 Matchers.containsString (org.hamcrest.Matchers.containsString)2 PostDTO (com.nixmash.blog.jpa.dto.PostDTO)1 JsoupPostDTO (com.nixmash.blog.jsoup.dto.JsoupPostDTO)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1