From eb66f813dfd6bdec8437aa2899d1507edba6d670 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Sun, 4 Aug 2024 12:15:46 +0900 Subject: [PATCH 01/12] =?UTF-8?q?refactor:=20mates=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?@ArraySchema=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/meeting/dto/response/MeetingWithMatesResponse.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java index 19b766973..73f13e002 100644 --- a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java @@ -2,6 +2,7 @@ import com.ody.mate.domain.Mate; import com.ody.meeting.domain.Meeting; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDate; import java.time.LocalTime; @@ -32,8 +33,8 @@ public record MeetingWithMatesResponse( @Schema(description = "참여자 인원 수", example = "1") int mateCount, - - @Schema(description = "참여자 닉네임 목록", example = "[{\"nickname\": \"오디\"}]") + + @ArraySchema(schema = @Schema(implementation = MateResponse.class)) List mates, @Schema(description = "초대코드", example = "초대코드") From cade1f1f3bb519150405a8efe9f601eeb25bc53e Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Sun, 4 Aug 2024 12:20:02 +0900 Subject: [PATCH 02/12] =?UTF-8?q?refactor:=20ErrorCode404=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/controller/MeetingControllerSwagger.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java index fa62774f6..7a4b3ed1f 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java @@ -10,6 +10,7 @@ import com.ody.notification.dto.response.NotiLogFindResponses; import com.ody.swagger.annotation.ErrorCode400; import com.ody.swagger.annotation.ErrorCode401; +import com.ody.swagger.annotation.ErrorCode404; import com.ody.swagger.annotation.ErrorCode500; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,17 +53,16 @@ ResponseEntity 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 = "존재하지 않는 약속이거나 해당 약속 참여자가 아닌 경우") @ErrorCode500 - ResponseEntity findMeetingWithMates(@Parameter(hidden = true) Member member, Long meetingId); + ResponseEntity findMeetingWithMates( + @Parameter(hidden = true) Member member, + Long meetingId + ); @Operation( summary = "참여중인 모임 목록 조회", From d474b2543aa8f3b90937c71d783877f5f5bad5a1 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Mon, 5 Aug 2024 00:41:59 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat:=20=EB=82=A0=EC=A7=9C,=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20JsonFormat=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/meeting/dto/response/MeetingWithMatesResponse.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java index 73f13e002..cd546a883 100644 --- a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java @@ -1,5 +1,6 @@ package com.ody.meeting.dto.response; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ody.mate.domain.Mate; import com.ody.meeting.domain.Meeting; import io.swagger.v3.oas.annotations.media.ArraySchema; @@ -17,9 +18,11 @@ public record MeetingWithMatesResponse( String name, @Schema(description = "약속 날짜", type = "string", example = "2024-07-15") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") LocalDate date, @Schema(description = "약속 시간", type = "string", example = "14:00") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") LocalTime time, @Schema(description = "도착지 주소", example = "서울 송파구 올림픽로35다길 42") @@ -33,7 +36,7 @@ public record MeetingWithMatesResponse( @Schema(description = "참여자 인원 수", example = "1") int mateCount, - + @ArraySchema(schema = @Schema(implementation = MateResponse.class)) List mates, From 4f3afe6bdd30ee85eda8e9a85b63b39074c67c8e Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Mon, 5 Aug 2024 08:35:56 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EC=9D=B4=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=ED=95=98=EA=B3=A0=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=ED=8A=B9=EC=A0=95=20=EC=95=BD=EC=86=8D=EC=9D=98=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ody/mate/service/MateService.java | 7 +++++++ .../com/ody/mate/service/MateServiceTest.java | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/backend/src/main/java/com/ody/mate/service/MateService.java b/backend/src/main/java/com/ody/mate/service/MateService.java index c15fd270e..e5b505d97 100644 --- a/backend/src/main/java/com/ody/mate/service/MateService.java +++ b/backend/src/main/java/com/ody/mate/service/MateService.java @@ -46,4 +46,11 @@ public MeetingSaveResponse findAllByMeetingId(Meeting meeting) { List mates = mateRepository.findAllByMeetingId(meeting.getId()); return MeetingSaveResponse.of(meeting, mates); } + + public List findAllByMemberAndMeetingId(Member member, Long meetingId) { + if (!mateRepository.existsByMeetingIdAndMemberId(meetingId, member.getId())) { + throw new OdyBadRequestException("존재하지 않는 모임이거나 약속 참여자가 아닙니다."); + } + return mateRepository.findAllByMeetingId(meetingId); + } } diff --git a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java index 45804255d..26c9864e7 100644 --- a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java +++ b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java @@ -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,6 +15,7 @@ import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.Member; import com.ody.member.repository.MemberRepository; +import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -72,4 +74,23 @@ void saveMateWithDuplicateNickname() { assertThatThrownBy(() -> mateService.save(mateSaveRequest, meeting, member2)) .isInstanceOf(OdyBadRequestException.class); } + + @DisplayName("회원이 참여하고 있는 특정 약속의 참여자 리스트를 조회한다.") + @Test + void findAllByMemberAndMeetingIdSuccess() { + Member member1 = memberRepository.save(Fixture.MEMBER1); + memberRepository.save(Fixture.MEMBER2); + + Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); + + Long mate1Id = mateRepository.save(Fixture.MATE1).getId(); + Long mate2Id = mateRepository.save(Fixture.MATE2).getId(); + + List mates = mateService.findAllByMemberAndMeetingId(member1, meetingId); + List mateIds = mates.stream() + .map(Mate::getId) + .toList(); + + assertThat(mateIds).containsOnly(mate1Id, mate2Id); + } } From 79d4f7b0f6ca3f069ca81895b74075ea40b6c042 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Mon, 5 Aug 2024 08:40:46 +0900 Subject: [PATCH 05/12] =?UTF-8?q?test:=20=EC=95=BD=EC=86=8D=EC=97=90=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=ED=95=98=EA=B3=A0=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EC=9D=B4=20=EC=95=84=EB=8B=88=EB=A9=B4=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=20=EB=B0=9C=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ody/mate/service/MateServiceTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java index 26c9864e7..ea54dc113 100644 --- a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java +++ b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java @@ -16,6 +16,7 @@ import com.ody.member.domain.Member; import com.ody.member.repository.MemberRepository; import java.util.List; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -93,4 +94,17 @@ void findAllByMemberAndMeetingIdSuccess() { assertThat(mateIds).containsOnly(mate1Id, mate2Id); } + + @DisplayName("약속에 참여하고 있는 회원이 아니면 예외가 발생한다.") + @Test + void findAllByMemberAndMeetingIdException() { + memberRepository.save(Fixture.MEMBER1); + Member member2 = memberRepository.save(Fixture.MEMBER2); + + Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); + mateRepository.save(Fixture.MATE1); + + Assertions.assertThatThrownBy(() -> mateService.findAllByMemberAndMeetingId(member2, meetingId)) + .isInstanceOf(OdyBadRequestException.class); + } } From 020efd66229c218cf8c3f1ab46673458b30e7a81 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Mon, 5 Aug 2024 08:57:20 +0900 Subject: [PATCH 06/12] =?UTF-8?q?feat:=20=EC=95=BD=EC=86=8D=EA=B3=BC=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=EC=9E=90=EB=93=A4=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/meeting/service/MeetingService.java | 22 ++----- .../meeting/service/MeetingServiceTest.java | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java diff --git a/backend/src/main/java/com/ody/meeting/service/MeetingService.java b/backend/src/main/java/com/ody/meeting/service/MeetingService.java index d44dba955..47ce517d9 100644 --- a/backend/src/main/java/com/ody/meeting/service/MeetingService.java +++ b/backend/src/main/java/com/ody/meeting/service/MeetingService.java @@ -2,13 +2,13 @@ import com.ody.common.exception.OdyNotFoundException; import com.ody.mate.domain.EtaStatus; +import com.ody.mate.domain.Mate; import com.ody.mate.dto.request.MateEtaRequest; import com.ody.mate.dto.request.MateSaveRequest; import com.ody.mate.dto.response.MateEtaResponse; import com.ody.mate.dto.response.MateEtaResponses; import com.ody.mate.service.MateService; import com.ody.meeting.domain.Meeting; -import com.ody.meeting.dto.response.MateResponse; import com.ody.meeting.dto.request.MeetingSaveRequest; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; @@ -16,8 +16,6 @@ import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.Member; import com.ody.util.InviteCodeGenerator; -import java.time.LocalDate; -import java.time.LocalTime; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -78,21 +76,9 @@ public MeetingSaveResponses findAllMeetingsByMember(Member member) { } public MeetingWithMatesResponse findMeetingWithMates(Member member, Long meetingId) { - return new MeetingWithMatesResponse( - 1L, - "우테코 16조", - LocalDate.parse("2024-07-15"), - LocalTime.parse("14:00"), - "서울 송파구 올림픽로35다길 42", - "37.515298", - "127.103113", - 2, - List.of( - new MateResponse("오디"), - new MateResponse("제리") - ), - "초대코드" - ); + Meeting meeting = findById(meetingId); + List mates = mateService.findAllByMemberAndMeetingId(member, meetingId); + return MeetingWithMatesResponse.of(meeting, mates); } public MateEtaResponses findAllMateEtas(Long meetingId, MateEtaRequest mateEtaRequest) { diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java new file mode 100644 index 000000000..dcc1b6bc2 --- /dev/null +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -0,0 +1,57 @@ +package com.ody.meeting.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + +import com.ody.common.BaseServiceTest; +import com.ody.common.Fixture; +import com.ody.mate.repository.MateRepository; +import com.ody.meeting.dto.response.MateResponse; +import com.ody.meeting.dto.response.MeetingWithMatesResponse; +import com.ody.meeting.repository.MeetingRepository; +import com.ody.member.domain.Member; +import com.ody.member.repository.MemberRepository; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +class MeetingServiceTest extends BaseServiceTest { + + @Autowired + private MeetingService meetingService; + + @Autowired + private MemberRepository memberRepository; + + @Autowired + private MeetingRepository meetingRepository; + + @Autowired + private MateRepository mateRepository; + + @DisplayName("약속과 참여자들 정보를 조회한다.") + @Test + void findMeetingWithMatesSuccess() { + Member member1 = memberRepository.save(Fixture.MEMBER1); + memberRepository.save(Fixture.MEMBER2); + + Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); + + mateRepository.save(Fixture.MATE1); + mateRepository.save(Fixture.MATE2); + + MeetingWithMatesResponse meetingWithMatesResponses = meetingService.findMeetingWithMates(member1, meetingId); + List mateNicknames = meetingWithMatesResponses.mates().stream() + .map(MateResponse::nickname) + .toList(); + + assertAll( + () -> assertThat(meetingWithMatesResponses.id()).isEqualTo(meetingId), + () -> assertThat(mateNicknames).containsOnly( + Fixture.MATE1.getNicknameValue(), + Fixture.MATE2.getNicknameValue() + ) + ); + } +} From 868e5b20e68e48f6f4fe963365fd409f0f043037 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Mon, 5 Aug 2024 09:00:22 +0900 Subject: [PATCH 07/12] =?UTF-8?q?test:=20=EC=95=BD=EC=86=8D=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C,=20=EC=95=BD=EC=86=8D=EC=9D=B4=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20=EC=98=88=EC=99=B8=20=EB=B0=9C=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ody/meeting/service/MeetingServiceTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java index dcc1b6bc2..7aa8b0446 100644 --- a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -1,10 +1,12 @@ package com.ody.meeting.service; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; import com.ody.common.BaseServiceTest; import com.ody.common.Fixture; +import com.ody.common.exception.OdyNotFoundException; import com.ody.mate.repository.MateRepository; import com.ody.meeting.dto.response.MateResponse; import com.ody.meeting.dto.response.MeetingWithMatesResponse; @@ -54,4 +56,13 @@ void findMeetingWithMatesSuccess() { ) ); } + + @DisplayName("약속 조회 시, 약속이 존재하지 않으면 예외가 발생한다.") + @Test + void findMeetingWithMatesException() { + Member member = memberRepository.save(Fixture.MEMBER1); + + assertThatThrownBy(() -> meetingService.findMeetingWithMates(member, 1L)) + .isInstanceOf(OdyNotFoundException.class); + } } From fa21a9b92ce3be1655c117c17b62eaaaa8dbbfb3 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Tue, 6 Aug 2024 00:33:49 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20meetingId=20primitive=20type?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/com/ody/mate/service/MateService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/ody/mate/service/MateService.java b/backend/src/main/java/com/ody/mate/service/MateService.java index e5b505d97..e513af348 100644 --- a/backend/src/main/java/com/ody/mate/service/MateService.java +++ b/backend/src/main/java/com/ody/mate/service/MateService.java @@ -47,7 +47,7 @@ public MeetingSaveResponse findAllByMeetingId(Meeting meeting) { return MeetingSaveResponse.of(meeting, mates); } - public List findAllByMemberAndMeetingId(Member member, Long meetingId) { + public List findAllByMemberAndMeetingId(Member member, long meetingId) { if (!mateRepository.existsByMeetingIdAndMemberId(meetingId, member.getId())) { throw new OdyBadRequestException("존재하지 않는 모임이거나 약속 참여자가 아닙니다."); } From b03af78c1b73c92ab3a2f6d1149f3330e1ae7abb Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Tue, 6 Aug 2024 15:32:18 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20JsonFormat=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=98=B5=EC=85=98=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ody/meeting/dto/response/MeetingWithMatesResponse.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java index cd546a883..c957942df 100644 --- a/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingWithMatesResponse.java @@ -18,11 +18,10 @@ public record MeetingWithMatesResponse( String name, @Schema(description = "약속 날짜", type = "string", example = "2024-07-15") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") LocalDate date, @Schema(description = "약속 시간", type = "string", example = "14:00") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @JsonFormat(pattern = "HH:mm") LocalTime time, @Schema(description = "도착지 주소", example = "서울 송파구 올림픽로35다길 42") From ec00da9847bb4a8293ba7a503d5f63651580f6a8 Mon Sep 17 00:00:00 2001 From: eun-byeol Date: Tue, 6 Aug 2024 19:58:28 +0900 Subject: [PATCH 10/12] =?UTF-8?q?test:=20Fixture.MATE=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ody/mate/service/MateServiceTest.java | 21 ++++++++-------- .../meeting/service/MeetingServiceTest.java | 24 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java index ea54dc113..065fc4ec0 100644 --- a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java +++ b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java @@ -16,7 +16,6 @@ import com.ody.member.domain.Member; import com.ody.member.repository.MemberRepository; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -80,31 +79,31 @@ void saveMateWithDuplicateNickname() { @Test void findAllByMemberAndMeetingIdSuccess() { Member member1 = memberRepository.save(Fixture.MEMBER1); - memberRepository.save(Fixture.MEMBER2); + Member member2 = memberRepository.save(Fixture.MEMBER2); - Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); + Meeting meeting = meetingRepository.save(Fixture.ODY_MEETING1); - Long mate1Id = mateRepository.save(Fixture.MATE1).getId(); - Long mate2Id = mateRepository.save(Fixture.MATE2).getId(); + 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 mates = mateService.findAllByMemberAndMeetingId(member1, meetingId); + List mates = mateService.findAllByMemberAndMeetingId(member1, meeting.getId()); List mateIds = mates.stream() .map(Mate::getId) .toList(); - assertThat(mateIds).containsOnly(mate1Id, mate2Id); + assertThat(mateIds).containsOnly(mate1.getId(), mate2.getId()); } @DisplayName("약속에 참여하고 있는 회원이 아니면 예외가 발생한다.") @Test void findAllByMemberAndMeetingIdException() { - memberRepository.save(Fixture.MEMBER1); + Member member1 = memberRepository.save(Fixture.MEMBER1); Member member2 = memberRepository.save(Fixture.MEMBER2); - Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); - mateRepository.save(Fixture.MATE1); + Meeting meeting = meetingRepository.save(Fixture.ODY_MEETING1); + mateRepository.save(new Mate(meeting, member1, new Nickname("조조"), Fixture.ORIGIN_LOCATION)); - Assertions.assertThatThrownBy(() -> mateService.findAllByMemberAndMeetingId(member2, meetingId)) + assertThatThrownBy(() -> mateService.findAllByMemberAndMeetingId(member2, meeting.getId())) .isInstanceOf(OdyBadRequestException.class); } } diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java index 09d049a42..3f1cb4c1e 100644 --- a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -7,6 +7,8 @@ import com.ody.common.BaseServiceTest; import com.ody.common.Fixture; import com.ody.common.exception.OdyNotFoundException; +import com.ody.mate.domain.Mate; +import com.ody.mate.domain.Nickname; import com.ody.mate.repository.MateRepository; import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.request.MeetingSaveRequestV1; @@ -66,24 +68,24 @@ void saveV1Success() { @Test void findMeetingWithMatesSuccess() { Member member1 = memberRepository.save(Fixture.MEMBER1); - memberRepository.save(Fixture.MEMBER2); + Member member2 = memberRepository.save(Fixture.MEMBER2); - Long meetingId = meetingRepository.save(Fixture.ODY_MEETING1).getId(); + Meeting meeting = meetingRepository.save(Fixture.ODY_MEETING1); - mateRepository.save(Fixture.MATE1); - mateRepository.save(Fixture.MATE2); + Mate mate1 = new Mate(meeting, member1, new Nickname("조조"), Fixture.ORIGIN_LOCATION); + Mate mate2 = new Mate(meeting, member2, new Nickname("제리"), Fixture.ORIGIN_LOCATION); - MeetingWithMatesResponse meetingWithMatesResponses = meetingService.findMeetingWithMates(member1, meetingId); - List mateNicknames = meetingWithMatesResponses.mates().stream() + mateRepository.save(mate1); + mateRepository.save(mate2); + + MeetingWithMatesResponse response = meetingService.findMeetingWithMates(member1, meeting.getId()); + List mateNicknames = response.mates().stream() .map(MateResponse::nickname) .toList(); assertAll( - () -> assertThat(meetingWithMatesResponses.id()).isEqualTo(meetingId), - () -> assertThat(mateNicknames).containsOnly( - Fixture.MATE1.getNicknameValue(), - Fixture.MATE2.getNicknameValue() - ) + () -> assertThat(response.id()).isEqualTo(meeting.getId()), + () -> assertThat(mateNicknames).containsOnly(mate1.getNicknameValue(), mate2.getNicknameValue()) ); } From c4f8a95f92a6dc75eb88ffb4ea3991941cb5212b Mon Sep 17 00:00:00 2001 From: eun-byeol <62530884+eun-byeol@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:19:06 +0900 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20import=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/com/ody/mate/service/MateService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/com/ody/mate/service/MateService.java b/backend/src/main/java/com/ody/mate/service/MateService.java index 4f7c0784f..3689b85ed 100644 --- a/backend/src/main/java/com/ody/mate/service/MateService.java +++ b/backend/src/main/java/com/ody/mate/service/MateService.java @@ -8,6 +8,7 @@ import com.ody.meeting.domain.Meeting; import com.ody.member.domain.Member; import com.ody.notification.service.NotificationService; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From 0dbd36368a2b9c325fbb60d96778500ca3f2bf72 Mon Sep 17 00:00:00 2001 From: mzeong Date: Tue, 6 Aug 2024 20:28:46 +0900 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20=EB=A8=B8=EC=A7=80=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=EC=97=90=EC=84=9C=20=EB=88=84=EB=9D=BD=EB=90=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/com/ody/mate/service/MateServiceTest.java | 4 ++++ .../test/java/com/ody/meeting/service/MeetingServiceTest.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java index 28ff603d7..d0b214c40 100644 --- a/backend/src/test/java/com/ody/mate/service/MateServiceTest.java +++ b/backend/src/test/java/com/ody/mate/service/MateServiceTest.java @@ -15,6 +15,7 @@ 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; @@ -39,6 +40,9 @@ class MateServiceTest extends BaseServiceTest { @Autowired private MateService mateService; + @Autowired + private MeetingRepository meetingRepository; + @DisplayName("모임 내 닉네임이 중복되지 않으면 모임에 참여한다.") @Test void saveMate() { diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java index 79608c9d7..add5ca0d1 100644 --- a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -9,10 +9,10 @@ import com.ody.common.exception.OdyNotFoundException; import com.ody.mate.domain.Mate; import com.ody.mate.domain.Nickname; +import com.ody.mate.dto.response.MateResponse; import com.ody.mate.repository.MateRepository; import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.request.MeetingSaveRequestV1; -import com.ody.meeting.dto.response.MateResponse; import com.ody.meeting.dto.response.MeetingFindByMemberResponse; import com.ody.meeting.dto.response.MeetingSaveResponseV1; import com.ody.meeting.dto.response.MeetingWithMatesResponse;