@@ -35,7 +35,7 @@ class CommunityCommentQueryServiceTest extends IntegrationTestSupport {
3535 @ Autowired
3636 private DeleteCommunityCommentUseCase deleteCommunityCommentUseCase ;
3737
38- private Long boardId , commentId , replyId ;
38+ private Long boardId , commentId , replyId , commentId2 ;
3939 UUID writerId ;
4040
4141 @ BeforeEach
@@ -53,7 +53,11 @@ void setUp() {
5353 communityCommentRepository .save (communityComment1 );
5454 commentId = communityComment1 .getId ();
5555
56- for (int i = 1 ; i <= 8 ; i ++) {
56+ CommunityComment communityComment2 = createCommunityComment (boardId , writerId );
57+ communityCommentRepository .save (communityComment2 );
58+ commentId2 = communityComment2 .getId ();
59+
60+ for (int i = 1 ; i <= 12 ; i ++) {
5761 String content = "제목" + i ;
5862 CommunityComment communityComment = createCommunityComment (content , boardId , writerId );
5963 communityCommentRepository .save (communityComment );
@@ -79,14 +83,15 @@ void getCommentsByCommunityBoardId() {
7983
8084 //then
8185 assertThat (comments ).isNotNull ();
82- assertThat (comments .getTotalElements ()).isEqualTo (10 );
86+ assertThat (comments .getTotalElements ()).isEqualTo (15 );
8387 assertThat (comments .getSize ()).isEqualTo (4 );
84- assertThat (comments .getNumber ()).isZero ( );
88+ assertThat (comments .getTotalPages ()).isEqualTo ( 4 );
8589 }
8690
87- @ DisplayName ("삭제된 댓글의 경우 조회할 수 없다." )
91+ @ DisplayName ("삭제된 대댓글의 경우 조회할 수 없다." )
8892 @ Test
89- void doesNotFind () {
93+ void doesNotFindReply () {
94+
9095 //given
9196 deleteCommunityCommentUseCase .deleteCommunityComment (writerId , replyId , boardId );
9297
@@ -95,9 +100,24 @@ void doesNotFind() {
95100
96101 //then
97102 assertThat (comments ).isNotNull ();
98- assertThat (comments .getTotalElements ()).isEqualTo (9 );
103+ assertThat (comments .getTotalElements ()).isEqualTo (14 );
104+ assertThat (comments .getSize ()).isEqualTo (4 );
105+ }
106+
107+ @ DisplayName ("대댓글이 없는 삭제된 댓글의 경우 조회할 수 없다." )
108+ @ Test
109+ void doesNotFindCommennt () {
110+
111+ //given
112+ deleteCommunityCommentUseCase .deleteCommunityComment (writerId , commentId2 , boardId );
113+
114+ //when
115+ Page <CommunityCommentResponseDto > comments = communityCommentQueryService .getCommunityCommentsByBoardId (boardId , 0 );
116+
117+ //then
118+ assertThat (comments ).isNotNull ();
119+ assertThat (comments .getTotalElements ()).isEqualTo (14 );
99120 assertThat (comments .getSize ()).isEqualTo (4 );
100- assertThat (comments .getNumber ()).isZero ();
101121 }
102122
103123 @ DisplayName ("대댓글이 있는 댓글의 경우 삭제된 댓글로 조회할 수 있다." )
@@ -106,13 +126,13 @@ void getCommentsByCommunityBoardIdWithDeletedComment() {
106126
107127 //given
108128 deleteCommunityCommentUseCase .deleteCommunityComment (writerId , commentId , boardId );
129+
109130 //when
110131 Page <CommunityCommentResponseDto > comments = communityCommentQueryService .getCommunityCommentsByBoardId (boardId , 0 );
111132
112133 //then
113134 assertThat (comments ).isNotNull ();
114- assertThat (comments .getTotalElements ()).isEqualTo (10 );
135+ assertThat (comments .getTotalElements ()).isEqualTo (15 );
115136 assertThat (comments .getSize ()).isEqualTo (4 );
116- assertThat (comments .getNumber ()).isZero ();
117137 }
118138}
0 commit comments