Package org.jtalks.jcommune.model.entity

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


        initMocks(this);
        service = new NotificationService(
                userService,
                mailService,
                subscriptionService);
        topic = new Topic(user1, "title");
        topic.setId(TOPIC_ID);
        branch = new Branch("name", "description");
        branch.addTopic(topic);
        codeReview = new CodeReview();
        topic.setCodeReview(codeReview);
View Full Code Here


        when(userService.getCurrentUser()).thenReturn(user);
    }
   
    @Test
    public void testGetTopic() throws NotFoundException {
        Topic expectedTopic = new Topic(user, "title");
        when(topicDao.isExist(999L)).thenReturn(true);
        when(topicDao.get(999L)).thenReturn(expectedTopic);

        int viewsCount = expectedTopic.getViews();

        Topic actualTopic = topicFetchService.get(999L);

        assertEquals(actualTopic.getViews(), viewsCount + 1);
        assertEquals(actualTopic, expectedTopic, "Topics aren't equal");
        verify(topicDao).isExist(999L);
        verify(topicDao).get(999L);
    }
View Full Code Here

    @Test
    public void testGetAllTopicsPastLastDay() throws NotFoundException {
        String pageNumber = "1";
        int pageSize = 20;
        List<Topic> expectedList = Collections.nCopies(2, new Topic(user, "title"));
        Page<Topic> expectedPage = new PageImpl<>(expectedList);
        when(topicDao.getTopicsUpdatedSince(Matchers.<DateTime>any(), Matchers.<PageRequest>any(),eq(user)))
                .thenReturn(expectedPage);
        user.setPageSize(pageSize);
        when(userService.getCurrentUser()).thenReturn(user);
View Full Code Here

    @Test
    public void testGetUnansweredTopics() {
        String pageNumber = "1";
        int pageSize = 20;
        List<Topic> expectedList = Collections.nCopies(2, new Topic(user, "title"));
        Page<Topic> expectedPage = new PageImpl<>(expectedList);
        when(topicDao.getUnansweredTopics(Matchers.<PageRequest>any(),eq(user)))
                .thenReturn(expectedPage);
        user.setPageSize(pageSize);
        when(userService.getCurrentUser()).thenReturn(user);
View Full Code Here

        List<Branch> branches = (List) section.getBranches();
        return getBranchesWithViewPermission(currentTopicId, branches);
    }

    private List<Branch> getBranchesWithViewPermission(Long topicId, List<Branch> branches) {
        Topic topic = topicDao.get(topicId);
        List<Branch> result = new ArrayList<>();
        for (Branch branch : branches) {
            if (permissionService.hasBranchPermission(branch.getId(), BranchPermission.VIEW_TOPICS)) {
                result.add(branch);
            }
        }
        result.remove(topic.getBranch());
        return result;
    }
View Full Code Here

    public String showNewQuestionPage(@RequestParam(BRANCH_ID) Long branchId, Model model, HttpServletRequest request)
            throws NotFoundException {
        VelocityEngine engine = new VelocityEngine(getProperties());
        engine.init();
        Branch branch = TransactionalPluginBranchService.getInstance().get(branchId);
        Topic topic = new Topic();
        topic.setBranch(branch);
        TopicDto dto = new TopicDto(topic);
        Map<String, Object> data = getDefaultModel(request);
        data.put("breadcrumbList", breadcrumbBuilder.getForumBreadcrumb(topic));
        data.put("topicDto", dto);
        model.addAttribute("content", VelocityEngineUtils.mergeTemplateIntoString(engine,
View Full Code Here

        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"));
        data.put("subscribed", false);
        data.put("breadcrumbList", breadcrumbList);
        return data;
    }
View Full Code Here

    @BeforeMethod
    public void setUp() {
        initMocks(this);
        service = new TransactionalSubscriptionService(userService, branchDao, topicDao, codeReviewDao);
        branch = new Branch("name", "description");
        topic = new Topic(user, "title");
        codeReview = new CodeReview();
        topic.setCodeReview(codeReview);
        codeReview.setTopic(topic);
        when(userService.getCurrentUser()).thenReturn(user);
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override   
    public Topic get(Long id) throws NotFoundException {
        Topic topic = super.get(id);
        topic.setViews(topic.getViews() + 1);
        this.getDao().saveOrUpdate(topic);
        return topic;
    }
View Full Code Here

        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);
        model.put("topics", topics);
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.