Test ๋์ค ์ด์ํ๊ฒ ResponseFileds๋ฅผ ๋ฐ์ง ๋ชปํ๋ ๋ฌธ์ ๊ฐ ์๋ค. ํน์๋ ํด์ postman์ผ๋ก ํ ์คํธ ํด๋ณด์๋๋ฐ ์๋์ ๊ฐ์ด ์๋์จ๋ค ...
ํ ์คํธ๋ ์ฑ๊ณตํ์ง๋ง responseFields ๊ฐ ์๋ค๋ฉฐ ๊ณ์ํด์ ์ค๋ฅ๋ฅผ ๋ฑ๋๋ค ... ใ ใ ๋ฌด์์ด ๋ฌธ์ ์ผ๊น
@Test
void loginUser() throws Exception {
final UserLoginRequest userLoginRequest =
UserLoginRequest.builder().socialToken("Asd823daz").pushToken("Wesdf0898dfa").build();
final UserLoginResponse userLoginResponse =
UserLoginResponse.builder().coupleToken("7E0U7W").socialToken("Asd823daz").build();
when(userFindService.loginUser(userLoginRequest)).thenReturn(userLoginResponse);
this.mockMvc
.perform(
post("/login")
.content(this.objectMapper.writeValueAsString(userLoginRequest))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(print())
.andDo(
document(
"user-login",
requestFields(
fieldWithPath("socialToken").description("์์
ํ ํฐ"),
fieldWithPath("pushToken").description("ํธ์ ํ ํฐ").optional()),
responseFields(
fieldWithPath("socialToken").description("์์
ํ ํฐ"),
fieldWithPath("coupleToken").description("์ปคํ ํ ํฐ"))));
}
* ํด๊ฒฐ๋๋ฉด ํด๊ฒฐ๋ฐฉ๋ฒ๊ณผ ๊ฐ์ด ๋ค์ ์์ ์์ ใ ใ
๋ฐ์ํ
'Project > DARLING' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
8. Service (0) | 2022.02.16 |
---|---|
7. CI/CD ๊ณํ (0) | 2022.02.09 |
5. Spring REST Docs ์ฌ์ฉ (0) | 2022.01.24 |
4. ์ฐ๊ด๊ด๊ณ - OneToMany (0) | 2022.01.23 |
3. ์ฐ๊ด๊ด๊ณ - ManyToOne (0) | 2022.01.23 |