-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#16] feat: user response json 내에 null값 들어가도록 변경
- rest docs 생성 시 null이 들어가는 것을 금지하므로 optional()을 통해 이를 허용
- Loading branch information
1 parent
e97bff4
commit b2b4397
Showing
2 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import static com.study.realworld.user.controller.ApiDocumentUtils.getDocumentRequest; | ||
import static com.study.realworld.user.controller.ApiDocumentUtils.getDocumentResponse; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
|
@@ -96,8 +97,8 @@ void joinTest() throws Exception { | |
|
||
.andExpect(jsonPath("$.user.username", is("username"))) | ||
.andExpect(jsonPath("$.user.email", is("[email protected]"))) | ||
.andExpect(jsonPath("$.user.bio", is("null"))) | ||
.andExpect(jsonPath("$.user.image", is("null"))) | ||
.andExpect(jsonPath("$.user.bio", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.image", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.token", is("token"))) | ||
.andDo(document("user-join", | ||
getDocumentRequest(), | ||
|
@@ -115,8 +116,10 @@ void joinTest() throws Exception { | |
fieldWithPath("user.email").type(JsonFieldType.STRING).description("이메일"), | ||
fieldWithPath("user.token").type(JsonFieldType.STRING).description("로그인 토큰"), | ||
fieldWithPath("user.username").type(JsonFieldType.STRING).description("유저이름"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio") | ||
.optional(), | ||
fieldWithPath("user.image").type(JsonFieldType.STRING).description("이미지") | ||
.optional() | ||
) | ||
)) | ||
; | ||
|
@@ -155,8 +158,8 @@ void loginTest() throws Exception { | |
|
||
.andExpect(jsonPath("$.user.username", is("username"))) | ||
.andExpect(jsonPath("$.user.email", is("[email protected]"))) | ||
.andExpect(jsonPath("$.user.bio", is("null"))) | ||
.andExpect(jsonPath("$.user.image", is("null"))) | ||
.andExpect(jsonPath("$.user.bio", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.image", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.token", is("token"))) | ||
.andDo(document("user-login", | ||
getDocumentRequest(), | ||
|
@@ -169,8 +172,10 @@ void loginTest() throws Exception { | |
fieldWithPath("user.email").type(JsonFieldType.STRING).description("이메일"), | ||
fieldWithPath("user.token").type(JsonFieldType.STRING).description("로그인 토큰"), | ||
fieldWithPath("user.username").type(JsonFieldType.STRING).description("유저이름"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio") | ||
.optional(), | ||
fieldWithPath("user.image").type(JsonFieldType.STRING).description("이미지") | ||
.optional() | ||
) | ||
)) | ||
; | ||
|
@@ -203,8 +208,8 @@ void getCurrentUserTest() throws Exception { | |
|
||
.andExpect(jsonPath("$.user.username", is("username"))) | ||
.andExpect(jsonPath("$.user.email", is("[email protected]"))) | ||
.andExpect(jsonPath("$.user.bio", is("null"))) | ||
.andExpect(jsonPath("$.user.image", is("null"))) | ||
.andExpect(jsonPath("$.user.bio", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.image", is(nullValue()))) | ||
.andExpect(jsonPath("$.user.token", is("token"))) | ||
.andDo(document("user-get-current", | ||
getDocumentRequest(), | ||
|
@@ -213,8 +218,10 @@ void getCurrentUserTest() throws Exception { | |
fieldWithPath("user.email").type(JsonFieldType.STRING).description("이메일"), | ||
fieldWithPath("user.token").type(JsonFieldType.STRING).description("로그인 토큰"), | ||
fieldWithPath("user.username").type(JsonFieldType.STRING).description("유저이름"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio") | ||
.optional(), | ||
fieldWithPath("user.image").type(JsonFieldType.STRING).description("이미지") | ||
.optional() | ||
) | ||
)) | ||
; | ||
|
@@ -276,8 +283,10 @@ void updateTest() throws Exception { | |
fieldWithPath("user.email").type(JsonFieldType.STRING).description("이메일"), | ||
fieldWithPath("user.token").type(JsonFieldType.STRING).description("로그인 토큰"), | ||
fieldWithPath("user.username").type(JsonFieldType.STRING).description("유저이름"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio"), | ||
fieldWithPath("user.bio").type(JsonFieldType.STRING).description("bio") | ||
.optional(), | ||
fieldWithPath("user.image").type(JsonFieldType.STRING).description("이미지") | ||
.optional() | ||
) | ||
)) | ||
; | ||
|