Skip to content
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

[Refactor/#168] JSON Property Case 변경 (SNAKE_CASE -> LOWER_CAMEL_CASE) #169

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
@Configuration
public class WebConfig {

/**
* swagger-ui 에서 따로 snake_case 를 위한 설정을 제공하지 않음. camelCase 를 snake_case 로 변환하기 위한 resolver 등록
*/
@Bean
public ModelResolver modelResolver(ObjectMapper objectMapper) {
return new ModelResolver(objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE));
return new ModelResolver(objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MenuId implements Serializable {

private static final long serialVersionUID = -7661257651938513762L;

@JsonProperty("menu_id")
@JsonProperty("menuId")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void createApplicationTest() throws Exception {

mockMvc.perform(post("/budget/application")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"title\":\"서버 사용비\", \"date_used\":\"2000-01-01T00:00:00\", \"details\":\"aws 크롤링 비용\", \"outcome\":50000, \"accounts\":\"카카오 01-00022-13204 유동현\"}"))
.content("{\"title\":\"서버 사용비\", \"dateUsed\":\"2000-01-01T00:00:00\", \"details\":\"aws 크롤링 비용\", \"outcome\":50000, \"accounts\":\"카카오 01-00022-13204 유동현\"}"))
.andExpect(status().isNoContent());

//then
Expand All @@ -55,7 +55,7 @@ public void modifyApplicationTest() throws Exception {

mockMvc.perform(put("/budget/application")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"id\":1,\"title\":\"서버 사용비\", \"date_used\":\"2000-01-01T00:00:00\", \"details\":\"aws 크롤링 비용\", \"outcome\":50000, \"accounts\":\"카카오 01-00022-13204 유동현\", \"application_id\":1}"))
.content("{\"id\":1,\"title\":\"서버 사용비\", \"dateUsed\":\"2000-01-01T00:00:00\", \"details\":\"aws 크롤링 비용\", \"outcome\":50000, \"accounts\":\"카카오 01-00022-13204 유동현\", \"applicationId\":1}"))
.andExpect(status().isNoContent());

//then
Expand Down Expand Up @@ -105,7 +105,7 @@ public void changeApplicationStatusTest() throws Exception {

mockMvc.perform(put("/budget/application/1/status")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"status\":\"PROCESSED\", \"reject_reason\":\"\"}"))
.content("{\"status\":\"PROCESSED\", \"rejectReason\":\"\"}"))
.andExpect(status().isNoContent());

//then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BudgetHistoryControllerTest {
@Test
public void historyCreationFormTest() throws Exception {
//given
String jsonOfCreationForm = "{\"date_used\":\"2999-01-01T01:01:00\",\"title\":\" \",\"details\":\"aws 작년 비용\",\"person_received\":12171652,\"income\":-1,\"outcome\":-1}";
String jsonOfCreationForm = "{\"dateUsed\":\"2999-01-01T01:01:00\",\"title\":\" \",\"details\":\"aws 작년 비용\",\"personReceived\":12171652,\"income\":-1,\"outcome\":-1}";

//when
Exception resolvedException =
Expand Down Expand Up @@ -65,7 +65,7 @@ public void historyCreationFormTest() throws Exception {
@Test
public void budgetCreationFormWillPassValidationTest() throws Exception {
//given
String jsonOfCreationForm = "{\"date_used\":\"2000-01-01T01:01:00\",\"title\":\"서버 운영비\",\"details\":\"aws 작년 비용\",\"person_received\":12171652,\"income\":0,\"outcome\":500000}";
String jsonOfCreationForm = "{\"dateUsed\":\"2000-01-01T01:01:00\",\"title\":\"서버 운영비\",\"details\":\"aws 작년 비용\",\"personReceived\":12171652,\"income\":0,\"outcome\":500000}";

//when
mockMvc.perform(post("/budget/history")
Expand All @@ -80,7 +80,7 @@ public void budgetCreationFormWillPassValidationTest() throws Exception {
@Test
public void historyModificationFormTest() throws Exception {
//given
String jsonOfCreationForm = "{\"id\":1, \"date_used\":\"2999-01-01T01:01:00\",\"title\":\" \",\"details\":\"aws 작년 비용\",\"person_received\":12171652,\"income\":-1,\"outcome\":-1}";
String jsonOfCreationForm = "{\"id\":1, \"dateUsed\":\"2999-01-01T01:01:00\",\"title\":\" \",\"details\":\"aws 작년 비용\",\"personReceived\":12171652,\"income\":-1,\"outcome\":-1}";

//when
Exception resolvedException =
Expand Down Expand Up @@ -109,7 +109,7 @@ public void historyModificationFormTest() throws Exception {
@Test
public void budgetModificationFormWillPassValidationTest() throws Exception {
//given
String jsonOfModificationForm = "{\"id\":1,\"date_used\":\"2000-01-01T01:01:00\",\"title\":\"서버 운영비\",\"details\":\"aws 작년 비용\",\"person_received\":12171652,\"income\":0,\"outcome\":500000}";
String jsonOfModificationForm = "{\"id\":1,\"dateUsed\":\"2000-01-01T01:01:00\",\"title\":\"서버 운영비\",\"details\":\"aws 작년 비용\",\"personReceived\":12171652,\"income\":0,\"outcome\":500000}";

//when
mockMvc.perform(put("/budget/history")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void getCommentList() throws Exception {
@Test
void createNewComment() throws Exception {
//given
String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"board_id\":13}";
String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13}";
Integer newCommentId = 1;
given(commentService.create(any(), any())).willReturn(newCommentId);

Expand All @@ -100,7 +100,7 @@ void createNewComment() throws Exception {
@Test
void createNewReply() throws Exception {
//given
String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"board_id\":13, \"parent_comment_id\":1}";
String jsonRequest = "{\"writerId\":12171652,\"contents\":\"아싸 1등\",\"boardId\":13, \"parentCommentId\":1}";
Integer newReplyId = 2;
given(commentService.create(any(), any())).willReturn(newReplyId);

Expand Down Expand Up @@ -139,7 +139,7 @@ void tryToSaveTooLongContents() throws Exception {
@Test
void updateComment() throws Exception {
//given
String jsonRequest = "{\"comment_id\":1, \"writerId\":12171652,\"contents\":\"1등이 아니네,,,\",\"boardId\":12}";
String jsonRequest = "{\"commentId\":1, \"writerId\":12171652,\"contents\":\"1등이 아니네,,,\",\"boardId\":12}";
given(commentService.update(any(), any())).willReturn(1);

String responseBody = mockMvc.perform(put("/comment")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public void createLectureTest() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.content("{\n" +
" \"title\": \"절권도 강의\",\n" +
" \"apply_dead_line\": \"9022-07-31T16:51:33\",\n" +
" \"days_of_weeks\": \"월 수 금\",\n" +
" \"applyDeadLine\": \"9022-07-31T16:51:33\",\n" +
" \"daysOfWeeks\": \"월 수 금\",\n" +
" \"place\": \"6호관 623 강의실\",\n" +
" \"curriculum_details\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\",\n" +
" \"participants_limits\": 30,\n" +
" \"curriculumDetails\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\",\n" +
" \"participantsLimits\": 30,\n" +
" \"method\": 1,\n" +
" \"introduction\": \"호신술을 배워보자\"\n" +
"}"))
Expand All @@ -83,11 +83,11 @@ public void updateLectureTest() throws Exception {
.content("{\n" +
" \"id\": \"1\",\n" +
" \"title\": \"절권도 강의\",\n" +
" \"apply_dead_line\": \"9022-07-31T16:51:33\",\n" +
" \"days_of_weeks\": \"월 수 금\",\n" +
" \"applyDeadLine\": \"9022-07-31T16:51:33\",\n" +
" \"daysOfWeeks\": \"월 수 금\",\n" +
" \"place\": \"6호관 623 강의실\",\n" +
" \"curriculum_details\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\",\n" +
" \"participants_limits\": 30,\n" +
" \"curriculumDetails\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\",\n" +
" \"participantsLimits\": 30,\n" +
" \"method\": 1,\n" +
" \"introduction\": \"호신술을 배워보자\"\n" +
"}"))
Expand Down Expand Up @@ -154,7 +154,7 @@ public void getLectureDetailsTest() throws Exception {
" \"major\": \"산업경영공학과\"," +
" \"name\": \"유동현\"" +
" }," +
" \"co_instructors\": [" +
" \"coInstructors\": [" +
" {" +
" \"id\": 12345678," +
" \"major\": \"스마트모빌리티공학과\"," +
Expand All @@ -166,15 +166,15 @@ public void getLectureDetailsTest() throws Exception {
" \"name\": \"나까무라철수\"" +
" }" +
" ]," +
" \"apply_dead_line\": \"9022-07-31T17:11:36\"," +
" \"days_of_weeks\": \"월 금\"," +
" \"applyDeadLine\": \"9022-07-31T17:11:36\"," +
" \"daysOfWeeks\": \"월 금\"," +
" \"place\": \"구내식당\"," +
" \"introduction\": \"호신술을 배워보자\"," +
" \"curriculum_details\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\"," +
" \"participants_limits\": 30," +
" \"curriculumDetails\": \"1주차: 빅데이터에 기반한 공격패턴분석<br> 2주차: ...\"," +
" \"participantsLimits\": 30," +
" \"method\": 1," +
" \"state\": \"WAITING\"," +
" \"reject_reason\": null," +
" \"rejectReason\": null," +
" \"paid\": false," +
" \"created\": \"9022-07-23T17:11:36\"," +
" \"updated\": null" +
Expand Down Expand Up @@ -203,42 +203,42 @@ public void getLectureListTest() throws Exception {
//then
then(lectureService).should(times(1)).getList(any());
JSONAssert.assertEquals("{\n" +
" \"total_pages\": 1,\n" +
" \"total_elements\": 3,\n" +
" \"totalPages\": 1,\n" +
" \"totalElements\": 3,\n" +
" \"size\": 6,\n" +
" \"content\": [\n" +
" {\n" +
" \"lecture_id\": 3,\n" +
" \"lectureId\": 3,\n" +
" \"title\": \"title3\",\n" +
" \"chief_id\": 1000003,\n" +
" \"chiefId\": 1000003,\n" +
" \"introduction\": \"intro3\",\n" +
" \"apply_deadline\": \"2003-03-03T03:03:03\",\n" +
" \"applyDeadline\": \"2003-03-03T03:03:03\",\n" +
" \"status\": \"PROGRESSING\",\n" +
" \"method\": 1,\n" +
" \"participants_limits\": 32,\n" +
" \"the_number_of_current_participants\": 4\n" +
" \"participantsLimits\": 32,\n" +
" \"theNumberOfCurrentParticipants\": 4\n" +
" },\n" +
" {\n" +
" \"lecture_id\": 2,\n" +
" \"lectureId\": 2,\n" +
" \"title\": \"title2\",\n" +
" \"chief_id\": 1000002,\n" +
" \"chiefId\": 1000002,\n" +
" \"introduction\": \"intro2\",\n" +
" \"apply_deadline\": \"2002-02-02T02:02:02\",\n" +
" \"applyDeadline\": \"2002-02-02T02:02:02\",\n" +
" \"status\": \"PROGRESSING\",\n" +
" \"method\": 1,\n" +
" \"participants_limits\": 31,\n" +
" \"the_number_of_current_participants\": 3\n" +
" \"participantsLimits\": 31,\n" +
" \"theNumberOfCurrentParticipants\": 3\n" +
" },\n" +
" {\n" +
" \"lecture_id\": 1,\n" +
" \"lectureId\": 1,\n" +
" \"title\": \"title1\",\n" +
" \"chief_id\": 1000001,\n" +
" \"chiefId\": 1000001,\n" +
" \"introduction\": \"intro1\",\n" +
" \"apply_deadline\": \"2001-01-01T01:01:01\",\n" +
" \"applyDeadline\": \"2001-01-01T01:01:01\",\n" +
" \"status\": \"PROGRESSING\",\n" +
" \"method\": 1,\n" +
" \"participants_limits\": 30,\n" +
" \"the_number_of_current_participants\": 2\n" +
" \"participantsLimits\": 30,\n" +
" \"theNumberOfCurrentParticipants\": 2\n" +
" }\n" +
" ],\n" +
" \"number\": 0,\n" +
Expand All @@ -249,16 +249,16 @@ public void getLectureListTest() throws Exception {
" },\n" +
" \"first\": true,\n" +
" \"last\": true,\n" +
" \"number_of_elements\": 3,\n" +
" \"numberOfElements\": 3,\n" +
" \"pageable\": {\n" +
" \"offset\": 0,\n" +
" \"sort\": {\n" +
" \"empty\": false,\n" +
" \"sorted\": true,\n" +
" \"unsorted\": false\n" +
" },\n" +
" \"page_number\": 0,\n" +
" \"page_size\": 6,\n" +
" \"pageNumber\": 0,\n" +
" \"pageSize\": 6,\n" +
" \"paged\": true,\n" +
" \"unpaged\": false\n" +
" },\n" +
Expand All @@ -278,7 +278,7 @@ public void updateLectureStatusTest() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.content("{\n" +
" \"status\": \"PROGRESSING\",\n" +
" \"reject_reason\": null\n" +
" \"rejectReason\": null\n" +
"}"))
.andExpect(status().isNoContent());

Expand Down Expand Up @@ -380,17 +380,17 @@ public void searchStudentsInformation() throws Exception {
//then
then(studentService).should(times(1)).searchStudents(any(), any());
JSONAssert.assertEquals("{\n" +
" \"total_pages\": 3,\n" +
" \"total_elements\": 51,\n" +
" \"totalPages\": 3,\n" +
" \"totalElements\": 51,\n" +
" \"size\": 25,\n" +
" \"content\": [\n" +
" {\n" +
" \"name\": \"홍길동50\",\n" +
" \"member_id\": 1000050,\n" +
" \"memberId\": 1000050,\n" +
" \"phone\": \"010-0000-0000\",\n" +
" \"email\": \"[email protected]\",\n" +
" \"assignment_count\": 0,\n" +
" \"attendance_count\": 0,\n" +
" \"assignmentCount\": 0,\n" +
" \"attendanceCount\": 0,\n" +
" \"status\": \"PROGRESS\",\n" +
" \"sid\": 50\n" +
" }\n" +
Expand All @@ -403,16 +403,16 @@ public void searchStudentsInformation() throws Exception {
" },\n" +
" \"first\": false,\n" +
" \"last\": true,\n" +
" \"number_of_elements\": 1,\n" +
" \"numberOfElements\": 1,\n" +
" \"pageable\": {\n" +
" \"offset\": 50,\n" +
" \"sort\": {\n" +
" \"empty\": false,\n" +
" \"sorted\": true,\n" +
" \"unsorted\": false\n" +
" },\n" +
" \"page_number\": 2,\n" +
" \"page_size\": 25,\n" +
" \"pageNumber\": 2,\n" +
" \"pageSize\": 25,\n" +
" \"paged\": true,\n" +
" \"unpaged\": false\n" +
" },\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void getTotalMenuInfoTest() throws Exception {
mvc.perform(get("/menus"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string("[{\"id\":1,\"group_name\":\"IBAS\",\"menu_list\":[{\"menu_id\":6,\"priority\":1,\"name\":\"ë\u008F\u0099ì\u0095\u0084리 ì\u0086\u008Cê°\u009C\",\"type\":\"INTRODUCE\",\"description\":\"\"}]}]"))
.andExpect(content().string("[{\"id\":1,\"groupName\":\"IBAS\",\"menuList\":[{\"menuId\":6,\"priority\":1,\"name\":\"ë\u008F\u0099ì\u0095\u0084리 ì\u0086\u008Cê°\u009C\",\"type\":\"INTRODUCE\",\"description\":\"\"}]}]"))
.andReturn();

then(menuService).should(times(1)).getAllMenuInfo();
Expand All @@ -54,7 +54,7 @@ public void getMenuInfoByIdTest() throws Exception {
new MenuDto(new MenuId(6),1,"공지사항", MenuType.LIST, ""));

mvc.perform(get("/menu/6"))
.andExpect(content().string("{\"menu_id\":6,\"priority\":1,\"name\":\"ê³µì§\u0080ì\u0082¬í\u0095\u00AD\",\"type\":\"LIST\",\"description\":\"\"}"))
.andExpect(content().string("{\"menuId\":6,\"priority\":1,\"name\":\"ê³µì§\u0080ì\u0082¬í\u0095\u00AD\",\"type\":\"LIST\",\"description\":\"\"}"))
.andExpect(status().isOk())
.andReturn();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class WebConfigTest {
@Autowired
private ModelResolver modelResolver;

@DisplayName("swagger 명세로 변환하는 modelResolver 는 snake_case 를 따른다.")
@DisplayName("swagger 명세로 변환하는 modelResolver 는 LOWER_CAMEL_CASE 를 따른다.")
@Test
public void ModelResolverSnakeCaseTest() {
//when
Expand All @@ -28,6 +28,6 @@ public void ModelResolverSnakeCaseTest() {

//then
Assertions.assertThat(propertyNamingStrategy)
.isEqualTo(PropertyNamingStrategies.SNAKE_CASE);
.isEqualTo(PropertyNamingStrategies.LOWER_CAMEL_CASE);
}
}
2 changes: 1 addition & 1 deletion resource-server/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spring:
ansi:
enabled: always
jackson:
property-naming-strategy: SNAKE_CASE
property-naming-strategy: LOWER_CAMEL_CASE
data:
web:
pageable:
Expand Down
Loading