Skip to content

Commit b78814c

Browse files
committed
test(search): 커뮤니티 검색 테스트 추가 및 주석
1 parent 102b9e2 commit b78814c

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

src/test/java/com/somemore/community/repository/CommunityBoardDocumentRepositoryTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setUp() {
4343

4444
@DisplayName("검색 키워드가 포함된 게시글을 조회할 수 있다. (repository)")
4545
@Test
46-
void findByCommunityBoardsContaining() throws InterruptedException {
46+
void findByCommunityBoardsContaining() {
4747
//given
4848
Pageable pageable = getPageable();
4949

@@ -57,6 +57,22 @@ void findByCommunityBoardsContaining() throws InterruptedException {
5757
assertThat(findBoards.getTotalPages()).isEqualTo(1);
5858
}
5959

60+
// @DisplayName("키워드 없이 검색시 전체 게시글을 조회할 수 있다. (repository)")
61+
// @Test
62+
// void findByCommunityBoardsContainingWithNull() {
63+
// //given
64+
// Pageable pageable = getPageable();
65+
//
66+
// //when
67+
// Page<CommunityBoardView> findBoards = communityBoardRepository.findByCommunityBoardsContaining(null, pageable);
68+
//
69+
// //then
70+
// assertThat(findBoards).isNotNull();
71+
// assertThat(findBoards.getTotalElements()).isEqualTo(16);
72+
// assertThat(findBoards.getSize()).isEqualTo(10);
73+
// assertThat(findBoards.getTotalPages()).isEqualTo(2);
74+
// }
75+
6076
private Pageable getPageable() {
6177
return PageRequest.of(0, 10);
6278
}

src/test/java/com/somemore/community/service/board/CommunityBoardDocumentServiceTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,19 @@ void getCommunityBoardBySearch() {
6565
assertThat(dtos.getSize()).isEqualTo(10);
6666
assertThat(dtos.getTotalPages()).isEqualTo(1);
6767
}
68+
69+
// @DisplayName("검색 키워드 없이 조회시 전체 게시글을 조회한다. (service)")
70+
// @Test
71+
// void getCommunityBoardBySearchWithNull() {
72+
// //given
73+
// //when
74+
// Page<CommunityBoardResponseDto> dtos = communityBoardDocumentService.getCommunityBoardBySearch("", 0);
75+
//
76+
// //then
77+
// assertThat(dtos).isNotNull();
78+
// assertThat(dtos.getContent()).isNotNull();
79+
// assertThat(dtos.getTotalElements()).isEqualTo(15);
80+
// assertThat(dtos.getSize()).isEqualTo(10);
81+
// assertThat(dtos.getTotalPages()).isEqualTo(2);
82+
// }
6883
}

src/test/java/com/somemore/community/service/board/CommunityBoardQueryServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ void saveCommunityBoardDocuments() {
165165
communityBoardDocumentService.saveCommunityBoardDocuments(communityBoards);
166166

167167
//then
168-
Page<CommunityBoardResponseDto> dtos = communityBoardDocumentService.getCommunityBoardBySearch("저장", 0);
168+
Page<CommunityBoardResponseDto> dtos = communityBoardDocumentService.getCommunityBoardBySearch("", 0);
169169

170170
assertThat(dtos).isNotNull();
171171
assertThat(dtos.getContent()).isNotNull();
172-
assertThat(dtos.getTotalElements()).isEqualTo(1);
172+
assertThat(dtos.getTotalElements()).isEqualTo(15);
173173
assertThat(dtos.getSize()).isEqualTo(10);
174-
assertThat(dtos.getTotalPages()).isEqualTo(1);
174+
assertThat(dtos.getTotalPages()).isEqualTo(2);
175175

176176
communityBoardRepository.deleteDocument(savedBoard.getId());
177177
}

0 commit comments

Comments
 (0)