Package org.jtalks.jcommune.model.entity

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


    public void buildFeedItemsShouldReturnItemsWithAuthorsFromTheModel() throws IOException {
        Map<String, Object> model = new HashMap<>();

        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();
View Full Code Here


    public void buildFeedItemsShouldReturnItemsWithPostContentFromTheModel() throws IOException {
        Map<String, Object> model = new HashMap<>();

        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();
View Full Code Here

    public void buildFeedItemsShouldReturnItemsWithTitleFromTheModel() throws IOException {
        Map<String, Object> model = new HashMap<>();

        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).getTitle(), topic.getTitle());
        assertEquals(result.get(1).getTitle(), topic.getTitle());
    }
View Full Code Here

    public void buildFeedItemsShouldReturnItemsWithLinksFromTheModel() throws IOException {
        Map<String, Object> model = new HashMap<>();

        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));

        MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

    public void buildFeedItemsShouldReturnItemsWithDatesFromTheModel() throws IOException {
        Map<String, Object> model = new HashMap<>();

        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));

        MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

            "hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.EDIT_OWN_POSTS')) or " +
            "(not hasPermission(#post.id, 'POST', 'GeneralPermission.WRITE') and " +
            "hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.EDIT_OTHERS_POSTS'))")
    @Override
    public void updatePost(Post post, String postContent) {
        Topic postTopic = post.getTopic();
        if (postTopic.getCodeReview() != null
                && postTopic.getPosts().get(0).getId() == post.getId()) {
            throw new AccessDeniedException("It is impossible to edit code review!");
        }
        post.setPostContent(postContent);
        post.updateModificationDate();
View Full Code Here

            "(hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.DELETE_OTHERS_POSTS') and " +
            "#post.userCreated.username != principal.username)")
    public void deletePost(Post post) {
        JCUser user = post.getUserCreated();
        user.setPostCount(user.getPostCount() - 1);
        Topic topic = post.getTopic();
        topic.removePost(post);
        Branch branch = topic.getBranch();
        boolean deletedPostIsLastPostInBranch = branch.isLastPost(post);
        if (deletedPostIsLastPostInBranch) {
            branch.clearLastPost();
        }

        if (post.getCreationDate().equals(topic.getModificationDate())) {
            topic.recalculateModificationDate();
        }

        // todo: event API?
        topicDao.saveOrUpdate(topic);
        securityService.deleteFromAcl(post);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public int calculatePageForPost(Post post) {
        Topic topic = post.getTopic();
        int index = topic.getPosts().indexOf(post) + 1;
        int pageSize = userService.getCurrentUser().getPageSize();
        int pageNum = index / pageSize;
        if (index % pageSize == 0) {
            return pageNum;
        } else {
View Full Code Here

    private Branch createDefaultBranch(){
        long branchId = 1L;
        long topicId = 1L;
        JCUser user = new JCUser("username", "email", "password");
        Topic topic = new Topic(user, "Topic title");
        topic.setId(topicId);
        Branch branch = new Branch("name", "description");
        branch.setId(branchId);
        branch.addTopic(topic);
        return branch;
    }
View Full Code Here

                               @Valid @ModelAttribute PostDto postDto,
                               BindingResult result) throws NotFoundException {
        postDto.setTopicId(topicId);
        if (result.hasErrors()) {
            JCUser currentUser = userService.getCurrentUser();
            Topic topic = topicFetchService.get(topicId);
            postDto.setTopicId(topicId);
            Page<Post> postsPage = postService.getPosts(topic, page);

            return new ModelAndView("topic/postList")
                    .addObject("viewList", locationService.getUsersViewing(topic))
                    .addObject("usersOnline", sessionRegistry.getAllPrincipals())
                    .addObject("postsPage", postsPage)
                    .addObject("topic", topic)
                    .addObject(POST_DTO, postDto)
                    .addObject("subscribed", topic.getSubscribers().contains(currentUser))
                    .addObject(BREADCRUMB_LIST, breadcrumbBuilder.getForumBreadcrumb(topic));
        }

        Post newbie = replyToTopicWithLockHandling(postDto, topicId);
        lastReadPostService.markTopicAsRead(newbie.getTopic());
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.Topic

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.