-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RestDocs 적용 #25
RestDocs 적용 #25
Conversation
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import hanglog.trip.presentation.dto.request.TripRequest; | ||
import hanglog.trip.restdocs.RestDocsConfiguration; | ||
import hanglog.trip.restdocs.RestDocsTest; | ||
import hanglog.trip.service.TripService; | ||
import java.time.LocalDate; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.data.jpa.mapping.JpaMetamodelMappingContext; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.restdocs.payload.JsonFieldType; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static hanglog.trip.restdocs.RestDocsConfiguration.field; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.springframework.http.HttpHeaders.LOCATION; | ||
import static org.springframework.http.MediaType.APPLICATION_JSON; | ||
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; | ||
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
teco-style이 적용되어 있지 않은 것 같아요.! option+cmd+L 로 정렬하면 static import가 최상단으로 와야 합니다..!
fieldWithPath("startDate").type(JsonFieldType.STRING).description("여행 시작 날짜").attributes(field("constraint", "yyyy-MM-dd")), | ||
fieldWithPath("endDate").type(JsonFieldType.STRING).description("여행 종료 날짜").attributes(field("constraint", "yyyy-MM-dd")), | ||
fieldWithPath("cityIds").type(JsonFieldType.ARRAY).description("도시 ID 목록").attributes(field("constraint", "1개 이상의 양의 정수")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fieldWithPath("startDate").type(JsonFieldType.STRING).description("여행 시작 날짜").attributes(field("constraint", "yyyy-MM-dd")), | |
fieldWithPath("endDate").type(JsonFieldType.STRING).description("여행 종료 날짜").attributes(field("constraint", "yyyy-MM-dd")), | |
fieldWithPath("cityIds").type(JsonFieldType.ARRAY).description("도시 ID 목록").attributes(field("constraint", "1개 이상의 양의 정수")) | |
requestFields( | |
fieldWithPath("startDate").type(JsonFieldType.STRING).description("여행 시작 날짜") | |
.attributes(field("constraint", "yyyy-MM-dd")), | |
fieldWithPath("endDate").type(JsonFieldType.STRING).description("여행 종료 날짜") | |
.attributes(field("constraint", "yyyy-MM-dd")), | |
fieldWithPath("cityIds").type(JsonFieldType.ARRAY).description("도시 ID 목록") | |
.attributes(field("constraint", "1개 이상의 양의 정수")) | |
), |
여기도 가로줄 제한을 넘겨서 정렬하면 이렇게 바뀌는데 type과 description도 줄바꿈 하는 방법도 좋아 보입니다.!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
적용하였습니다 :)
public static final Attribute field(final String key, final String value) { | ||
return new Attribute(key, value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Autowired | ||
protected RestDocumentationResultHandler restDocs; | ||
@Autowired | ||
protected MockMvc mockMvc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필드 사이에 띄우나요 안띄우나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
일반 필드 사이에는 띄우지 않고, 어노테이션이 붙은 필드는 띄우는 것으로 결정되었습니다 🔨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿굿굿 🏊♂️👍
📄 Summary
🙋🏻 More