Package org.jtalks.jcommune.model.entity

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


        this.notificationService = notificationService;
    }

    @Override
    public CodeReviewComment addComment(Long reviewId, int lineNumber, String body) throws NotFoundException {
        CodeReview review = get(reviewId);
        JCUser currentUser = userService.getCurrentUser();

        permissionService.checkPermission(
                review.getTopic().getBranch().getId(),
                AclClassName.BRANCH,
                BranchPermission.LEAVE_COMMENTS_IN_CODE_REVIEW);

        CodeReviewComment comment = new CodeReviewComment();
        comment.setLineNumber(lineNumber);
        comment.setBody(body);
        comment.setCreationDate(new DateTime(System.currentTimeMillis()));
        comment.setAuthor(currentUser);
        if (currentUser.isAutosubscribe()) {
            review.getSubscribers().add(currentUser);
        }

        review.addComment(comment);
        getDao().saveOrUpdate(review);
        notificationService.subscribedEntityChanged(review);

        return comment;
    }
View Full Code Here


   
    /*===== Common methods =====*/

    @Test
    public void testGet() {
        CodeReview review = PersistedObjectsFactory.getDefaultCodeReview();
        session.flush();

        CodeReview result = codeReviewDao.get(review.getId());

        assertNotNull(result);
        assertEquals(result.getId(), review.getId());
        assertEquals(result.getComments().size(), 2);
    }
View Full Code Here

    }


    @Test
    public void testGetInvalidId() {
        CodeReview result = codeReviewDao.get(-567890L);
        assertNull(result);
    }
View Full Code Here

    }

    @Test
    public void testUpdate() {
        String newUuid = "1234-1231-1231";
        CodeReview review = PersistedObjectsFactory.getDefaultCodeReview();
        session.flush();
        review.setUuid(newUuid);

        codeReviewDao.saveOrUpdate(review);
        session.flush();
        session.evict(review);
        CodeReview result = (CodeReview) session.get(CodeReview.class, review.getId());

        assertEquals(result.getUuid(), newUuid);
    }
View Full Code Here

        assertEquals(result.getUuid(), newUuid);
    }

    @Test(expectedExceptions = org.hibernate.exception.ConstraintViolationException.class)
    public void testUpdateNotNullViolation() {
        CodeReview review = PersistedObjectsFactory.getDefaultCodeReview();
        session.flush();
        review.setUuid(null);

        codeReviewDao.saveOrUpdate(review);
        session.flush();
    }
View Full Code Here

        session.flush();
    }

    @Test
    public void testOrphanRemoving() {
        CodeReview review = PersistedObjectsFactory.getDefaultCodeReview();
        session.flush();

        review.getComments().remove(0);
        codeReviewDao.saveOrUpdate(review);
        session.flush();
        session.evict(review);

        assertEquals(codeReviewDao.get(review.getId()).getComments().size(), 1);
    }
View Full Code Here

    }


    @Test
    public void testDeletionReview() {
        CodeReview review = PersistedObjectsFactory.getDefaultCodeReview();
        CodeReviewComment comment0 = review.getComments().get(0);
        CodeReviewComment comment1 = review.getComments().get(1);

        codeReviewDao.delete(review);
        session.flush();
        session.evict(review);

        assertNull(codeReviewDao.get(review.getId()));
        assertNull(codeReviewCommentDao.get(comment0.getId()));
        assertNull(codeReviewCommentDao.get(comment1.getId()));
    }
View Full Code Here

     * @throws NotFoundException if code review was not found
     */
    @RequestMapping(value = "/reviews/{reviewId}/json", method = RequestMethod.GET)
    @ResponseBody
    public JsonResponse getCodeReview(@PathVariable("reviewId") Long reviewId) throws NotFoundException {
        CodeReview review = codeReviewService.get(reviewId);
        return new JsonResponse(JsonResponseStatus.SUCCESS, new CodeReviewDto(review));
    }
View Full Code Here

                subscriptionService);
        topic = new Topic(user1, "title");
        topic.setId(TOPIC_ID);
        branch = new Branch("name", "description");
        branch.addTopic(topic);
        codeReview = new CodeReview();
        topic.setCodeReview(codeReview);
        codeReview.setTopic(topic);
       
        when(userService.getCurrentUser()).thenReturn(currentUser);
    }
View Full Code Here

    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

TOP

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

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.