diff --git a/src/main/java/com/moabam/api/application/room/RoomSearchService.java b/src/main/java/com/moabam/api/application/room/RoomSearchService.java index 1d7e3c57..912eea8f 100644 --- a/src/main/java/com/moabam/api/application/room/RoomSearchService.java +++ b/src/main/java/com/moabam/api/application/room/RoomSearchService.java @@ -28,6 +28,7 @@ import com.moabam.api.domain.room.Routine; import com.moabam.api.domain.room.repository.CertificationsSearchRepository; import com.moabam.api.domain.room.repository.ParticipantSearchRepository; +import com.moabam.api.domain.room.repository.RoomRepository; import com.moabam.api.domain.room.repository.RoomSearchRepository; import com.moabam.api.domain.room.repository.RoutineSearchRepository; import com.moabam.api.dto.room.CertificationImageResponse; @@ -54,6 +55,7 @@ public class RoomSearchService { private final ParticipantSearchRepository participantSearchRepository; private final RoutineSearchRepository routineSearchRepository; private final RoomSearchRepository roomSearchRepository; + private final RoomRepository roomRepository; private final MemberService memberService; private final RoomCertificationService roomCertificationService; private final NotificationService notificationService; @@ -116,7 +118,38 @@ public RoomsHistoryResponse getJoinHistory(Long memberId) { public SearchAllRoomsResponse searchAllRooms(@Nullable RoomType roomType, @Nullable Long roomId) { List searchAllRoomResponses = new ArrayList<>(); List rooms = new ArrayList<>(roomSearchRepository.findAllWithNoOffset(roomType, roomId)); + boolean hasNext = isHasNext(searchAllRoomResponses, rooms); + return RoomMapper.toSearchAllRoomsResponse(hasNext, searchAllRoomResponses); + } + + public SearchAllRoomsResponse search(String keyword, @Nullable RoomType roomType, @Nullable Long roomId) { + List searchAllRoomResponses = new ArrayList<>(); + List rooms = new ArrayList<>(); + + if (roomId == null && roomType == null) { + rooms = new ArrayList<>(roomRepository.searchByKeyword(keyword)); + } + + if (roomId == null && roomType != null) { + rooms = new ArrayList<>(roomRepository.searchByKeywordAndRoomType(keyword, roomType.name())); + } + + if (roomId != null && roomType == null) { + rooms = new ArrayList<>(roomRepository.searchByKeywordAndRoomId(keyword, roomId)); + } + + if (roomId != null && roomType != null) { + rooms = new ArrayList<>( + roomRepository.searchByKeywordAndRoomIdAndRoomType(keyword, roomType.name(), roomId)); + } + + boolean hasNext = isHasNext(searchAllRoomResponses, rooms); + + return RoomMapper.toSearchAllRoomsResponse(hasNext, searchAllRoomResponses); + } + + private boolean isHasNext(List searchAllRoomResponses, List rooms) { boolean hasNext = false; if (rooms.size() > ROOM_FIXED_SEARCH_SIZE) { @@ -138,8 +171,7 @@ public SearchAllRoomsResponse searchAllRooms(@Nullable RoomType roomType, @Nulla RoomMapper.toSearchAllRoomResponse(room, RoutineMapper.toRoutineResponses(filteredRoutines), isPassword)); } - - return RoomMapper.toSearchAllRoomsResponse(hasNext, searchAllRoomResponses); + return hasNext; } private List getRoutineResponses(Long roomId) { diff --git a/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java b/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java index 9fe19658..0c52f23c 100644 --- a/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java +++ b/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java @@ -42,14 +42,14 @@ public static RoomDetailsResponse toRoomDetailsResponse(Long memberId, Room room .managerNickName(managerNickname) .roomImage(room.getRoomImage()) .level(room.getLevel()) - .roomType(room.getRoomType().name()) + .roomType(room.getRoomType()) .certifyTime(room.getCertifyTime()) .currentUserCount(room.getCurrentUserCount()) .maxUserCount(room.getMaxUserCount()) .announcement(room.getAnnouncement()) .completePercentage(completePercentage) .certifiedDates(certifiedDates) - .routine(routineResponses) + .routines(routineResponses) .todayCertificateRank(todayCertificateRankResponses) .build(); } @@ -103,7 +103,7 @@ public static SearchAllRoomResponse toSearchAllRoomResponse(Room room, List { + @Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " + + "where rm.title like %:keyword% " + + "or rm.manager_nickname like %:keyword% " + + "or rt.content like %:keyword% " + + "order by rm.id desc limit 11", nativeQuery = true) + List searchByKeyword(@Param(value = "keyword") String keyword); + + @Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " + + "where (rm.title like %:keyword% " + + "or rm.manager_nickname like %:keyword% " + + "or rt.content like %:keyword%) " + + "and rm.room_type = :roomType " + + "order by rm.id desc limit 11", nativeQuery = true) + List searchByKeywordAndRoomType(@Param(value = "keyword") String keyword, + @Param(value = "roomType") String roomType); + + @Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " + + "where (rm.title like %:keyword% " + + "or rm.manager_nickname like %:keyword% " + + "or rt.content like %:keyword%) " + + "and rm.id < :roomId " + + "order by rm.id desc limit 11", nativeQuery = true) + List searchByKeywordAndRoomId(@Param(value = "keyword") String keyword, @Param(value = "roomId") Long roomId); + + @Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " + + "where rm.title like %:keyword% " + + "or rm.manager_nickname like %:keyword% " + + "or rt.content like %:keyword% " + + "and rm.room_type = :roomType " + + "and rm.id < :roomId " + + "order by rm.id desc limit 11", nativeQuery = true) + List searchByKeywordAndRoomIdAndRoomType(@Param(value = "keyword") String keyword, + @Param(value = "roomType") String roomType, @Param(value = "roomId") Long roomId); } diff --git a/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java b/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java index bdac9689..abb7d06b 100644 --- a/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java +++ b/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java @@ -3,6 +3,8 @@ import java.time.LocalDate; import java.util.List; +import com.moabam.api.domain.room.RoomType; + import lombok.Builder; @Builder @@ -13,14 +15,14 @@ public record RoomDetailsResponse( String managerNickName, String roomImage, int level, - String roomType, + RoomType roomType, int certifyTime, int currentUserCount, int maxUserCount, String announcement, double completePercentage, List certifiedDates, - List routine, + List routines, List todayCertificateRank ) { diff --git a/src/main/java/com/moabam/api/dto/room/SearchAllRoomResponse.java b/src/main/java/com/moabam/api/dto/room/SearchAllRoomResponse.java index 1960f105..cdb35ab4 100644 --- a/src/main/java/com/moabam/api/dto/room/SearchAllRoomResponse.java +++ b/src/main/java/com/moabam/api/dto/room/SearchAllRoomResponse.java @@ -18,7 +18,7 @@ public record SearchAllRoomResponse( int certifyTime, int currentUserCount, int maxUserCount, - List routine + List routines ) { } diff --git a/src/main/java/com/moabam/api/presentation/RoomController.java b/src/main/java/com/moabam/api/presentation/RoomController.java index d37a54eb..3a354d64 100644 --- a/src/main/java/com/moabam/api/presentation/RoomController.java +++ b/src/main/java/com/moabam/api/presentation/RoomController.java @@ -119,9 +119,18 @@ public RoomsHistoryResponse getJoinHistory(@CurrentMember AuthorizationMember au @GetMapping @ResponseStatus(HttpStatus.OK) - public SearchAllRoomsResponse searchAllRooms(@RequestParam(value = "type", required = false) RoomType roomType, + public SearchAllRoomsResponse searchAllRooms(@RequestParam(value = "roomType", required = false) RoomType roomType, @RequestParam(value = "roomId", required = false) Long roomId) { return roomSearchService.searchAllRooms(roomType, roomId); } + + @GetMapping("/search") + @ResponseStatus(HttpStatus.OK) + public SearchAllRoomsResponse search(@RequestParam(value = "keyword") String keyword, + @RequestParam(value = "roomType", required = false) RoomType roomType, + @RequestParam(value = "roomId", required = false) Long roomId) { + + return roomSearchService.search(keyword, roomType, roomId); + } } diff --git a/src/test/java/com/moabam/api/application/room/RoomSearchServiceTest.java b/src/test/java/com/moabam/api/application/room/RoomSearchServiceTest.java index 23d136da..9507fdb0 100644 --- a/src/test/java/com/moabam/api/application/room/RoomSearchServiceTest.java +++ b/src/test/java/com/moabam/api/application/room/RoomSearchServiceTest.java @@ -1,7 +1,10 @@ package com.moabam.api.application.room; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.BDDMockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.anyList; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.spy; +import static org.mockito.BDDMockito.when; import java.time.LocalDate; import java.time.LocalDateTime; @@ -21,6 +24,7 @@ import com.moabam.api.domain.room.Routine; import com.moabam.api.domain.room.repository.CertificationsSearchRepository; import com.moabam.api.domain.room.repository.ParticipantSearchRepository; +import com.moabam.api.domain.room.repository.RoomRepository; import com.moabam.api.domain.room.repository.RoomSearchRepository; import com.moabam.api.domain.room.repository.RoutineSearchRepository; import com.moabam.api.dto.room.MyRoomsResponse; @@ -52,6 +56,9 @@ class RoomSearchServiceTest { @Mock private RoomCertificationService certificationService; + @Mock + private RoomRepository roomRepository; + @DisplayName("유저가 참여중인 방 목록 조회 성공") @Test void get_my_rooms_success() { @@ -304,4 +311,101 @@ void search_last_page_all_morning_night_rooms_success() { assertThat(searchAllRoomsResponse.rooms().get(0).id()).isEqualTo(11L); assertThat(searchAllRoomsResponse.rooms().get(3).id()).isEqualTo(14L); } + + @DisplayName("전체 방 제목, 방장 이름, 루틴 내용으로 검색 성공 - 최초 조회") + @Test + void search_room_by_title_manager_nickname_routine_success() { + // given + Room room1 = spy(RoomFixture.room("아침 - 첫 번째 방", RoomType.MORNING, 10, "1234")); + Room room2 = spy(RoomFixture.room("아침 - 두 번째 방", RoomType.MORNING, 9)); + Room room3 = spy(RoomFixture.room("밤 - 세 번째 방", RoomType.NIGHT, 22)); + Room room4 = spy(RoomFixture.room("아침 - 네 번째 방", RoomType.MORNING, 7)); + Room room5 = spy(RoomFixture.room("밤 - 다섯 번째 방", RoomType.NIGHT, 23, "5869")); + Room room6 = spy(RoomFixture.room("아침 - 여섯 번째 방", RoomType.MORNING, 8)); + Room room7 = spy(RoomFixture.room("밤 - 일곱 번째 방", RoomType.NIGHT, 20)); + Room room8 = spy(RoomFixture.room("밤 - 여덟 번째 방", RoomType.NIGHT, 1, "5236")); + Room room9 = spy(RoomFixture.room("아침 - 아홉 번째 방", RoomType.MORNING, 4)); + Room room10 = spy(RoomFixture.room("밤 - 열 번째 방", RoomType.NIGHT, 1, "97979")); + Room room11 = spy(RoomFixture.room("밤 - 열하나 번째 방", RoomType.NIGHT, 22)); + Room room12 = spy(RoomFixture.room("아침 - 열둘 번째 방", RoomType.MORNING, 10)); + Room room13 = spy(RoomFixture.room("밤 - 열셋 번째 방", RoomType.NIGHT, 2)); + Room room14 = spy(RoomFixture.room("밤 - 열넷 번째 방", RoomType.NIGHT, 21)); + + given(room4.getId()).willReturn(4L); + given(room5.getId()).willReturn(5L); + given(room6.getId()).willReturn(6L); + given(room7.getId()).willReturn(7L); + given(room8.getId()).willReturn(8L); + given(room9.getId()).willReturn(9L); + given(room10.getId()).willReturn(10L); + given(room11.getId()).willReturn(11L); + given(room12.getId()).willReturn(12L); + given(room13.getId()).willReturn(13L); + given(room14.getId()).willReturn(14L); + + List rooms = List.of(room4, room5, room6, room7, room8, room9, room10, room11, room12, room13, room14); + + Routine routine9 = spy(RoomFixture.routine(room5, "방5의 루틴1")); + Routine routine10 = spy(RoomFixture.routine(room5, "방5의 루틴2")); + + Routine routine11 = spy(RoomFixture.routine(room6, "방6의 루틴1")); + Routine routine12 = spy(RoomFixture.routine(room6, "방6의 루틴2")); + + Routine routine13 = spy(RoomFixture.routine(room7, "방7의 루틴1")); + Routine routine14 = spy(RoomFixture.routine(room7, "방7의 루틴2")); + + Routine routine15 = spy(RoomFixture.routine(room8, "방8의 루틴1")); + Routine routine16 = spy(RoomFixture.routine(room8, "방8의 루틴2")); + + Routine routine17 = spy(RoomFixture.routine(room9, "방9의 루틴1")); + Routine routine18 = spy(RoomFixture.routine(room9, "방9의 루틴2")); + + Routine routine19 = spy(RoomFixture.routine(room10, "방10의 루틴1")); + Routine routine20 = spy(RoomFixture.routine(room10, "방10의 루틴2")); + + Routine routine21 = spy(RoomFixture.routine(room11, "방11의 루틴1")); + Routine routine22 = spy(RoomFixture.routine(room11, "방11의 루틴2")); + + Routine routine23 = spy(RoomFixture.routine(room12, "방12의 루틴1")); + Routine routine24 = spy(RoomFixture.routine(room12, "방12의 루틴2")); + + Routine routine25 = spy(RoomFixture.routine(room13, "방13의 루틴1")); + Routine routine26 = spy(RoomFixture.routine(room13, "방13의 루틴2")); + + Routine routine27 = spy(RoomFixture.routine(room14, "방14의 루틴1")); + Routine routine28 = spy(RoomFixture.routine(room14, "방14의 루틴2")); + + given(routine9.getId()).willReturn(9L); + given(routine10.getId()).willReturn(10L); + given(routine11.getId()).willReturn(11L); + given(routine12.getId()).willReturn(12L); + given(routine13.getId()).willReturn(13L); + given(routine14.getId()).willReturn(14L); + given(routine15.getId()).willReturn(15L); + given(routine16.getId()).willReturn(16L); + given(routine17.getId()).willReturn(17L); + given(routine18.getId()).willReturn(18L); + given(routine19.getId()).willReturn(19L); + given(routine20.getId()).willReturn(20L); + given(routine21.getId()).willReturn(21L); + given(routine22.getId()).willReturn(22L); + given(routine23.getId()).willReturn(23L); + given(routine24.getId()).willReturn(24L); + given(routine25.getId()).willReturn(25L); + given(routine26.getId()).willReturn(26L); + + List routines = List.of(routine9, routine10, routine11, routine12, routine13, routine14, routine15, + routine16, routine17, routine18, routine19, routine20, routine21, routine22, routine23, routine24, + routine25, routine26, routine27, routine28); + + given(roomRepository.searchByKeyword("번째")).willReturn(rooms); + given(routineSearchRepository.findAllByRoomIds(anyList())).willReturn(routines); + + // when + SearchAllRoomsResponse searchAllRoomsResponse = roomSearchService.search("번째", null, null); + + // then + assertThat(searchAllRoomsResponse.hasNext()).isTrue(); + assertThat(searchAllRoomsResponse.rooms()).hasSize(10); + } } diff --git a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java index c6ae23ac..146d5155 100644 --- a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java @@ -1147,15 +1147,15 @@ void search_last_page_all_morning_rooms_success() throws Exception { routine20, routine21, routine22, routine23, routine24, routine25, routine26, routine27, routine28)); // expected - mockMvc.perform(get("/rooms?type=MORNING")) + mockMvc.perform(get("/rooms?roomType=MORNING")) .andExpect(status().isOk()) .andDo(print()); } - @DisplayName("저녁 방 전체 조회 성공 - 첫 번째 조회, 다음 페이지 없음") + @DisplayName("방 검색 조회 성공 - 키워드만 존재") @WithMember(id = 1L) @Test - void search_last_page_all_night_rooms_success() throws Exception { + void search_first_page_all_rooms_by_keyword_success() throws Exception { // given Room room1 = RoomFixture.room("아침 - 첫 번째 방", RoomType.MORNING, 10, "1234"); Room room2 = RoomFixture.room("아침 - 두 번째 방", RoomType.MORNING, 9); @@ -1224,7 +1224,169 @@ void search_last_page_all_night_rooms_success() throws Exception { routine20, routine21, routine22, routine23, routine24, routine25, routine26, routine27, routine28)); // expected - mockMvc.perform(get("/rooms?type=NIGHT")) + mockMvc.perform(get("/rooms/search?keyword=아침")) + .andExpect(status().isOk()) + .andDo(print()); + + mockMvc.perform(get("/rooms/search?keyword=방12")) + .andExpect(status().isOk()) + .andDo(print()); + + mockMvc.perform(get("/rooms/search?keyword=방")) + .andExpect(status().isOk()) + .andDo(print()); + } + + @DisplayName("방 검색 조회 성공 - 키워드 + 방 타입 존재") + @WithMember(id = 1L) + @Test + void search_first_page_all_rooms_by_keyword_roomType_success() throws Exception { + // given + Room room1 = RoomFixture.room("아침 - 첫 번째 방", RoomType.MORNING, 10, "1234"); + Room room2 = RoomFixture.room("아침 - 두 번째 방", RoomType.MORNING, 9); + Room room3 = RoomFixture.room("밤 - 세 번째 방", RoomType.NIGHT, 22); + Room room4 = RoomFixture.room("아침 - 네 번째 방", RoomType.MORNING, 7); + Room room5 = RoomFixture.room("밤 - 다섯 번째 방", RoomType.NIGHT, 23, "5869"); + Room room6 = RoomFixture.room("아침 - 여섯 번째 방", RoomType.MORNING, 8); + Room room7 = RoomFixture.room("밤 - 일곱 번째 방", RoomType.NIGHT, 20); + Room room8 = RoomFixture.room("밤 - 여덟 번째 방", RoomType.NIGHT, 1, "5236"); + Room room9 = RoomFixture.room("아침 - 아홉 번째 방", RoomType.MORNING, 4); + Room room10 = RoomFixture.room("밤 - 열 번째 방", RoomType.NIGHT, 1, "97979"); + Room room11 = RoomFixture.room("밤 - 열하나 번째 방", RoomType.NIGHT, 22); + Room room12 = RoomFixture.room("아침 - 열둘 번째 방", RoomType.MORNING, 10); + Room room13 = RoomFixture.room("밤 - 열셋 번째 방", RoomType.NIGHT, 2); + Room room14 = RoomFixture.room("밤 - 열넷 번째 방", RoomType.NIGHT, 21); + + Routine routine1 = RoomFixture.routine(room1, "방1의 루틴1"); + Routine routine2 = RoomFixture.routine(room1, "방1의 루틴2"); + + Routine routine3 = RoomFixture.routine(room2, "방2의 루틴1"); + Routine routine4 = RoomFixture.routine(room2, "방2의 루틴2"); + + Routine routine5 = RoomFixture.routine(room3, "방3의 루틴1"); + Routine routine6 = RoomFixture.routine(room3, "방3의 루틴2"); + + Routine routine7 = RoomFixture.routine(room4, "방4의 루틴1"); + Routine routine8 = RoomFixture.routine(room4, "방4의 루틴2"); + + Routine routine9 = RoomFixture.routine(room5, "방5의 루틴1"); + Routine routine10 = RoomFixture.routine(room5, "방5의 루틴2"); + + Routine routine11 = RoomFixture.routine(room6, "방6의 루틴1"); + Routine routine12 = RoomFixture.routine(room6, "방6의 루틴2"); + + Routine routine13 = RoomFixture.routine(room7, "방7의 루틴1"); + Routine routine14 = RoomFixture.routine(room7, "방7의 루틴2"); + + Routine routine15 = RoomFixture.routine(room8, "방8의 루틴1"); + Routine routine16 = RoomFixture.routine(room8, "방8의 루틴2"); + + Routine routine17 = RoomFixture.routine(room9, "방9의 루틴1"); + Routine routine18 = RoomFixture.routine(room9, "방9의 루틴2"); + + Routine routine19 = RoomFixture.routine(room10, "방10의 루틴1"); + Routine routine20 = RoomFixture.routine(room10, "방10의 루틴2"); + + Routine routine21 = RoomFixture.routine(room11, "방11의 루틴1"); + Routine routine22 = RoomFixture.routine(room11, "방11의 루틴2"); + + Routine routine23 = RoomFixture.routine(room12, "방12의 루틴1"); + Routine routine24 = RoomFixture.routine(room12, "방12의 루틴2"); + + Routine routine25 = RoomFixture.routine(room13, "방13의 루틴1"); + Routine routine26 = RoomFixture.routine(room13, "방13의 루틴2"); + + Routine routine27 = RoomFixture.routine(room14, "방14의 루틴1"); + Routine routine28 = RoomFixture.routine(room14, "방14의 루틴2"); + + roomRepository.saveAll( + List.of(room1, room2, room3, room4, room5, room6, room7, room8, room9, room10, room11, room12, room13, + room14)); + + routineRepository.saveAll( + List.of(routine1, routine2, routine3, routine4, routine5, routine6, routine7, routine8, routine9, routine10, + routine11, routine12, routine13, routine14, routine15, routine16, routine17, routine18, routine19, + routine20, routine21, routine22, routine23, routine24, routine25, routine26, routine27, routine28)); + + // expected + mockMvc.perform(get("/rooms/search?keyword=번째&roomType=MORNING")) + .andExpect(status().isOk()) + .andDo(print()); + } + + @DisplayName("방 검색 조회 성공 - 키워드 + 방 타입 + 추가 페이지 존재X") + @WithMember(id = 1L) + @Test + void search_first_page_all_rooms_by_keyword_roomType_roomId_success() throws Exception { + // given + Room room1 = RoomFixture.room("밤 - 첫 번째 방", RoomType.NIGHT, 1, "1234"); + Room room2 = RoomFixture.room("밤 - 두 번째 방", RoomType.NIGHT, 1); + Room room3 = RoomFixture.room("밤 - 세 번째 방", RoomType.NIGHT, 22); + Room room4 = RoomFixture.room("아침 - 네 번째 방", RoomType.MORNING, 7); + Room room5 = RoomFixture.room("밤 - 다섯 번째 방", RoomType.NIGHT, 23, "5869"); + Room room6 = RoomFixture.room("아침 - 여섯 번째 방", RoomType.MORNING, 8); + Room room7 = RoomFixture.room("밤 - 일곱 번째 방", RoomType.NIGHT, 20); + Room room8 = RoomFixture.room("밤 - 여덟 번째 방", RoomType.NIGHT, 1, "5236"); + Room room9 = RoomFixture.room("밤 - 아홉 번째 방", RoomType.NIGHT, 1, "5236"); + Room room10 = RoomFixture.room("밤 - 열 번째 방", RoomType.NIGHT, 1, "97979"); + Room room11 = RoomFixture.room("밤 - 열하나 번째 방", RoomType.NIGHT, 22); + Room room12 = RoomFixture.room("밤 - 열둘 번째 방", RoomType.NIGHT, 1); + Room room13 = RoomFixture.room("밤 - 열셋 번째 방", RoomType.NIGHT, 2); + Room room14 = RoomFixture.room("밤 - 열넷 번째 방", RoomType.NIGHT, 21); + + Routine routine1 = RoomFixture.routine(room1, "방1의 루틴1"); + Routine routine2 = RoomFixture.routine(room1, "방1의 루틴2"); + + Routine routine3 = RoomFixture.routine(room2, "방2의 루틴1"); + Routine routine4 = RoomFixture.routine(room2, "방2의 루틴2"); + + Routine routine5 = RoomFixture.routine(room3, "방3의 루틴1"); + Routine routine6 = RoomFixture.routine(room3, "방3의 루틴2"); + + Routine routine7 = RoomFixture.routine(room4, "방4의 루틴1"); + Routine routine8 = RoomFixture.routine(room4, "방4의 루틴2"); + + Routine routine9 = RoomFixture.routine(room5, "방5의 루틴1"); + Routine routine10 = RoomFixture.routine(room5, "방5의 루틴2"); + + Routine routine11 = RoomFixture.routine(room6, "방6의 루틴1"); + Routine routine12 = RoomFixture.routine(room6, "방6의 루틴2"); + + Routine routine13 = RoomFixture.routine(room7, "방7의 루틴1"); + Routine routine14 = RoomFixture.routine(room7, "방7의 루틴2"); + + Routine routine15 = RoomFixture.routine(room8, "방8의 루틴1"); + Routine routine16 = RoomFixture.routine(room8, "방8의 루틴2"); + + Routine routine17 = RoomFixture.routine(room9, "방9의 루틴1"); + Routine routine18 = RoomFixture.routine(room9, "방9의 루틴2"); + + Routine routine19 = RoomFixture.routine(room10, "방10의 루틴1"); + Routine routine20 = RoomFixture.routine(room10, "방10의 루틴2"); + + Routine routine21 = RoomFixture.routine(room11, "방11의 루틴1"); + Routine routine22 = RoomFixture.routine(room11, "방11의 루틴2"); + + Routine routine23 = RoomFixture.routine(room12, "방12의 루틴1"); + Routine routine24 = RoomFixture.routine(room12, "방12의 루틴2"); + + Routine routine25 = RoomFixture.routine(room13, "방13의 루틴1"); + Routine routine26 = RoomFixture.routine(room13, "방13의 루틴2"); + + Routine routine27 = RoomFixture.routine(room14, "방14의 루틴1"); + Routine routine28 = RoomFixture.routine(room14, "방14의 루틴2"); + + roomRepository.saveAll( + List.of(room1, room2, room3, room4, room5, room6, room7, room8, room9, room10, room11, room12, room13, + room14)); + + routineRepository.saveAll( + List.of(routine1, routine2, routine3, routine4, routine5, routine6, routine7, routine8, routine9, routine10, + routine11, routine12, routine13, routine14, routine15, routine16, routine17, routine18, routine19, + routine20, routine21, routine22, routine23, routine24, routine25, routine26, routine27, routine28)); + + // expected + mockMvc.perform(get("/rooms/search?keyword=루틴&roomType=NIGHT&roomId=3")) .andExpect(status().isOk()) .andDo(print()); }