1212import com .somemore .global .exception .ExceptionMessage ;
1313import org .assertj .core .api .ThrowableAssert ;
1414import org .junit .jupiter .api .AfterEach ;
15+ import org .junit .jupiter .api .BeforeEach ;
1516import org .junit .jupiter .api .DisplayName ;
1617import org .junit .jupiter .api .Test ;
1718import org .springframework .beans .factory .annotation .Autowired ;
@@ -28,6 +29,23 @@ class DeleteCommunityBoardServiceTest extends IntegrationTestSupport {
2829 @ Autowired
2930 private CommunityBoardRepository communityBoardRepository ;
3031
32+ private UUID writerId ;
33+ private Long communityId ;
34+ private String imgUrl ;
35+
36+ @ BeforeEach
37+ void setUp () {
38+ CommunityBoardCreateRequestDto dto = CommunityBoardCreateRequestDto .builder ()
39+ .title ("커뮤니티 테스트 제목" )
40+ .content ("커뮤니티 테스트 내용" )
41+ .build ();
42+
43+ writerId = UUID .randomUUID ();
44+ imgUrl = "https://image.test.url/123" ;
45+
46+ communityId = createCommunityBoardUseCase .createCommunityBoard (dto , writerId , imgUrl );
47+ }
48+
3149 @ AfterEach
3250 void tearDown () {
3351 communityBoardRepository .deleteAllInBatch ();
@@ -37,16 +55,6 @@ void tearDown() {
3755 @ Test
3856 void deleteCommunityBoardWithId () {
3957 //given
40- CommunityBoardCreateRequestDto dto = CommunityBoardCreateRequestDto .builder ()
41- .title ("커뮤니티 테스트 제목" )
42- .content ("커뮤니티 테스트 내용" )
43- .build ();
44-
45- UUID writerId = UUID .randomUUID ();
46- String imgUrl = "https://image.test.url/123" ;
47-
48- Long communityId = createCommunityBoardUseCase .createCommunityBoard (dto , writerId , imgUrl );
49-
5058 //when
5159 deleteCommunityBoardService .deleteCommunityBoard (writerId , communityId );
5260
@@ -58,15 +66,6 @@ void deleteCommunityBoardWithId() {
5866 @ Test
5967 void deleteCommunityBoardWithDeletedId () {
6068 //given
61- CommunityBoardCreateRequestDto dto = CommunityBoardCreateRequestDto .builder ()
62- .title ("커뮤니티 테스트 제목" )
63- .content ("커뮤니티 테스트 내용" )
64- .build ();
65-
66- UUID writerId = UUID .randomUUID ();
67- String imgUrl = "https://image.test.url/123" ;
68-
69- Long communityId = createCommunityBoardUseCase .createCommunityBoard (dto , writerId , imgUrl );
7069 deleteCommunityBoardService .deleteCommunityBoard (writerId , communityId );
7170
7271 //when
@@ -82,16 +81,6 @@ void deleteCommunityBoardWithDeletedId() {
8281 @ Test
8382 void deleteCommunityBoardWithNotWriterId () {
8483 //given
85- CommunityBoardCreateRequestDto dto = CommunityBoardCreateRequestDto .builder ()
86- .title ("커뮤니티 테스트 제목" )
87- .content ("커뮤니티 테스트 내용" )
88- .build ();
89-
90- UUID writerId = UUID .randomUUID ();
91- String imgUrl = "https://image.test.url/123" ;
92-
93- Long communityId = createCommunityBoardUseCase .createCommunityBoard (dto , writerId , imgUrl );
94-
9584 //when
9685 ThrowableAssert .ThrowingCallable callable = () -> deleteCommunityBoardService .deleteCommunityBoard (UUID .randomUUID (), communityId );
9786
@@ -100,4 +89,4 @@ void deleteCommunityBoardWithNotWriterId() {
10089 .isThrownBy (callable )
10190 .withMessage (ExceptionMessage .UNAUTHORIZED_COMMUNITY_BOARD .getMessage ());
10291 }
103- }
92+ }
0 commit comments