Package com.steeplesoft.frenchpress.model

Examples of com.steeplesoft.frenchpress.model.Post


        // Create Post
        Response response = target.request().accept(MediaType.APPLICATION_JSON).get();
        assertNotNull(response);
        assertNotNull(response.readEntity(String.class));
        Post post = new Post();
        post.setTitle("REST Test");
        post.setSlug("rest-test");

        response = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(post, MediaType.APPLICATION_JSON));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        Post newPost = response.readEntity(Post.class);
        assertNotNull(newPost);

        // Update Post
        newPost.setTitle("Updated");
        response = target.path("id").path(newPost.getId().toString()).request().put(Entity.entity(newPost, MediaType.APPLICATION_JSON));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        // Delete Post
        response = target.path("id").path(newPost.getId().toString()).request().delete();
        assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    }
View Full Code Here


    @Test
    public void postCrud() {
        assertNotNull(postService.getPosts(-1));

        Post newPost = testCreatePost();
        testUpdatePost(newPost);
        testFindingBySlug(newPost);
        testDeletePost(newPost);
    }
View Full Code Here

        testFindingBySlug(newPost);
        testDeletePost(newPost);
    }

    public Post testCreatePost() {
        Post post = createPost();
        postService.createPost(post);
        assertNotNull(post.getId());
        assertNotNull(postService.getPost(post.getId()));

        return post;
    }
View Full Code Here

    public void testFindingBySlug(Post post) {
        assertEquals(post, postService.findPostBySlug(post.getSlug()));
    }

    private Post createPost() {
        Post post = new Post();
        int rand = generateRandomNumber();
        post.setTitle("Arquillian Post - " + rand);
        post.setBody("Arquillian Body");
        post.setSlug("arquillian-post-" + rand);
        post.setPosted(new Date());

        return post;
    }
View Full Code Here

        return postService.getPosts(limit);
    }

    public void loadPost() {
        Post requestedPost = (Post) ((ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getAttribute("post");
        post = (requestedPost != null) ? requestedPost : postService.getPost(post.getId());
    }
View Full Code Here

        postService.createPost(post);
        return Constants.VIEW_ADMIN_POSTS_INDEX;
    }

    public String delete() {
        Post toDelete = (Post) dataTable.getRowData();
        postService.deletePost(toDelete);

        return null;
    }
View Full Code Here

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest hsr = (HttpServletRequest) request;
        String path = hsr.getServletPath();
        if (!path.startsWith("/javax.faces.resource/")) {
            Post post = null;

            String postId = request.getParameter("p");
            if (postId != null) {
                Long id = Long.parseLong(postId);
                post = postService.getPost(id);
View Full Code Here

            em.remove(post);
        }
    }

    public Post findPostBySlug(String slug) {
        Post post = null;

        List<Post> posts = em.createNamedQuery("findBySlug", Post.class)
            .setParameter("SLUG", slug)
            .getResultList();
View Full Code Here

    }

    @GET
    @Path("id/{id}/comments")
    public List<Comment> getPostComment(@PathParam("id") Long id) {
        final Post post = postService.getPost(id);
        if (post == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }
        return post.getComments();
    }
View Full Code Here

TOP

Related Classes of com.steeplesoft.frenchpress.model.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.