์• ์ •์ฝ”๋”ฉ ๐Ÿ’ป
article thumbnail

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