-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: 참여중인 방 목록 조회 #95
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
73548a0
feat: 참여중인 방 목록 조회 기능 구현
ymkim97 4138363
feat: 관련 Repository 구현
ymkim97 97e1eca
test: 참여중인 방 목록 조회 테스트 작성
ymkim97 1327d9d
Merge branch 'develop' into feature/#67-my-rooms
ymkim97 a631bed
Merge branch 'develop' into feature/#67-my-rooms
ymkim97 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
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/moabam/api/domain/room/repository/DailyMemberCertificationRepository.java
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,9 +1,13 @@ | ||
package com.moabam.api.domain.room.repository; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.moabam.api.domain.room.DailyMemberCertification; | ||
|
||
public interface DailyMemberCertificationRepository extends JpaRepository<DailyMemberCertification, Long> { | ||
|
||
boolean existsByMemberIdAndRoomIdAndCreatedAtBetween(Long memberId, Long roomId, LocalDateTime startTime, | ||
LocalDateTime endTime); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/moabam/api/domain/room/repository/DailyRoomCertificationRepository.java
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,9 +1,12 @@ | ||
package com.moabam.api.domain.room.repository; | ||
|
||
import java.time.LocalDate; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.moabam.api.domain.room.DailyRoomCertification; | ||
|
||
public interface DailyRoomCertificationRepository extends JpaRepository<DailyRoomCertification, Long> { | ||
|
||
boolean existsByRoomIdAndCertifiedAt(Long roomId, LocalDate date); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.moabam.api.dto.room; | ||
|
||
import com.moabam.api.domain.room.RoomType; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record MyRoomResponse( | ||
Long roomId, | ||
String title, | ||
RoomType roomType, | ||
int certifyTime, | ||
int currentUserCount, | ||
int maxUserCount, | ||
int obtainedBugs, | ||
boolean isMemberCertifiedToday, | ||
boolean isRoomCertifiedToday | ||
) { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/moabam/api/dto/room/MyRoomsResponse.java
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.moabam.api.dto.room; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record MyRoomsResponse( | ||
List<MyRoomResponse> participatingRooms | ||
) { | ||
|
||
} |
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
90 changes: 90 additions & 0 deletions
90
src/test/java/com/moabam/api/application/room/RoomSearchServiceTest.java
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.moabam.api.application.room; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.BDDMockito.*; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import com.moabam.api.application.member.MemberService; | ||
import com.moabam.api.domain.room.Participant; | ||
import com.moabam.api.domain.room.Room; | ||
import com.moabam.api.domain.room.RoomType; | ||
import com.moabam.api.domain.room.repository.CertificationsSearchRepository; | ||
import com.moabam.api.domain.room.repository.ParticipantSearchRepository; | ||
import com.moabam.api.domain.room.repository.RoutineSearchRepository; | ||
import com.moabam.api.dto.room.MyRoomsResponse; | ||
import com.moabam.support.fixture.RoomFixture; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class RoomSearchServiceTest { | ||
|
||
@InjectMocks | ||
private RoomSearchService roomSearchService; | ||
|
||
@Mock | ||
private CertificationsSearchRepository certificationsSearchRepository; | ||
|
||
@Mock | ||
private ParticipantSearchRepository participantSearchRepository; | ||
|
||
@Mock | ||
private RoutineSearchRepository routineSearchRepository; | ||
|
||
@Mock | ||
private MemberService memberService; | ||
|
||
@Mock | ||
private RoomCertificationService certificationService; | ||
|
||
@DisplayName("유저가 참여중인 방 목록 조회 성공") | ||
@Test | ||
void get_my_rooms_success() { | ||
// given | ||
LocalDate today = LocalDate.now(); | ||
Long memberId = 1L; | ||
Room room1 = spy(RoomFixture.room("아침 - 첫 번째 방", RoomType.MORNING, 10)); | ||
Room room2 = spy(RoomFixture.room("아침 - 두 번째 방", RoomType.MORNING, 9)); | ||
Room room3 = spy(RoomFixture.room("밤 - 첫 번째 방", RoomType.NIGHT, 22)); | ||
|
||
lenient().when(room1.getId()).thenReturn(1L); | ||
lenient().when(room2.getId()).thenReturn(2L); | ||
lenient().when(room3.getId()).thenReturn(3L); | ||
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. Q: lenient를 사용한 이유가 있나요? doReturn으로는 대체가 안되는 건가요? 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.
|
||
|
||
Participant participant1 = RoomFixture.participant(room1, memberId); | ||
Participant participant2 = RoomFixture.participant(room2, memberId); | ||
Participant participant3 = RoomFixture.participant(room3, memberId); | ||
List<Participant> participants = List.of(participant1, participant2, participant3); | ||
|
||
given(participantSearchRepository.findParticipantsByMemberId(memberId)).willReturn(participants); | ||
given(certificationService.existsMemberCertification(memberId, room1.getId(), today)).willReturn(true); | ||
given(certificationService.existsMemberCertification(memberId, room2.getId(), today)).willReturn(false); | ||
given(certificationService.existsMemberCertification(memberId, room3.getId(), today)).willReturn(true); | ||
|
||
given(certificationService.existsRoomCertification(room1.getId(), today)).willReturn(true); | ||
given(certificationService.existsRoomCertification(room2.getId(), today)).willReturn(false); | ||
given(certificationService.existsRoomCertification(room3.getId(), today)).willReturn(false); | ||
|
||
// when | ||
MyRoomsResponse myRooms = roomSearchService.getMyRooms(memberId); | ||
|
||
// then | ||
assertThat(myRooms.participatingRooms()).hasSize(3); | ||
|
||
assertThat(myRooms.participatingRooms().get(0).isMemberCertifiedToday()).isTrue(); | ||
assertThat(myRooms.participatingRooms().get(0).isRoomCertifiedToday()).isTrue(); | ||
|
||
assertThat(myRooms.participatingRooms().get(1).isMemberCertifiedToday()).isFalse(); | ||
assertThat(myRooms.participatingRooms().get(1).isRoomCertifiedToday()).isFalse(); | ||
|
||
assertThat(myRooms.participatingRooms().get(2).isMemberCertifiedToday()).isTrue(); | ||
assertThat(myRooms.participatingRooms().get(2).isRoomCertifiedToday()).isFalse(); | ||
} | ||
} |
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
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.
obtainedBug 먼가 했네 ㅋ.ㅋ 근데 생각해보니까 이거 있으면 걍 이것도 더하면 되는건데 괜히 API 따로 만든듯..
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.
오잉 그러네요 ㅋㅋㅋㅋㅋ 일단은 필요할지도 모르니 keep~ ㅎ.ㅎ