Skip to content

Commit

Permalink
test(volunteer-apply): 봉사 활동 지원 정산 기능 API 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
leebs0521 committed Dec 7, 2024
1 parent a6f50c6 commit 0a18b8f
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willDoNothing;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.somemore.ControllerTestSupport;
import com.somemore.WithMockCustomUser;
import com.somemore.facade.volunteerapply.SettleVolunteerApplyFacadeUseCase;
import com.somemore.volunteerapply.dto.request.VolunteerApplySettleRequestDto;
import com.somemore.volunteerapply.usecase.ApproveVolunteerApplyUseCase;
import com.somemore.volunteerapply.usecase.RejectVolunteerApplyUseCase;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand All @@ -28,6 +34,12 @@ class CenterVolunteerApplyCommandApiControllerTest extends ControllerTestSupport
@MockBean
private RejectVolunteerApplyUseCase rejectVolunteerApplyUseCase;

@MockBean
private SettleVolunteerApplyFacadeUseCase settleVolunteerApplyFacadeUseCase;

@Autowired
private ObjectMapper objectMapper;

@Test
@DisplayName("봉사 활동 지원 승인 성공 테스트")
@WithMockCustomUser(role = "CENTER")
Expand Down Expand Up @@ -65,4 +77,28 @@ void reject() throws Exception {
.andExpect(jsonPath("$.data").value(""))
.andExpect(jsonPath("$.message").value("봉사 활동 지원 거절 성공"));
}

@Test
@DisplayName("봉사 활동 지원 정산 성공 테스트")
@WithMockCustomUser(role = "CENTER")
void settle() throws Exception {
// given
VolunteerApplySettleRequestDto dto = VolunteerApplySettleRequestDto.builder()
.ids(List.of(1L, 2L, 3L))
.build();

willDoNothing().given(settleVolunteerApplyFacadeUseCase)
.settleVolunteerApplies(any(VolunteerApplySettleRequestDto.class), any(UUID.class));
// when
mockMvc.perform(post("/api/volunteer-applies/settle")
.content(objectMapper.writeValueAsBytes(dto))
.contentType(APPLICATION_JSON)
.header("Authorization", "Bearer access-token"))
// then
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.data").value(""))
.andExpect(jsonPath("$.message").value("봉사 활동 지원 정산 성공"));

}
}

0 comments on commit 0a18b8f

Please sign in to comment.