public static Post getPostWithComments() { Post post = new Post(getDefaultUser(), "test"); post.addComment(new PostComment()); post.addComment(new PostComment()); return post; } }
/** * Return first code review comment from persisted code review. * * @return first code review comment from persisted code review. */ public static PostComment getDefaultPostComment() { PostComment comment2 = new PostComment(); comment2.setAuthor(persist(ObjectsFactory.getRandomUser())); comment2.setBody("Comment2 body"); comment2.setCreationDate(new DateTime(2)); comment2.setPost(getDefaultPost()); return comment2; }
public static PostComment getModifiedPostComment() { PostComment comment3 = new PostComment(); comment3.setAuthor(persist(ObjectsFactory.getRandomUser())); comment3.setBody("Comment3 body"); comment3.setCreationDate(new DateTime(3)); comment3.setPost(getDefaultPost()); comment3.setUserChanged(persist(ObjectsFactory.getRandomUser())); comment3.setModificationDate(new DateTime(4)); return comment3; }
/** * {@inheritDoc} */ @Override public PostComment addComment(Long postId, Map<String, String> attributes, String body) throws NotFoundException { Post targetPost = get(postId); JCUser currentUser = userService.getCurrentUser(); assertCommentAllowed(targetPost.getTopic()); PostComment comment = new PostComment(); comment.putAllAttributes(attributes); comment.setBody(body); comment.setCreationDate(new DateTime(System.currentTimeMillis())); comment.setAuthor(currentUser); if (currentUser.isAutosubscribe()) { targetPost.getTopic().getSubscribers().add(currentUser); } targetPost.addComment(comment); getDao().saveOrUpdate(targetPost); /** * Notify subscribers of topic if comment added */ notificationService.subscribedEntityChanged(targetPost.getTopic()); return comment; }