Skip to content

Commit c2bfb02

Browse files
committed
test(volunteer): sonar qube 이슈 해결 커버리지 테스트 추가
1 parent 36f8365 commit c2bfb02

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/test/java/com/somemore/volunteer/service/UpdateVolunteerLockServiceTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.somemore.volunteer.service;
22

33
import 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;
46
import static org.assertj.core.api.Assertions.assertThatThrownBy;
57
import static org.mockito.ArgumentMatchers.any;
68
import static org.mockito.ArgumentMatchers.anyLong;
79
import static org.mockito.BDDMockito.given;
810

11+
import com.somemore.global.exception.BadRequestException;
12+
import com.somemore.global.exception.ExceptionMessage;
913
import com.somemore.support.IntegrationTestSupport;
1014
import com.somemore.volunteer.domain.NEWVolunteer;
1115
import 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

Comments
 (0)