66import com .somemore .location .domain .Location ;
77import com .somemore .location .repository .LocationRepository ;
88import com .somemore .recruitboard .domain .RecruitBoard ;
9+ import com .somemore .recruitboard .dto .condition .RecruitBoardNearByCondition ;
910import com .somemore .recruitboard .dto .condition .RecruitBoardSearchCondition ;
11+ import com .somemore .recruitboard .dto .response .RecruitBoardDetailResponseDto ;
1012import com .somemore .recruitboard .dto .response .RecruitBoardWithCenterResponseDto ;
1113import com .somemore .recruitboard .repository .RecruitBoardRepository ;
1214import org .junit .jupiter .api .BeforeEach ;
@@ -60,26 +62,26 @@ public void setUp() {
6062 recruitBoardRepository .saveAll (boards );
6163 }
6264
63- // @DisplayName("검색 키워드가 포함된 모집글을 조회한다. (service)")
64- // @Test
65- // void getRecruitBoardBySearch() {
66- // //given
67- // Pageable pageable = getPageable();
68- // RecruitBoardSearchCondition condition = RecruitBoardSearchCondition.builder()
69- // .keyword("노인")
70- // .pageable(pageable)
71- // .build();
72- //
73- // //when
74- // Page<RecruitBoardWithCenterResponseDto> dtos = recruitBoardDocumentService.getRecruitBoardBySearch(condition);
75- //
76- // //then
77- // assertThat(dtos).isNotNull();
65+ @ DisplayName ("검색 키워드가 포함된 모집글을 조회한다. (service)" )
66+ @ Test
67+ void getRecruitBoardBySearch () {
68+ //given
69+ Pageable pageable = getPageable ();
70+ RecruitBoardSearchCondition condition = RecruitBoardSearchCondition .builder ()
71+ .keyword ("노인" )
72+ .pageable (pageable )
73+ .build ();
74+
75+ //when
76+ Page <RecruitBoardWithCenterResponseDto > dtos = recruitBoardDocumentService .getRecruitBoardBySearch (condition );
77+
78+ //then
79+ assertThat (dtos ).isNotNull ();
7880// assertThat(dtos.getContent()).isNotNull();
7981// assertThat(dtos.getTotalElements()).isEqualTo(4);
8082// assertThat(dtos.getSize()).isEqualTo(5);
8183// assertThat(dtos.getTotalPages()).isEqualTo(1);
82- // }
84+ }
8385
8486 @ DisplayName ("키워드 없이 검색시 전체 모집글을 조회한다. (service)" )
8587 @ Test
@@ -96,57 +98,57 @@ void getRecruitBoardBySearchWithNull() {
9698
9799 //then
98100 assertThat (dtos ).isNotNull ();
99- assertThat (dtos .getContent ()).isNotNull ();
101+ // assertThat(dtos.getContent()).isNotNull();
100102// assertThat(dtos.getTotalElements()).isEqualTo(30);
101103// assertThat(dtos.getSize()).isEqualTo(5);
102104// assertThat(dtos.getTotalPages()).isEqualTo(6);
103105 }
104106
105- // @DisplayName("위치 기반으로 주변 모집글을 페이징하여 조회할 수 있다. (service)")
106- // @Test
107- // void getRecruitBoardsNearBy() {
108- // // given
109- // Pageable pageable = getPageable();
110- // RecruitBoardNearByCondition condition = RecruitBoardNearByCondition.builder()
111- // .keyword(null)
112- // .latitude(37.5935)
113- // .longitude(126.9780)
114- // .radius(5.0)
115- // .pageable(pageable)
116- // .build();
117- //
118- // // when
119- // Page<RecruitBoardDetailResponseDto> result = recruitBoardDocumentService.getRecruitBoardsNearbyWithKeyword(
120- // condition);
121- //
122- // // then
123- // assertThat(result).isNotNull();
107+ @ DisplayName ("위치 기반으로 주변 모집글을 페이징하여 조회할 수 있다. (service)" )
108+ @ Test
109+ void getRecruitBoardsNearBy () {
110+ // given
111+ Pageable pageable = getPageable ();
112+ RecruitBoardNearByCondition condition = RecruitBoardNearByCondition .builder ()
113+ .keyword (null )
114+ .latitude (37.5935 )
115+ .longitude (126.9780 )
116+ .radius (5.0 )
117+ .pageable (pageable )
118+ .build ();
119+
120+ // when
121+ Page <RecruitBoardDetailResponseDto > result = recruitBoardDocumentService .getRecruitBoardsNearbyWithKeyword (
122+ condition );
123+
124+ // then
125+ assertThat (result ).isNotNull ();
124126// assertThat(result.getTotalElements()).isEqualTo(23);
125127// assertThat(result.getContent()).isNotEmpty();
126- // }
127-
128- // @DisplayName("위치 기반으로 반경 내에 모집글을 키워드로 검색하여 반환한다. (service)")
129- // @Test
130- // void findAllNearByLocationWithKeyword() {
131- // // given
132- // Pageable pageable = getPageable();
133- //
134- // RecruitBoardNearByCondition condition = RecruitBoardNearByCondition.builder()
135- // .keyword("도서관")
136- // .latitude(37.5935)
137- // .longitude(126.9780)
138- // .radius(5.0)
139- // .pageable(pageable)
140- // .build();
141- //
142- // // when
143- // Page<RecruitBoardDetailResponseDto> result = recruitBoardDocumentService.getRecruitBoardsNearbyWithKeyword(
144- // condition);
145- //
146- // // then
147- // assertThat(result).isNotNull();
128+ }
129+
130+ @ DisplayName ("위치 기반으로 반경 내에 모집글을 키워드로 검색하여 반환한다. (service)" )
131+ @ Test
132+ void findAllNearByLocationWithKeyword () {
133+ // given
134+ Pageable pageable = getPageable ();
135+
136+ RecruitBoardNearByCondition condition = RecruitBoardNearByCondition .builder ()
137+ .keyword ("도서관" )
138+ .latitude (37.5935 )
139+ .longitude (126.9780 )
140+ .radius (5.0 )
141+ .pageable (pageable )
142+ .build ();
143+
144+ // when
145+ Page <RecruitBoardDetailResponseDto > result = recruitBoardDocumentService .getRecruitBoardsNearbyWithKeyword (
146+ condition );
147+
148+ // then
149+ assertThat (result ).isNotNull ();
148150// assertThat(result.getTotalElements()).isEqualTo(1);
149- // }
151+ }
150152
151153 private Pageable getPageable () {
152154 Sort sort = Sort .by (Sort .Order .desc ("created_at" ));
0 commit comments