Skip to content

Commit d0511e9

Browse files
committed
test(volunteer-apply): 봉사 지원 철회 기능 API 테스트
1 parent b487880 commit d0511e9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/com/somemore/volunteerapply/controller/VolunteerApplyCommandApiControllerTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import static org.mockito.ArgumentMatchers.any;
44
import static org.mockito.BDDMockito.given;
5+
import static org.mockito.BDDMockito.willDoNothing;
56
import static org.springframework.http.MediaType.APPLICATION_JSON;
7+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
68
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
79
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
810
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -12,6 +14,7 @@
1214
import com.somemore.WithMockCustomUser;
1315
import com.somemore.volunteerapply.dto.VolunteerApplyCreateRequestDto;
1416
import com.somemore.volunteerapply.usecase.ApplyVolunteerApplyUseCase;
17+
import com.somemore.volunteerapply.usecase.WithdrawVolunteerApplyUseCase;
1518
import java.util.UUID;
1619
import org.junit.jupiter.api.DisplayName;
1720
import org.junit.jupiter.api.Test;
@@ -30,6 +33,9 @@ class VolunteerApplyCommandApiControllerTest extends ControllerTestSupport {
3033
@MockBean
3134
private ApplyVolunteerApplyUseCase applyVolunteerApplyUseCase;
3235

36+
@MockBean
37+
private WithdrawVolunteerApplyUseCase withdrawVolunteerApplyUseCase;
38+
3339
@Test
3440
@DisplayName("봉사 활동 지원 성공 테스트")
3541
@WithMockCustomUser
@@ -57,4 +63,24 @@ void apply() throws Exception {
5763
.andExpect(jsonPath("$.data").value(applyId))
5864
.andExpect(jsonPath("$.message").value("봉사 활동 지원 성공"));
5965
}
66+
67+
@Test
68+
@DisplayName("봉사 활동 철회 성공 테스트")
69+
@WithMockCustomUser
70+
void withdraw () throws Exception {
71+
// given
72+
Long id = 1L;
73+
74+
willDoNothing().given(withdrawVolunteerApplyUseCase)
75+
.withdraw(any(), any(UUID.class));
76+
77+
// when
78+
mockMvc.perform(delete("/api/volunteer-apply/{id}", id)
79+
.header("Authorization", "Bearer access-token"))
80+
// then
81+
.andExpect(status().isOk())
82+
.andExpect(jsonPath("$.code").value(200))
83+
.andExpect(jsonPath("$.data").value(""))
84+
.andExpect(jsonPath("$.message").value("봉사 활동 지원 철회 성공"));
85+
}
6086
}

0 commit comments

Comments
 (0)