Package sagan.blog

Examples of sagan.blog.Post


    private void setUpdatedDate(Map<String, Object> model, Feed feed) {
        @SuppressWarnings("unchecked")
        List<Post> posts = (List<Post>) model.get("posts");
        if (posts.size() > 0) {
            Post latestPost = posts.get(0);
            feed.setUpdated(latestPost.getPublishAt());
        }
    }
View Full Code Here


    }

    @Test
    public void updatingABlogPost_doesNotChangeItsCreatedDateByDefault() throws Exception {
        Date originalDate = DateTestUtils.getDate("2009-11-20 07:00");
        Post post = PostBuilder.post().createdAt(originalDate).build();
        postFormAdapter.updatePostFromPostForm(post, postForm);
        assertThat(post.getCreatedAt(), is(originalDate));
    }
View Full Code Here

    }

    @Test
    public void updatingABlogPost_usesTheCreatedDateFromThePostFormIfPresent() throws Exception {
        Date originalDate = DateTestUtils.getDate("2009-11-20 07:00");
        Post post = PostBuilder.post().createdAt(originalDate).build();

        Date newDate = DateTestUtils.getDate("2010-01-11 03:00");
        postForm.setCreatedAt(newDate);

        postFormAdapter.updatePostFromPostForm(post, postForm);
        assertThat(post.getCreatedAt(), is(newDate));
    }
View Full Code Here

    @Before
    public void setup() {
        given(dateFactory.now()).willReturn(now);

        given(postRepository.save((Post) anyObject())).will(invocation -> {
            Post post = (Post) invocation.getArguments()[0];
            ReflectionTestUtils.setField(post, "id", 123L);
            return post;
        });

        post = PostBuilder.post().publishAt(publishAt).build();
View Full Code Here

        reset(searchService);

        PostForm draftPostForm = new PostForm();
        draftPostForm.setDraft(true);

        Post draft = PostBuilder.post().draft().build();
        given(postFormAdapter.createPostFromPostForm(draftPostForm, AUTHOR_USERNAME)).willReturn(draft);

        service.addPost(draftPostForm, AUTHOR_USERNAME);
        verifyZeroInteractions(searchService);
    }
View Full Code Here

    @Test
    public void postCreatedDateCanBeSetFromAPostForm() throws Exception {
        Date createdAt = DateTestUtils.getDate("2013-05-23 22:58");
        postForm.setCreatedAt(createdAt);
        Post post = adapter.createPostFromPostForm(postForm, AUTHOR_USERNAME);
        assertThat(post.getCreatedAt(), is(createdAt));
    }
View Full Code Here

    @Test
    public void updatingABlogPost_doesNotSaveToSearchIndexIfNotLive() throws Exception {
        reset(searchService);
        long postId = 123L;
        Post post = PostBuilder.post().id(postId).draft().build();
        service.updatePost(post, new PostForm(post));
        verifyZeroInteractions(searchService);
    }
View Full Code Here

    public void updatePostSavesNewValues() throws Exception {
        MockHttpServletRequestBuilder editPostRequest = createEditPostRequest();

        String originalPublicSlug = post.getPublicSlug();
        mockMvc.perform(editPostRequest);
        Post updatedPost = postRepository.findOne(post.getId());

        assertEquals("New Title", updatedPost.getTitle());
        assertEquals("New Content", updatedPost.getRawContent());
        assertEquals(PostCategory.NEWS_AND_EVENTS, updatedPost.getCategory());
        assertEquals(false, updatedPost.isDraft());
        assertThat(updatedPost.getId(), equalTo(post.getId()));

        mockMvc.perform(get("/blog/{slug}", originalPublicSlug))
                .andExpect(status().is3xxRedirection())
                .andExpect(redirectedUrl("/blog/" + updatedPost.getPublicSlug()));
    }
View Full Code Here

        editPostRequest.param("content", "");
        editPostRequest.param("category", PostCategory.NEWS_AND_EVENTS.name());
        editPostRequest.param("draft", "false");

        mockMvc.perform(editPostRequest).andExpect(status().isOk());
        Post updatedPost = postRepository.findOne(post.getId());

        assertEquals("Original Title", updatedPost.getTitle());
        assertEquals("Original Content", updatedPost.getRawContent());
        assertEquals(PostCategory.ENGINEERING, updatedPost.getCategory());
        assertEquals(false, updatedPost.isDraft());
        assertThat(updatedPost.getId(), equalTo(post.getId()));
    }
View Full Code Here

        createPostRequest.param("category", PostCategory.ENGINEERING.name());
        createPostRequest.param("broadcast", "true");

        mockMvc.perform(createPostRequest);

        Post post = postRepository.findAll().get(0);

        assertThat(post.getTitle(), is("Post Title"));
        assertThat(post.getRawContent(), is("My Content"));
        assertThat(post.getCategory(), is(PostCategory.ENGINEERING));
        assertThat(post.isBroadcast(), is(true));
    }
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.