22
33import static org .mockito .ArgumentMatchers .any ;
44import static org .mockito .BDDMockito .given ;
5+ import static org .mockito .BDDMockito .willDoNothing ;
56import static org .springframework .http .MediaType .APPLICATION_JSON ;
7+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .delete ;
68import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
79import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .jsonPath ;
810import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
1214import com .somemore .WithMockCustomUser ;
1315import com .somemore .volunteerapply .dto .VolunteerApplyCreateRequestDto ;
1416import com .somemore .volunteerapply .usecase .ApplyVolunteerApplyUseCase ;
17+ import com .somemore .volunteerapply .usecase .WithdrawVolunteerApplyUseCase ;
1518import java .util .UUID ;
1619import org .junit .jupiter .api .DisplayName ;
1720import 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