Skip to content

Commit

Permalink
refactor: 변수명 mentionIds로 통일 (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkdhoho committed Oct 13, 2024
1 parent e750b13 commit ca24f25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public ReplyCreateResponse create(
Long targetCommentId,
Long writerId,
String content,
List<Long> mentionedIds
List<Long> mentionIds
) {
listRepository.getById(listId);
User user = userRepository.getById(writerId);
Comment comment = commentRepository.getById(targetCommentId);

List<Mention> mentions = mentionService.toMentions(mentionedIds);
List<Mention> mentions = mentionService.toMentions(mentionIds);
Reply reply = replyRepository.save(new Reply(comment, user, new CommentContent(content), mentions));

applicationEventPublisher.publishEvent(AlarmEvent.reply(comment, reply));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/listywave/mention/MentionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class MentionService {
private final UserRepository userRepository;

@Transactional(readOnly = true)
public List<Mention> toMentions(List<Long> mentionedIds) {
List<User> mentionedUsers = userRepository.findAllById(mentionedIds);
public List<Mention> toMentions(List<Long> mentionIds) {
List<User> mentionedUsers = userRepository.findAllById(mentionIds);
return mentionedUsers.stream()
.map(Mention::new)
.toList();
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/com/listywave/mention/MentionServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ class 멘션_수정 {
@Test
void 댓글을_수정해_새로운_멘션을_추가한다() {
// given
List<Long> firstMentionedIds = List.of(js.getId());
Long commentId = commentService.create(list.getId(), dh.getId(), "댓글이요", firstMentionedIds).id();
List<Long> firstMentionIds = List.of(js.getId());
Long commentId = commentService.create(list.getId(), dh.getId(), "댓글이요", firstMentionIds).id();

// when
List<Long> newMentionedIds = List.of(js.getId(), ej.getId());
commentService.update(list.getId(), dh.getId(), commentId, "댓글 수정이요", newMentionedIds);
List<Long> newMentionIds = List.of(js.getId(), ej.getId());
commentService.update(list.getId(), dh.getId(), commentId, "댓글 수정이요", newMentionIds);

// then
CommentFindResponse response = commentService.findCommentBy(list.getId(), 5, null);
Expand Down Expand Up @@ -231,12 +231,12 @@ class 멘션_수정 {
void 답글을_수정해_새로운_멘션을_추가한다() {
// given
Long commentId = commentService.create(list.getId(), dh.getId(), "댓글이요", EMPTY_LIST).id();
List<Long> firstMentionedIds = List.of(dh.getId());
Long replyId = replyService.create(list.getId(), commentId, js.getId(), "답글이요", firstMentionedIds).id();
List<Long> firstMentionIds = List.of(dh.getId());
Long replyId = replyService.create(list.getId(), commentId, js.getId(), "답글이요", firstMentionIds).id();

// when
List<Long> newMentionedIds = List.of(dh.getId(), ej.getId());
ReplyUpdateCommand replyUpdateCommand = new ReplyUpdateCommand(list.getId(), commentId, replyId, "답글 수정이요", newMentionedIds);
List<Long> newMentionIds = List.of(dh.getId(), ej.getId());
ReplyUpdateCommand replyUpdateCommand = new ReplyUpdateCommand(list.getId(), commentId, replyId, "답글 수정이요", newMentionIds);
replyService.update(replyUpdateCommand, js.getId());

// then
Expand All @@ -253,8 +253,8 @@ class 멘션_수정 {
void 답글을_수정해_멘션을_제거한다() {
// given
Long commentId = commentService.create(list.getId(), dh.getId(), "댓글이요", EMPTY_LIST).id();
List<Long> firstMentionedIds = List.of(dh.getId());
Long replyId = replyService.create(list.getId(), commentId, js.getId(), "답글이요", firstMentionedIds).id();
List<Long> firstMentionIds = List.of(dh.getId());
Long replyId = replyService.create(list.getId(), commentId, js.getId(), "답글이요", firstMentionIds).id();

// when
ReplyUpdateCommand replyUpdateCommand = new ReplyUpdateCommand(list.getId(), commentId, replyId, "답글 수정이요", EMPTY_LIST);
Expand Down

0 comments on commit ca24f25

Please sign in to comment.