Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.Post


        verify(postDao, never()).saveOrUpdate(mentioningPost);
    }

    @Test
    public void notifyNewlyMentionedUsersShouldNotSendWhenUsersWereNotFound() {
        Post mentioningPost = getPost(1L, "[user]Shogun[/user]");
        when(userDao.getByUsernames(asSet("Shogun"))).thenReturn(Collections.<JCUser>emptyList());

        List<JCUser> usersToNotify = MentionedUsers.parse(mentioningPost).getNewUsersToNotify(userDao);

        assertEquals(mentioningPost.getPostContent(), "[user]Shogun[/user]",
                "[user] code shouldn't be if user not found");
        assertEquals(usersToNotify.size(), 0);
        verify(postDao, never()).saveOrUpdate(mentioningPost);
    }
View Full Code Here


    }

    @Test
    public void notifyNewlyMentionedUsersShouldNotSendIfUserIsSubscriberOfTopic() {
        JCUser mentionedUser = getJCUser("Shogun", true);
        Post mentioningPost = getPost(1L, "[user]Shogun[/user]");
        mentioningPost.getTopic().setSubscribers(asSet(mentionedUser));
        when(userDao.getByUsernames(asSet("Shogun"))).thenReturn(asList(mentionedUser));

        List<JCUser> usersToNotify = MentionedUsers.parse(mentioningPost).getNewUsersToNotify(userDao);

        assertEquals(mentioningPost.getPostContent(), "[user]Shogun[/user]",
                "[user][/user] code should not be changed if user was subscribed.");
        assertEquals(usersToNotify.size(), 0);
        verify(postDao, never()).saveOrUpdate(mentioningPost);
    }
View Full Code Here

        MentionedUsers mentionedUsers = MentionedUsers.parse("");
        mentionedUsers.markUsersAsAlreadyNotified(postDao);
    }

    private Post getPost(long id, String content) {
        Post post = new Post(null, content);
        post.setTopic(new Topic());
        post.setId(id);
        return post;
    }
View Full Code Here

    }

    @Test
    public void testUpdateLastPostInBranchWhenPostDeletedIsLastPost() {
        Branch branchOfDeletedPost = new Branch(BRANCH_NAME, BRANCH_DESCRIPTION);
        Post expectedNewLastPost = new Post(null, null);
        when(postDao.getLastPostFor(branchOfDeletedPost))
                .thenReturn(expectedNewLastPost);

        branchLastPostService.refreshLastPostInBranch(branchOfDeletedPost);
        Post actualNewLastPost = branchOfDeletedPost.getLastPost();

        assertEquals(actualNewLastPost, expectedNewLastPost, "Incorrect last post was setted.");
        verify(branchDao).saveOrUpdate(branchOfDeletedPost);
        verify(postDao).getLastPostFor(branchOfDeletedPost);
    }
View Full Code Here

        JCUser mrVasiliy = new JCUser("Mr. Vasiliy", "", "");
        CodeReviewComment comment = new CodeReviewComment();
        comment.setAuthor(mrVasiliy);
        comment.setBody("Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        comment.setCreationDate(new DateTime());
        Post p1 = new Post(mrVasiliy, "Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        p1.getComments().add(comment);
        p1.getComments().add(comment);
        p1.getComments().add(comment);
        p1.getComments().add(comment);
        p1.getComments().add(comment);
        p1.getComments().add(comment);
        posts.add(p1);
        JCUser mrKakashka = new JCUser("Mr. Kakashka", "", "");
        Post p2 = new Post(mrKakashka, "Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        p2.getComments().add(comment);
        p2.getComments().add(comment);
        p2.getComments().add(comment);
        p2.getComments().add(comment);
        posts.add(p2);
        JCUser mrTolik = new JCUser("Mr. Tolik", "", "");
        Post p3 = new Post(mrTolik, "Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        p3.getComments().add(comment);
        p3.getComments().add(comment);
        posts.add(p3);
        Page<Post> postPage = new PageImpl<>(posts);
        data.putAll(getDefaultModel(request));
        data.put("postPage", postPage);
        data.put("question", new Topic(mrVasiliy, "Test title"));
View Full Code Here

        channel = new Channel();
        model = new HashMap<String, Object>();
        List<Topic> topics = new ArrayList<Topic>();
        JCUser user = new JCUser("username", "email", "password");
        user.setSignature("Signature");
        Post post = new Post(user, "sagjalighjh eghjwhjslhjsdfhdfhljdfh");
        topic = new Topic(user, "");
        topic.addPost(post);
        topic.setId(1L);
        topics.add(topic);
        topics.add(topic);
View Full Code Here

        JCUser user = new JCUser("user1", "mymail@email.mydomain", "qwerty");
        JCUser user2 = new JCUser("user2", "mymail2@email.mydomain", "qwerty");
        Topic topic = new Topic(user, "my topic");

        Post post = new Post(user, "Texty text!");
        Post post2 = new Post(user2, "Reply to texty text");
        topic.addPost(post);
        topic.addPost(post2);

        model.put("posts", Arrays.asList(post, post2));
View Full Code Here

        JCUser user = new JCUser("user1", "mymail@email.mydomain", "qwerty");
        JCUser user2 = new JCUser("user2", "mymail2@email.mydomain", "qwerty");
        Topic topic = new Topic(user, "my topic");

        Post post = new Post(user, "Texty text!");
        Post post2 = new Post(user2, "Reply to texty text");
        topic.addPost(post);
        topic.addPost(post2);

        model.put("posts", Arrays.asList(post, post2));

        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();

        List<Item> result = postListRssViewer.buildFeedItems(model, request, response);

        assertEquals(result.get(0).getContent().getValue(), post.getPostContent());
        assertEquals(result.get(1).getContent().getValue(), post2.getPostContent());
    }
View Full Code Here

        JCUser user = new JCUser("user1", "mymail@email.mydomain", "qwerty");
        JCUser user2 = new JCUser("user2", "mymail2@email.mydomain", "qwerty");
        Topic topic = new Topic(user, "my topic");

        Post post = new Post(user, "Texty text!");
        Post post2 = new Post(user2, "Reply to texty text");
        topic.addPost(post);
        topic.addPost(post2);

        model.put("posts", Arrays.asList(post, post2));
View Full Code Here

        JCUser user = new JCUser("user1", "mymail@email.mydomain", "qwerty");
        JCUser user2 = new JCUser("user2", "mymail2@email.mydomain", "qwerty");
        Topic topic = new Topic(user, "my topic");

        Post post = new Post(user, "Texty text!");
        post.setId(1);
        Post post2 = new Post(user2, "Reply to texty text");
        post2.setId(3);
        topic.addPost(post);
        topic.addPost(post2);

        model.put("posts", Arrays.asList(post, post2));
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.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.