Skip to content

Commit

Permalink
test: 이동봉사 신청 취소, 승인, 반려, 봉사 완료 Controller 테스트 코드 수정 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Nov 22, 2023
1 parent 8055f3a commit 34715ad
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,44 +135,50 @@ void setUp() {
void 이동봉사_신청_취소() throws Exception {
//given
Long applicationId = 1L;
ApplicationSuccessResponse response = new ApplicationSuccessResponse(true);

//when
given(applicationService.deleteApplication(anyString(), anyLong())).willReturn(response);
ResultActions result = mockMvc.perform(
delete("/volunteers/applications/{applicationId}", applicationId)
);

//then
result.andExpect(status().isNoContent());
result.andExpect(status().isOk());
verify(applicationService, times(1)).deleteApplication(anyString(), anyLong());
}

@Test
void 이동봉사_신청_승인() throws Exception {
//given
Long applicationId = 1L;
ApplicationSuccessResponse response = new ApplicationSuccessResponse(true);

//when
given(applicationService.confirmApplication(anyString(), anyLong())).willReturn(response);
ResultActions result = mockMvc.perform(
patch("/intermediaries/applications/{applicationId}", applicationId)
);

//then
result.andExpect(status().isNoContent());
result.andExpect(status().isOk());
verify(applicationService, times(1)).confirmApplication(anyString(), anyLong());
}

@Test
void 이동봉사_신청_반려() throws Exception {
//given
Long applicationId = 1L;
ApplicationSuccessResponse response = new ApplicationSuccessResponse(true);

//when
given(applicationService.cancelApplication(anyString(), anyLong())).willReturn(response);
ResultActions result = mockMvc.perform(
delete("/intermediaries/applications/{applicationId}", applicationId)
);

//then
result.andExpect(status().isNoContent());
result.andExpect(status().isOk());
verify(applicationService, times(1)).cancelApplication(anyString(), anyLong());
}

Expand Down Expand Up @@ -306,17 +312,19 @@ void setUp() {
}

@Test
void 이동봉사_완료() throws Exception {
void 이동봉사_완료하기() throws Exception {
//given
Long applicationId = 1L;
ApplicationSuccessResponse response = new ApplicationSuccessResponse(true);

//when
given(applicationService.completeApplication(anyString(), anyLong())).willReturn(response);
ResultActions result = mockMvc.perform(
patch("/intermediaries/applications/{applicationId}/completed", applicationId)
);

//then
result.andExpect(status().isNoContent());
result.andExpect(status().isOk());
verify(applicationService, times(1)).completeApplication(anyString(), anyLong());
}

Expand Down

0 comments on commit 34715ad

Please sign in to comment.