@@ -19,9 +19,9 @@ class CommunityRepositoryTest extends IntegrationTestSupport {
1919 @ Autowired
2020 private CommunityBoardRepository communityBoardRepository ;
2121
22- @ DisplayName ("커뮤니티 id로 커뮤니티 상세 정보를 조회할 수 있다. (Repository)" )
22+ @ DisplayName ("커뮤니티 게시글 id로 커뮤니티 상세 정보를 조회할 수 있다. (Repository)" )
2323 @ Test
24- void findById () {
24+ void getCommunityBoardById () {
2525 //given
2626 CommunityBoard communityBoard = CommunityBoard .builder ()
2727 .title ("테스트 커뮤니티 게시글 제목" )
@@ -33,7 +33,7 @@ void findById() {
3333 communityBoardRepository .save (communityBoard );
3434
3535 //when
36- Optional <CommunityBoard > foundCommunityBoard = communityBoardRepository .findById (communityBoard .getId ());
36+ Optional <CommunityBoard > foundCommunityBoard = communityBoardRepository .getCommunityBoardWithId (communityBoard .getId ());
3737
3838 //then
3939 assertThat (foundCommunityBoard ).isNotNull ();
@@ -43,6 +43,27 @@ void findById() {
4343 assertThat (foundCommunityBoard .get ().getWriterId ()).isEqualTo (communityBoard .getWriterId ());
4444 }
4545
46+ @ DisplayName ("삭제된 커뮤니티 id로 커뮤니티 상세 정보를 조회할 때 예외를 반환할 수 있다. (Repository)" )
47+ @ Test
48+ void getCommunityBoardByDeletedId () {
49+ //given
50+ CommunityBoard communityBoard = CommunityBoard .builder ()
51+ .title ("테스트 커뮤니티 게시글 제목" )
52+ .content ("테스트 커뮤니티 게시글 내용" )
53+ .imgUrl ("http://community.example.com/123" )
54+ .writerId (UUID .randomUUID ())
55+ .build ();
56+
57+ communityBoardRepository .save (communityBoard );
58+ communityBoardRepository .deleteAllInBatch ();
59+
60+ //when
61+ Optional <CommunityBoard > foundCommunityBoard = communityBoardRepository .getCommunityBoardWithId (communityBoard .getId ());
62+
63+ //then
64+ assertThat (foundCommunityBoard ).isEmpty ();
65+ }
66+
4667 @ DisplayName ("저장된 전체 커뮤니티 게시글을 목록으로 조회할 수 있다. (Repository)" )
4768 @ Test
4869 void getCommunityBoards () {
0 commit comments