@Test void findAllRepliesTest() { TipsAndTricksComment tipsAndTricksComment = ModelUtils.getTipsAndTricksComment(); List<TipsAndTricksComment> tipsAndTricksComments = Collections.singletonList(ModelUtils.getTipsAndTricksComment()); List<TipsAndTricksCommentDto> dtoList = Collections.singletonList(tipsAndTricksCommentDto); tipsAndTricksComment.setParentComment(ModelUtils.getTipsAndTricksComment()); when(tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(anyLong())) .thenReturn(tipsAndTricksComments); when(modelMapper.map(tipsAndTricksComments.get(0), TipsAndTricksCommentDto.class)). thenReturn(tipsAndTricksCommentDto); assertEquals(dtoList, tipsAndTricksCommentService.findAllReplies(tipsAndTricksComment.getParentComment().getId())); }
@Override public List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId) { return tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(parentCommentId) .stream() .map(tipsAndTricksComment -> modelMapper.map(tipsAndTricksComment, TipsAndTricksCommentDto.class)) .collect(Collectors.toList()); }
TipsAndTricksCommentServiceImpl implements TipsAndTricksCommentService { @Override public List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId) { return tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(parentCommentId) .stream() .map(tipsAndTricksComment -> modelMapper.map(tipsAndTricksComment, TipsAndTricksCommentDto.class)) .collect(Collectors.toList()); } }
TipsAndTricksCommentServiceImpl implements TipsAndTricksCommentService { @Override public List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId) { return tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(parentCommentId) .stream() .map(tipsAndTricksComment -> modelMapper.map(tipsAndTricksComment, TipsAndTricksCommentDto.class)) .collect(Collectors.toList()); }  }
TipsAndTricksCommentServiceImpl implements TipsAndTricksCommentService { @Override public List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId) { return tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(parentCommentId) .stream() .map(tipsAndTricksComment -> modelMapper.map(tipsAndTricksComment, TipsAndTricksCommentDto.class)) .collect(Collectors.toList()); }  @Override AddTipsAndTricksCommentDtoResponse save(Long tipsandtricksId,
                                                   AddTipsAndTricksCommentDtoRequest addTipsAndTricksCommentDtoRequest,
                                                   User user); @Override PageableDto<TipsAndTricksCommentDto> findAllComments(Pageable pageable, User user, Long tipsAndTricksId); @Override List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId); @Override void deleteById(Long id, User user); @Override void update(String text, Long id, User user); @Override void like(Long id, User user); @Override int countLikes(Long id); @Override int countReplies(Long id); @Override int countComments(Long tipAndTricksId); }
TipsAndTricksCommentServiceImpl implements TipsAndTricksCommentService { @Override public List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId) { return tipsAndTricksCommentRepo.findAllByParentCommentIdAndDeletedFalseOrderByCreatedDateAsc(parentCommentId) .stream() .map(tipsAndTricksComment -> modelMapper.map(tipsAndTricksComment, TipsAndTricksCommentDto.class)) .collect(Collectors.toList()); }  @Override AddTipsAndTricksCommentDtoResponse save(Long tipsandtricksId,
                                                   AddTipsAndTricksCommentDtoRequest addTipsAndTricksCommentDtoRequest,
                                                   User user); @Override PageableDto<TipsAndTricksCommentDto> findAllComments(Pageable pageable, User user, Long tipsAndTricksId); @Override List<TipsAndTricksCommentDto> findAllReplies(Long parentCommentId); @Override void deleteById(Long id, User user); @Override void update(String text, Long id, User user); @Override void like(Long id, User user); @Override int countLikes(Long id); @Override int countReplies(Long id); @Override int countComments(Long tipAndTricksId);  }