
겜프 수락 Junit Test
<작업계획>
더미데이터 추가 설정
Test 코드 작성
더미데이터 추가 설정
Follow 정보를 좀 더 설정했다.

Test 코드 작성
@WithUserDetails(value = "ssar", setupBefore = TestExecutionEvent.TEST_EXECUTION)
@Test
public void acceptGgamf_test() throws Exception {
// given
Long followId = 4L;
AcceptGgamfReqDto acceptGgamfReqDto = new AcceptGgamfReqDto();
acceptGgamfReqDto.setFollowId(followId);
String requestBody = om.writeValueAsString(acceptGgamfReqDto);
System.out.println("테스트 : " + requestBody);
// when
ResultActions resultActions = mvc
.perform(MockMvcRequestBuilders.put("/s/api/ggamf/accept/" + followId)
.content(requestBody).contentType(APPLICATION_JSON_UTF8));
String responseBody = resultActions.andReturn().getResponse().getContentAsString();
System.out.println("테스트 : " + responseBody);
// then
resultActions.andExpect(MockMvcResultMatchers.status().isCreated());
resultActions.andExpect(MockMvcResultMatchers.jsonPath("$.data.accept").value(true));
}
테스트 성공 :)


'Project > GameFriendApp' 카테고리의 다른 글
| Ggamf : 겜프 삭제 Junit Test (0) | 2022.12.08 |
|---|---|
| Ggamf : 겜프 삭제 (0) | 2022.12.08 |
| Ggamf : 겜프 수락 (0) | 2022.12.07 |
| Ggamf : 겜프 요청 Junit Test (0) | 2022.12.07 |
| Ggamf : 겜프 요청 (0) | 2022.12.07 |