22
33import static org .mockito .ArgumentMatchers .any ;
44import static org .mockito .BDDMockito .willDoNothing ;
5+ import static org .springframework .http .MediaType .APPLICATION_JSON ;
56import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .patch ;
7+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
68import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .jsonPath ;
79import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
810
11+ import com .fasterxml .jackson .databind .ObjectMapper ;
912import com .somemore .ControllerTestSupport ;
1013import com .somemore .WithMockCustomUser ;
14+ import com .somemore .facade .volunteerapply .SettleVolunteerApplyFacadeUseCase ;
15+ import com .somemore .volunteerapply .dto .request .VolunteerApplySettleRequestDto ;
1116import com .somemore .volunteerapply .usecase .ApproveVolunteerApplyUseCase ;
1217import com .somemore .volunteerapply .usecase .RejectVolunteerApplyUseCase ;
18+ import java .util .List ;
1319import java .util .UUID ;
1420import org .junit .jupiter .api .DisplayName ;
1521import org .junit .jupiter .api .Test ;
@@ -28,6 +34,12 @@ class CenterVolunteerApplyCommandApiControllerTest extends ControllerTestSupport
2834 @ MockBean
2935 private RejectVolunteerApplyUseCase rejectVolunteerApplyUseCase ;
3036
37+ @ MockBean
38+ private SettleVolunteerApplyFacadeUseCase settleVolunteerApplyFacadeUseCase ;
39+
40+ @ Autowired
41+ private ObjectMapper objectMapper ;
42+
3143 @ Test
3244 @ DisplayName ("봉사 활동 지원 승인 성공 테스트" )
3345 @ WithMockCustomUser (role = "CENTER" )
@@ -65,4 +77,28 @@ void reject() throws Exception {
6577 .andExpect (jsonPath ("$.data" ).value ("" ))
6678 .andExpect (jsonPath ("$.message" ).value ("봉사 활동 지원 거절 성공" ));
6779 }
80+
81+ @ Test
82+ @ DisplayName ("봉사 활동 지원 정산 성공 테스트" )
83+ @ WithMockCustomUser (role = "CENTER" )
84+ void settle () throws Exception {
85+ // given
86+ VolunteerApplySettleRequestDto dto = VolunteerApplySettleRequestDto .builder ()
87+ .ids (List .of (1L , 2L , 3L ))
88+ .build ();
89+
90+ willDoNothing ().given (settleVolunteerApplyFacadeUseCase )
91+ .settleVolunteerApplies (any (VolunteerApplySettleRequestDto .class ), any (UUID .class ));
92+ // when
93+ mockMvc .perform (post ("/api/volunteer-applies/settle" )
94+ .content (objectMapper .writeValueAsBytes (dto ))
95+ .contentType (APPLICATION_JSON )
96+ .header ("Authorization" , "Bearer access-token" ))
97+ // then
98+ .andExpect (status ().isOk ())
99+ .andExpect (jsonPath ("$.code" ).value (200 ))
100+ .andExpect (jsonPath ("$.data" ).value ("" ))
101+ .andExpect (jsonPath ("$.message" ).value ("봉사 활동 지원 정산 성공" ));
102+
103+ }
68104}
0 commit comments