Package sagan.blog

Examples of sagan.blog.Post


    @Test
    public void blogIndexPostsIncludeLinkToAuthor() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
View Full Code Here


    public void blogIndexPostsDoNotIncludeLinksToHiddenAuthors() throws Exception {
        MemberProfile activeAuthor =
                MemberProfileBuilder.profile().name("Hidden Author").username("hidden_author").hidden(true).build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertTrue(html.select("a.author").isEmpty());
View Full Code Here

    @Test
    public void blogPostPageIncludesLinkToAuthor() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog/" + post.getPublicSlug())).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
    }
View Full Code Here

    public void blogPostPageDoesNotIncludeLinkToHiddenAuthors() throws Exception {
        MemberProfile activeAuthor =
                MemberProfileBuilder.profile().name("Hidden Author").username("hidden_author").hidden(true).build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog/" + post.getPublicSlug())).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertTrue(html.select("a.author").isEmpty());
        assertThat(html.text(), containsString("Hidden Author"));
    }
View Full Code Here

        assertThat(xpath.evaluate("/feed/link/@href", doc), is(siteUrl.getAbsoluteUrl("/blog/category/news")));
    }

    @Test
    public void containsBlogPostFields() throws Exception {
        Post post = PostBuilder.post().category(PostCategory.ENGINEERING).isBroadcast().build();
        postRepository.save(post);

        ResultActions resultActions = mockMvc.perform(get("/blog.atom"));
        MvcResult mvcResult = resultActions
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("application/atom+xml"))
                .andReturn();

        assertThat(mvcResult.getResponse().getCharacterEncoding(), equalTo("utf-8"));

        String atomFeed = mvcResult.getResponse().getContentAsString();
        assertThat(atomFeed, containsString(post.getTitle()));
        assertThat(atomFeed, containsString(post.getRenderedContent()));

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setTimeZone(DateFactory.DEFAULT_TIME_ZONE);
        String postDate = dateFormat.format(post.getCreatedAt());
        assertThat(atomFeed, containsString(postDate));
        assertThat(atomFeed, containsString("/blog/" + post.getPublicSlug()));
        assertThat(atomFeed, containsString(PostCategory.ENGINEERING.getDisplayName()));
        assertThat(atomFeed, containsString("Broadcast"));
    }
View Full Code Here

    private void createPosts(int numPostsToCreate) {
        Calendar calendar = Calendar.getInstance();
        List<Post> posts = new ArrayList<>();
        for (int postNumber = 1; postNumber <= numPostsToCreate; postNumber++) {
            calendar.set(2013, 10, postNumber);
            Post post = new PostBuilder().title("This week in Spring - November " + postNumber + ", 2013")
                    .rawContent("Raw content")
                    .renderedContent("Html content")
                    .renderedSummary("Html summary")
                    .createdAt(calendar.getTime())
                    .build();
View Full Code Here

                        .get(0).attr("href"), equalTo("/blog.atom"));
    }

    @Test
    public void given1Post_blogIndexShowsPostSummary() throws Exception {
        Post post = createSinglePost();

        MvcResult response = mockMvc.perform(get("/blog"))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html")).andReturn();

        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select(".blog--title a").first().text(), is(post.getTitle()));
    }
View Full Code Here

    @Test
    public void givenPostContentThatIsEqualToSummary_blogIndexShouldNotShow_ReadMore() throws Exception {
        String summary = "A blog post string that is longish.";
        String content = summary;
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
View Full Code Here

        String summary = "A blog post string that is longish.";
        String content = "";
        for (int i = 0; i < 50; i++) {
            content = content + summary;
        }
        Post post = new PostBuilder().renderedContent(content).renderedSummary(summary).build();

        postRepository.save(post);

        MvcResult result = mockMvc.perform(get("/blog")).andReturn();
        String response = result.getResponse().getContentAsString();
View Full Code Here

        String response = result.getResponse().getContentAsString();
        assertThat(response, containsString("Read more"));
    }

    private Post createSinglePost() {
        Post post = new PostBuilder().title("This week in Spring - June 3, 2013")
                .rawContent("Raw content").renderedContent("Html content")
                .renderedSummary("Html summary").build();
        postRepository.save(post);
        return post;
    }
View Full Code Here

TOP

Related Classes of sagan.blog.Post

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.