-
Notifications
You must be signed in to change notification settings - Fork 824
Fix 1324 page snake case support 4.3.x #1329
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,4 +188,71 @@ void serializeAndDeserializeFilledMultipleCascade() throws JsonProcessingExcepti | |
| assertThat(cascadedResult.getPageable().getPageNumber()).isEqualTo(6); | ||
| } | ||
|
|
||
| @Test | ||
| void deserializePageableWithHyphenatedAlias() { | ||
| // Given | ||
| File file = new File("./src/test/resources/withPageableAliasHyphen.json"); | ||
| // When | ||
| Page<?> result = objectMapper.readValue(file, Page.class); | ||
|
Comment on lines
+191
to
+196
|
||
| // Then | ||
| assertThat(result).isNotNull(); | ||
| assertThat(result.getTotalElements()).isEqualTo(15); | ||
| assertThat(result.getContent()).hasSize(10); | ||
| assertThat(result.getPageable()).isNotNull(); | ||
| assertThat(result.getPageable().getPageNumber()).isEqualTo(2); | ||
| assertThat(result.getPageable().getPageSize()).isEqualTo(3); | ||
| assertThat(result.getPageable().getSort().getOrderFor("firstName").getDirection()) | ||
| .isEqualTo(Sort.Direction.ASC); | ||
| } | ||
|
|
||
| @Test | ||
| void deserializePageableWithUnderscoreAlias() { | ||
| // Given | ||
| File file = new File("./src/test/resources/withPageableAliasUnderscore.json"); | ||
| // When | ||
| Page<?> result = objectMapper.readValue(file, Page.class); | ||
|
Comment on lines
+208
to
+213
|
||
| // Then | ||
|
Comment on lines
+209
to
+214
|
||
| assertThat(result).isNotNull(); | ||
| assertThat(result.getTotalElements()).isEqualTo(10); | ||
| assertThat(result.getContent()).hasSize(10); | ||
| assertThat(result.getPageable()).isNotNull(); | ||
| assertThat(result.getPageable().getPageNumber()).isEqualTo(1); | ||
| assertThat(result.getPageable().getPageSize()).isEqualTo(2); | ||
| assertThat(result.getPageable().getSort().getOrderFor("lastName").getDirection()) | ||
| .isEqualTo(Sort.Direction.DESC); | ||
| } | ||
|
|
||
| @Test | ||
| void deserializePageableWithLowercaseAlias() { | ||
| // Given | ||
| File file = new File("./src/test/resources/withPageableAliasLowercase.json"); | ||
| // When | ||
| Page<?> result = objectMapper.readValue(file, Page.class); | ||
|
Comment on lines
+225
to
+230
|
||
| // Then | ||
| assertThat(result).isNotNull(); | ||
| assertThat(result.getTotalElements()).isEqualTo(8); | ||
| assertThat(result.getContent()).hasSize(10); | ||
| assertThat(result.getPageable()).isNotNull(); | ||
| assertThat(result.getPageable().getPageNumber()).isEqualTo(0); | ||
| assertThat(result.getPageable().getPageSize()).isEqualTo(4); | ||
| assertThat(result.getPageable().getSort()).isEqualTo(Sort.unsorted()); | ||
| } | ||
|
|
||
| @Test | ||
| void deserializePageableWithPascalCaseAlias() { | ||
| // Given | ||
| File file = new File("./src/test/resources/withPageableAliasPascalCase.json"); | ||
| // When | ||
| Page<?> result = objectMapper.readValue(file, Page.class); | ||
|
Comment on lines
+241
to
+246
|
||
| // Then | ||
| assertThat(result).isNotNull(); | ||
| assertThat(result.getTotalElements()).isEqualTo(20); | ||
| assertThat(result.getContent()).hasSize(10); | ||
| assertThat(result.getPageable()).isNotNull(); | ||
| assertThat(result.getPageable().getPageNumber()).isEqualTo(3); | ||
| assertThat(result.getPageable().getPageSize()).isEqualTo(2); | ||
| assertThat(result.getPageable().getSort().getOrderFor("firstName").getDirection()) | ||
| .isEqualTo(Sort.Direction.ASC); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| { | ||
| "content": [ | ||
| { | ||
| "id": 3, | ||
| "lastName": "Williams", | ||
| "firstName": "Thomas", | ||
| "email": "w.t@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "lastName": "Smith", | ||
| "firstName": "James", | ||
| "email": "s.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "lastName": "Scott", | ||
| "firstName": "Steven", | ||
| "email": "s.s@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 8, | ||
| "lastName": "Rodriguez", | ||
| "firstName": "Daniel", | ||
| "email": "r.d@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "lastName": "Martinez", | ||
| "firstName": "Robert", | ||
| "email": "m.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "lastName": "Jones", | ||
| "firstName": "James", | ||
| "email": "j.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "lastName": "Johnson", | ||
| "firstName": "Robert", | ||
| "email": "j.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "lastName": "Garcia", | ||
| "firstName": "William", | ||
| "email": "g.w@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "lastName": "Davis", | ||
| "firstName": "Richard", | ||
| "email": "d.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "lastName": "Brown", | ||
| "firstName": "Paul", | ||
| "email": "b.p@my.domain.com" | ||
| } | ||
| ], | ||
| "pageable": { | ||
| "page-number": 2, | ||
| "page-size": 3, | ||
| "sort": { | ||
| "orders": [ | ||
| { | ||
| "direction": "ASC", | ||
| "property": "firstName" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "totalElements": 15 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| { | ||
| "content": [ | ||
| { | ||
| "id": 3, | ||
| "lastName": "Williams", | ||
| "firstName": "Thomas", | ||
| "email": "w.t@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "lastName": "Smith", | ||
| "firstName": "James", | ||
| "email": "s.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "lastName": "Scott", | ||
| "firstName": "Steven", | ||
| "email": "s.s@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 8, | ||
| "lastName": "Rodriguez", | ||
| "firstName": "Daniel", | ||
| "email": "r.d@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "lastName": "Martinez", | ||
| "firstName": "Robert", | ||
| "email": "m.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "lastName": "Jones", | ||
| "firstName": "James", | ||
| "email": "j.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "lastName": "Johnson", | ||
| "firstName": "Robert", | ||
| "email": "j.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "lastName": "Garcia", | ||
| "firstName": "William", | ||
| "email": "g.w@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "lastName": "Davis", | ||
| "firstName": "Richard", | ||
| "email": "d.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "lastName": "Brown", | ||
| "firstName": "Paul", | ||
| "email": "b.p@my.domain.com" | ||
| } | ||
| ], | ||
| "pageable": { | ||
| "pagenumber": 0, | ||
| "pagesize": 4, | ||
| "sort": { | ||
| "orders": [] | ||
| } | ||
| }, | ||
| "totalElements": 8 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| { | ||
| "content": [ | ||
| { | ||
| "id": 3, | ||
| "lastName": "Williams", | ||
| "firstName": "Thomas", | ||
| "email": "w.t@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "lastName": "Smith", | ||
| "firstName": "James", | ||
| "email": "s.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "lastName": "Scott", | ||
| "firstName": "Steven", | ||
| "email": "s.s@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 8, | ||
| "lastName": "Rodriguez", | ||
| "firstName": "Daniel", | ||
| "email": "r.d@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "lastName": "Martinez", | ||
| "firstName": "Robert", | ||
| "email": "m.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "lastName": "Jones", | ||
| "firstName": "James", | ||
| "email": "j.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "lastName": "Johnson", | ||
| "firstName": "Robert", | ||
| "email": "j.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "lastName": "Garcia", | ||
| "firstName": "William", | ||
| "email": "g.w@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "lastName": "Davis", | ||
| "firstName": "Richard", | ||
| "email": "d.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "lastName": "Brown", | ||
| "firstName": "Paul", | ||
| "email": "b.p@my.domain.com" | ||
| } | ||
| ], | ||
| "pageable": { | ||
| "PageNumber": 3, | ||
| "PageSize": 2, | ||
| "sort": { | ||
| "orders": [ | ||
| { | ||
| "direction": "ASC", | ||
| "property": "firstName" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "totalElements": 20 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| { | ||
| "content": [ | ||
| { | ||
| "id": 3, | ||
| "lastName": "Williams", | ||
| "firstName": "Thomas", | ||
| "email": "w.t@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "lastName": "Smith", | ||
| "firstName": "James", | ||
| "email": "s.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "lastName": "Scott", | ||
| "firstName": "Steven", | ||
| "email": "s.s@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 8, | ||
| "lastName": "Rodriguez", | ||
| "firstName": "Daniel", | ||
| "email": "r.d@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "lastName": "Martinez", | ||
| "firstName": "Robert", | ||
| "email": "m.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "lastName": "Jones", | ||
| "firstName": "James", | ||
| "email": "j.j@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "lastName": "Johnson", | ||
| "firstName": "Robert", | ||
| "email": "j.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "lastName": "Garcia", | ||
| "firstName": "William", | ||
| "email": "g.w@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "lastName": "Davis", | ||
| "firstName": "Richard", | ||
| "email": "d.r@my.domain.com" | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "lastName": "Brown", | ||
| "firstName": "Paul", | ||
| "email": "b.p@my.domain.com" | ||
| } | ||
| ], | ||
| "pageable": { | ||
| "page_number": 1, | ||
| "page_size": 2, | ||
| "sort": { | ||
| "orders": [ | ||
| { | ||
| "direction": "DESC", | ||
| "property": "lastName" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "totalElements": 10 | ||
| } |
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.
Minor formatting: these
@JsonAliasarray initializers omit the spaces used elsewhere in this file (e.g.,@JsonAlias({ "total-elements", ... })). Consider formatting consistently to avoid style/linter churn.