11package com .somemore .volunteer .service ;
22
33import static org .assertj .core .api .Assertions .assertThat ;
4+ import static org .assertj .core .api .Assertions .assertThatCode ;
5+ import static org .assertj .core .api .Assertions .assertThatNoException ;
46import static org .assertj .core .api .Assertions .assertThatThrownBy ;
57import static org .mockito .ArgumentMatchers .any ;
68import static org .mockito .ArgumentMatchers .anyLong ;
79import static org .mockito .BDDMockito .given ;
810
11+ import com .somemore .global .exception .BadRequestException ;
12+ import com .somemore .global .exception .ExceptionMessage ;
913import com .somemore .support .IntegrationTestSupport ;
1014import com .somemore .volunteer .domain .NEWVolunteer ;
1115import com .somemore .volunteer .repository .NEWVolunteerJpaRepository ;
@@ -90,7 +94,7 @@ void updateVolunteerStatsWithConcurrency() throws InterruptedException {
9094
9195 @ DisplayName ("봉사활동 정보 업데이트 중 인터럽트 예외 발생" )
9296 @ Test
93- void UpdateVolunteerStats_InterruptedException () throws InterruptedException {
97+ void UpdateVolunteerStatsWhenInterruptedException () throws InterruptedException {
9498 // given
9599 UUID id = UUID .randomUUID ();
96100 int hours = 5 ;
@@ -106,6 +110,21 @@ void UpdateVolunteerStats_InterruptedException() throws InterruptedException {
106110
107111 }
108112
113+ @ DisplayName ("존재하지 않는 봉사자의 봉사활동을 업데이트하려는 경우 예외가 발생한다." )
114+ @ Test
115+ void UpdateVolunteerStatsWhenDoesNotExistsVolunteer () throws InterruptedException {
116+ // given
117+ UUID wrongVolunteerId = UUID .randomUUID ();
118+ int hours = 5 ;
119+
120+ // when
121+ // then
122+ assertThatThrownBy (
123+ () -> updateVolunteerLockService .updateVolunteerStats (wrongVolunteerId , hours ))
124+ .isInstanceOf (BadRequestException .class )
125+ .hasMessage (ExceptionMessage .NOT_EXISTS_VOLUNTEER .getMessage ());
126+ }
127+
109128 private static NEWVolunteer createVolunteer () {
110129 UUID userId = UUID .randomUUID ();
111130 return NEWVolunteer .createDefault (userId );
0 commit comments