99import com .somemore .domains .recruitboard .dto .request .RecruitBoardUpdateRequestDto ;
1010import com .somemore .domains .recruitboard .repository .RecruitBoardJpaRepository ;
1111import com .somemore .domains .recruitboard .repository .RecruitBoardRepository ;
12- import com .somemore .global .exception .BadRequestException ;
1312import com .somemore .support .IntegrationTestSupport ;
14- import org .assertj .core .api .Assertions ;
15- import org .junit .jupiter .api .AfterEach ;
1613import org .junit .jupiter .api .BeforeEach ;
1714import org .junit .jupiter .api .DisplayName ;
1815import org .junit .jupiter .api .Test ;
1916import org .springframework .beans .factory .annotation .Autowired ;
17+ import org .springframework .transaction .annotation .Transactional ;
2018
2119import java .math .BigDecimal ;
2220import java .time .LocalDateTime ;
2725import static com .somemore .support .fixture .LocalDateTimeFixture .*;
2826import static org .assertj .core .api .Assertions .assertThat ;
2927
28+ @ Transactional
3029class UpdateRecruitBoardServiceTest extends IntegrationTestSupport {
3130
3231 @ Autowired
@@ -53,12 +52,6 @@ void setUp() {
5352 recruitBoardJpaRepository .saveAndFlush (recruitBoard );
5453 }
5554
56- @ AfterEach
57- void tearDown () {
58- recruitBoardJpaRepository .deleteAllInBatch ();
59- locationRepository .deleteAllInBatch ();
60- }
61-
6255 @ DisplayName ("봉사 모집글의 데이터를 업데이트하면 저장소에 반영된다." )
6356 @ Test
6457 void updateRecruitBoard () {
@@ -79,8 +72,7 @@ void updateRecruitBoard() {
7972 .build ();
8073
8174 // when
82- updateRecruitBoardService .updateRecruitBoard (dto , recruitBoard .getId (), centerId ,
83- newImgUrl );
75+ updateRecruitBoardService .updateRecruitBoard (dto , recruitBoard .getId (), centerId , newImgUrl );
8476
8577 // then
8678 RecruitBoard updatedRecruitBoard = recruitBoardRepository .findById (recruitBoard .getId ())
@@ -129,33 +121,6 @@ void updateRecruitBoardLocation() {
129121 .isEqualByComparingTo (dto .latitude ());
130122 }
131123
132- @ DisplayName ("봉사 모집글은 작성자만 수정할 수 있다" )
133- @ Test
134- void updateRecruitBoardWhenCenterIdIsWrong () {
135- // given
136- Long id = recruitBoard .getId ();
137- UUID wrongCenterId = UUID .randomUUID ();
138- LocalDateTime newStartDateTime = createUpdateStartDateTime ();
139- LocalDateTime newEndDateTime = newStartDateTime .plusHours (3 );
140- String newImgUrl = "https://image.domain.com/updates" ;
141- RecruitBoardUpdateRequestDto dto = RecruitBoardUpdateRequestDto .builder ()
142- .title ("업데이트 제목" )
143- .content ("업데이트 내용" )
144- .recruitmentCount (1111 )
145- .volunteerStartDateTime (newStartDateTime )
146- .volunteerEndDateTime (newEndDateTime )
147- .volunteerCategory (ADMINISTRATIVE_SUPPORT )
148- .admitted (false )
149- .build ();
150-
151- // when
152- // then
153- Assertions .assertThatThrownBy (
154- () -> updateRecruitBoardService .updateRecruitBoard (dto , id , wrongCenterId , newImgUrl )
155- ).isInstanceOf (BadRequestException .class );
156-
157- }
158-
159124 @ DisplayName ("봉사 모집글 상태를 변경할 수 있다" )
160125 @ Test
161126 void updateRecruitBoardStatus () {
@@ -165,8 +130,7 @@ void updateRecruitBoardStatus() {
165130 LocalDateTime currentDateTime = createCurrentDateTime ();
166131
167132 // when
168- updateRecruitBoardService .updateRecruitBoardStatus (newStatus , recruitBoardId , centerId ,
169- currentDateTime );
133+ updateRecruitBoardService .updateRecruitBoardStatus (newStatus , recruitBoardId , centerId , currentDateTime );
170134
171135 // then
172136 RecruitBoard findBoard = recruitBoardRepository .findById (recruitBoardId ).orElseThrow ();
0 commit comments