Package sagan.blog

Examples of sagan.blog.Post


        assertThat(((Page<PostView>) model.get("posts")).getContent().get(0).getTitle(), equalTo("published post"));
    }

    @Test
    public void showPostModel() {
        Post post = PostBuilder.post().build();
        given(blogService.getPost(post.getId())).willReturn(post);
        controller.showPost(post.getId(), "1-post-title", model);
        PostView view = (PostView) model.get("post");
        assertThat(view, is(notNullValue()));
    }
View Full Code Here


        PostForm postForm = new PostForm();
        postForm.setTitle("title");
        postForm.setContent("content");
        postForm.setCategory(PostCategory.ENGINEERING);
        Post post = PostBuilder.post().id(123L).publishAt("2013-05-06 00:00").title("Post Title").build();
        given(blogService.addPost(postForm, username)).willReturn(post);
        String result = controller.createPost(principal, postForm, bindingResult, null);

        assertThat(result, equalTo("redirect:/blog/2013/05/06/post-title"));
    }
View Full Code Here

        PostForm postForm = new PostForm();
        postForm.setTitle("title");
        postForm.setContent("content");
        postForm.setCategory(PostCategory.ENGINEERING);
        Post post = PostBuilder.post().id(123L).publishAt("2013-05-06 00:00").title("Post Title").build();

        given(blogService.addPost(postForm, username)).willReturn(post);
        String result1 = controller.createPost(principal, postForm, bindingResult, null);
        assertThat(result1, equalTo("redirect:/blog/2013/05/06/post-title"));
View Full Code Here

        profile.setGithubUsername("someguy");
        profile.setUsername("someguy");

        teamRepository.save(profile);

        Post post = PostBuilder.post().author(profile).title("My Post").build();
        postRepository.save(post);

        mockMvc.perform(get("/team/someguy"))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith("text/html"))
View Full Code Here

                .map(Element::text).collect(toList());
        assertThat(titles, contains("Back to Work", "Off to the Sales", "Happy New Year"));
    }

    private Post createAuthoredPost(MemberProfile author, String title, String publishAt) throws ParseException {
        Post post = PostBuilder.post().author(author).title(title).publishAt(publishAt).build();
        return postRepository.save(post);
    }
View Full Code Here

    @RequestMapping(value = "/{year:\\d+}/{month:\\d+}/{day:\\d+}/{slug}", method = { GET, HEAD })
    public String showPost(@PathVariable String year, @PathVariable String month, @PathVariable String day,
                           @PathVariable String slug, Model model) {

        String publicSlug = String.format("%s/%s/%s/%s", year, month, day, slug);
        Post post = service.getPublishedPost(publicSlug);
        model.addAttribute("post", PostView.of(post, dateFactory));
        model.addAttribute("categories", PostCategory.values());
        model.addAttribute("activeCategory", post.getCategory().getDisplayName());
        model.addAttribute("disqusShortname", service.getDisqusShortname());
        return "blog/show";
    }
View Full Code Here

        return "admin/blog/new";
    }

    @RequestMapping(value = "/{postId:[0-9]+}{slug:.*}/edit", method = { GET, HEAD })
    public String editPost(@PathVariable Long postId, @PathVariable String slug, Model model) {
        Post post = service.getPost(postId);
        PostForm postForm = new PostForm(post);

        model.addAttribute("categories", PostCategory.values());
        model.addAttribute("postForm", postForm);
        model.addAttribute("post", post);
View Full Code Here

            model.addAttribute("categories", PostCategory.values());
            return "admin/blog/new";
        } else {
            MemberProfile memberProfile = teamRepository.findById(new Long(principal.getName()));
            try {
                Post post = service.addPost(postForm, memberProfile.getUsername());
                PostView postView = PostView.of(post, dateFactory);
                return "redirect:" + postView.getPath();
            } catch (DataIntegrityViolationException ex) {
                model.addAttribute("categories", PostCategory.values());
                model.addAttribute("postForm", postForm);
View Full Code Here

    }

    @RequestMapping(value = "/{postId:[0-9]+}{slug:.*}", method = PUT)
    public String updatePost(@PathVariable Long postId, @Valid PostForm postForm, BindingResult bindingResult,
                             Model model) {
        Post post = service.getPost(postId);
        if (bindingResult.hasErrors()) {
            model.addAttribute("categories", PostCategory.values());
            model.addAttribute("post", post);
            return "admin/blog/edit";
        } else {
View Full Code Here

        }
    }

    @RequestMapping(value = "/{postId:[0-9]+}{slug:.*}", method = DELETE)
    public String deletePost(@PathVariable Long postId) {
        Post post = service.getPost(postId);
        service.deletePost(post);
        return "redirect:/admin/blog";
    }
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.