11package com .somemore .community .repository ;
22
33import com .somemore .IntegrationTestSupport ;
4+ import com .somemore .community .domain .CommunityBoard ;
45import com .somemore .community .domain .CommunityComment ;
6+ import com .somemore .community .dto .request .CommunityBoardCreateRequestDto ;
7+ import com .somemore .community .repository .board .CommunityBoardRepository ;
58import com .somemore .community .repository .comment .CommunityCommentRepository ;
9+ import org .junit .jupiter .api .BeforeEach ;
610import org .junit .jupiter .api .DisplayName ;
711import org .junit .jupiter .api .Test ;
812import org .springframework .beans .factory .annotation .Autowired ;
1721class CommunityCommentRepositoryTest extends IntegrationTestSupport {
1822 @ Autowired
1923 CommunityCommentRepository communityCommentRepository ;
24+ @ Autowired
25+ CommunityBoardRepository communityBoardRepository ;
26+
27+ private Long boardId ;
28+
29+ @ BeforeEach
30+ void setUp () {
31+ CommunityBoard communityBoard = CommunityBoard .builder ()
32+ .title ("테스트 커뮤니티 게시글 제목" )
33+ .content ("테스트 커뮤니티 게시글 내용" )
34+ .imgUrl ("http://community.example.com/123" )
35+ .writerId (UUID .randomUUID ())
36+ .build ();
37+
38+ communityBoardRepository .save (communityBoard );
39+
40+ boardId = communityBoard .getId ();
41+ }
2042
2143 @ DisplayName ("커뮤니티 게시글에 댓글을 생성할 수 있다. (Repository)" )
2244 @ Test
@@ -26,6 +48,7 @@ void createCommunityComment() {
2648 UUID writerId = UUID .randomUUID ();
2749
2850 CommunityComment communityComment = CommunityComment .builder ()
51+ .communityBoardId (boardId )
2952 .writerId (writerId )
3053 .content ("커뮤니티 댓글 테스트 내용" )
3154 .parentCommentId (null )
@@ -48,6 +71,7 @@ void createCommunityCommentReply() {
4871 UUID writerId = UUID .randomUUID ();
4972
5073 CommunityComment communityComment = CommunityComment .builder ()
74+ .communityBoardId (boardId )
5175 .writerId (writerId )
5276 .content ("커뮤니티 댓글 테스트 내용" )
5377 .parentCommentId (1L )
@@ -70,6 +94,7 @@ void findCommunityCommentById() {
7094 UUID writerId = UUID .randomUUID ();
7195
7296 CommunityComment communityComment = CommunityComment .builder ()
97+ .communityBoardId (boardId )
7398 .writerId (writerId )
7499 .content ("커뮤니티 댓글 테스트 내용" )
75100 .parentCommentId (null )
@@ -95,6 +120,7 @@ void existsById() {
95120 UUID writerId = UUID .randomUUID ();
96121
97122 CommunityComment communityComment = CommunityComment .builder ()
123+ .communityBoardId (boardId )
98124 .writerId (writerId )
99125 .content ("커뮤니티 댓글 테스트 내용" )
100126 .parentCommentId (null )
0 commit comments