-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: 약속 단건 조회 API 구현 #256
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eb66f81
refactor: mates 필드 @ArraySchema로 수정
eun-byeol cade1f1
refactor: ErrorCode404 어노테이션으로 수정
eun-byeol d474b25
feat: 날짜, 시간 JsonFormat 적용
eun-byeol 4f3afe6
feat: 회원이 참여하고 있는 특정 약속의 참여자 리스트 조회
eun-byeol 79d4f7b
test: 약속에 참여하고 있는 회원이 아니면 예외 발생
eun-byeol 020efd6
feat: 약속과 참여자들 정보 조회
eun-byeol 868e5b2
test: 약속 조회 시, 약속이 존재하지 않으면 예외 발생
eun-byeol f5fb8dc
Merge branch 'develop' into feature/224
eun-byeol fa21a9b
refactor: meetingId primitive type으로 변경
eun-byeol b03af78
refactor: JsonFormat 불필요한 옵션 제거
eun-byeol ec00da9
test: Fixture.MATE 제거
eun-byeol 9f8055e
Merge branch 'develop' into feature/224
eun-byeol c4f8a95
fix: import 추가
eun-byeol 0dbd363
fix: 머지 과정에서 누락된 코드 추가
mzeong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,17 +57,16 @@ ResponseEntity<MeetingSaveResponse> save( | |
responseCode = "200", | ||
description = "약속 단건 조회 성공", | ||
content = @Content(schema = @Schema(implementation = MeetingWithMatesResponse.class)) | ||
), | ||
@ApiResponse( | ||
responseCode = "404", | ||
description = "존재하지 않는 약속이거나 해당 약속 참여자가 아닌 경우", | ||
content = @Content(schema = @Schema(implementation = ProblemDetail.class)) | ||
) | ||
} | ||
) | ||
@ErrorCode401 | ||
@ErrorCode404(description = "존재하지 않는 약속이거나 해당 약속 참여자가 아닌 경우") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
@ErrorCode500 | ||
ResponseEntity<MeetingWithMatesResponse> findMeetingWithMates(@Parameter(hidden = true) Member member, Long meetingId); | ||
ResponseEntity<MeetingWithMatesResponse> findMeetingWithMates( | ||
@Parameter(hidden = true) Member member, | ||
Long meetingId | ||
); | ||
|
||
@Operation( | ||
summary = "참여중인 약속 목록 조회", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.ody.mate.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
|
@@ -14,11 +15,13 @@ | |
import com.ody.meeting.domain.Meeting; | ||
import com.ody.meeting.dto.request.MeetingSaveRequestV1; | ||
import com.ody.meeting.dto.response.MeetingSaveResponseV1; | ||
import com.ody.meeting.repository.MeetingRepository; | ||
import com.ody.meeting.service.MeetingService; | ||
import com.ody.member.domain.Member; | ||
import com.ody.member.repository.MemberRepository; | ||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
@@ -37,6 +40,9 @@ class MateServiceTest extends BaseServiceTest { | |
@Autowired | ||
private MateService mateService; | ||
|
||
@Autowired | ||
private MeetingRepository meetingRepository; | ||
|
||
@DisplayName("모임 내 닉네임이 중복되지 않으면 모임에 참여한다.") | ||
@Test | ||
void saveMate() { | ||
|
@@ -132,4 +138,36 @@ void saveMateWithDuplicateNickname() { | |
assertThatThrownBy(() -> mateService.saveAndSendNotifications(mateSaveRequest, member2, meeting)) | ||
.isInstanceOf(OdyBadRequestException.class); | ||
} | ||
|
||
@DisplayName("회원이 참여하고 있는 특정 약속의 참여자 리스트를 조회한다.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 예외 상황까지 꼼꼼한 테스트 👍🏻 |
||
@Test | ||
void findAllByMemberAndMeetingIdSuccess() { | ||
Member member1 = memberRepository.save(Fixture.MEMBER1); | ||
Member member2 = memberRepository.save(Fixture.MEMBER2); | ||
|
||
Meeting meeting = meetingRepository.save(Fixture.ODY_MEETING1); | ||
|
||
Mate mate1 = mateRepository.save(new Mate(meeting, member1, new Nickname("조조"), Fixture.ORIGIN_LOCATION)); | ||
Mate mate2 = mateRepository.save(new Mate(meeting, member2, new Nickname("제리"), Fixture.ORIGIN_LOCATION)); | ||
|
||
List<Mate> mates = mateService.findAllByMemberAndMeetingId(member1, meeting.getId()); | ||
List<Long> mateIds = mates.stream() | ||
.map(Mate::getId) | ||
.toList(); | ||
|
||
assertThat(mateIds).containsOnly(mate1.getId(), mate2.getId()); | ||
} | ||
|
||
@DisplayName("약속에 참여하고 있는 회원이 아니면 예외가 발생한다.") | ||
@Test | ||
void findAllByMemberAndMeetingIdException() { | ||
Member member1 = memberRepository.save(Fixture.MEMBER1); | ||
Member member2 = memberRepository.save(Fixture.MEMBER2); | ||
|
||
Meeting meeting = meetingRepository.save(Fixture.ODY_MEETING1); | ||
mateRepository.save(new Mate(meeting, member1, new Nickname("조조"), Fixture.ORIGIN_LOCATION)); | ||
|
||
assertThatThrownBy(() -> mateService.findAllByMemberAndMeetingId(member2, meeting.getId())) | ||
.isInstanceOf(OdyBadRequestException.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[질문] 해당 메서드가 dto인
MeetingWithMatesResponse
를 반환하게 하지 않고List<Mate>
를 반환하게 한 이유가 있나요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
두 가지 이유가 있었어요.
약속 1건 조회의 책임이
Mate
보다는Meeting
에 있다고 생각했어요.물론, Mate는 Meeting을 알고 있어서 Mate에서 Response를 반환할 수도 있겠지만,
MeetingService
가MateService
를 호출만 하게 되는 구조가 어색한 것 같아요.MateService
에서 바로 반환하면,MateRepository
의 재사용성이 매우 낮다고 생각했어요.MateService에서 Response를 반환하게 되면, 사실상 MeetingService는 불필요해요.
MateService
에서 모든 로직을 처리하고,MateRepository
한방쿼리로 해결할 수 있을 거예요. 당장은 Mate 인원수가 최대 8명이고, 성능이 중요한 케이스는 아니라고 생각해요.Repository 재사용성 측면
을 더 고려했습니다!