Package com.lissenberg.blog.domain

Examples of com.lissenberg.blog.domain.BlogPost


  private UserService userService;

    @Test
    public void testInsertBlog() throws Exception {
    // upgrader should have inserted first post
    BlogPost firstPost = blogService.getLatestPost();
        Assert.assertNotNull(firstPost);

    User user = new User();
    user.setUsername("test_user_" + System.currentTimeMillis());
    user.setName("Test user");
    user.setRole(UserRole.WRITER);
    userService.saveUser(user, "secret");

    BlogPost newPost = new BlogPost();
    newPost.setAuthor(user);
    newPost.setPosted(new Date());
    newPost.setTitle("Test title");
    newPost.setText("This is a test post.");
    blogService.savePost(newPost);
   
    BlogPost latestPost = blogService.getLatestPost();
    Assert.assertNotSame(firstPost.getId(), latestPost.getId());
    Assert.assertEquals(newPost.getId(), latestPost.getId());

    }
View Full Code Here


    public void testInsertBlog() {
        User user = new User();
        user.setName("name");
        user.setUsername("username");
        user.setRole(UserRole.WRITER);
        BlogPost post = new BlogPost();
        post.setAuthor(user);
        post.setPosted(new Date());
        post.setText("Lorum Ipsum");
        post.setTitle("Test post title");

        entityTransaction.begin();
        entityManager.persist(user);
        entityManager.persist(post);
        entityTransaction.commit();
        assertNotNull(post.getId());

        List<BlogPost> posts = blogService.getLatestPosts(0, 10);
        assertEquals(1, posts.size());
        assertEquals(post.getId(), posts.get(0).getId());

    }
View Full Code Here

        admin.setPasswordHash(securityService.createHash("secret"));
        entityManager.persist(admin);

        LOG.info("Inserting first post");
        // create first post
        BlogPost post = new BlogPost();
        post.setAuthor(admin);
        post.setTitle("First post!");
        post.setText("Java EE 6 is almost 2 years old and I never got the change to work with it in a " +
                "professional environment. All current projects my company runs still use old and trusted frameworks.<br/>" +
                "I decided to take matters into my own hands and started this quest to learn Java EE 6." +
                " Wanting to do a little bit more than just a Hello World application and decided to build" +
                " blogging software using nothing but plain vanilla Java EE 6 (and perhaps a JSF component library)" +
                " and at the same time use it to blog about my adventures.<br/>" +
View Full Code Here

TOP

Related Classes of com.lissenberg.blog.domain.BlogPost

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.