Skip to content

Commit 1c993eb

Browse files
committed
test(volunteer-apply): 봉사 활동 지원 정산 기능 API 테스트
1 parent 58f496b commit 1c993eb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
import static org.mockito.ArgumentMatchers.any;
44
import static org.mockito.BDDMockito.willDoNothing;
5+
import static org.springframework.http.MediaType.APPLICATION_JSON;
56
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
7+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
68
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
79
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
810

11+
import com.fasterxml.jackson.databind.ObjectMapper;
912
import com.somemore.ControllerTestSupport;
1013
import com.somemore.WithMockCustomUser;
14+
import com.somemore.facade.volunteerapply.SettleVolunteerApplyFacadeUseCase;
15+
import com.somemore.volunteerapply.dto.request.VolunteerApplySettleRequestDto;
1116
import com.somemore.volunteerapply.usecase.ApproveVolunteerApplyUseCase;
1217
import com.somemore.volunteerapply.usecase.RejectVolunteerApplyUseCase;
18+
import java.util.List;
1319
import java.util.UUID;
1420
import org.junit.jupiter.api.DisplayName;
1521
import 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

Comments
 (0)