diff --git a/async/pom.xml b/async/pom.xml index 4fa00cc09..aabb2146a 100644 --- a/async/pom.xml +++ b/async/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -34,7 +35,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final diff --git a/boot/src/main/java/com/example/demo/domain/model/Post.java b/boot/src/main/java/com/example/demo/domain/model/Post.java index c903632eb..94f3d091f 100644 --- a/boot/src/main/java/com/example/demo/domain/model/Post.java +++ b/boot/src/main/java/com/example/demo/domain/model/Post.java @@ -33,7 +33,7 @@ public class Post implements Serializable { @Column(name = "title") private String title; - @Column(name = "content") + @Column(name = "data") private String content; @CollectionTable(name = "post_labels", joinColumns = @JoinColumn(name = "post_id")) diff --git a/boot/src/main/java/com/example/demo/web/PaginatedResult.java b/boot/src/main/java/com/example/demo/web/PaginatedResult.java new file mode 100644 index 000000000..b1796cacd --- /dev/null +++ b/boot/src/main/java/com/example/demo/web/PaginatedResult.java @@ -0,0 +1,10 @@ +package com.example.demo.web; + +import java.util.List; + +public record PaginatedResult(List data, Long count ) { + + public static PaginatedResult of(List content, Long count) { + return new PaginatedResult<>(content, count); + } +} diff --git a/boot/src/main/java/com/example/demo/web/PostController.java b/boot/src/main/java/com/example/demo/web/PostController.java index 99071205b..a7062a1dc 100644 --- a/boot/src/main/java/com/example/demo/web/PostController.java +++ b/boot/src/main/java/com/example/demo/web/PostController.java @@ -7,7 +7,6 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.http.ResponseEntity; import org.springframework.util.StringUtils; @@ -28,14 +27,14 @@ public class PostController { private final PostRepository posts; @GetMapping(value = "", produces = APPLICATION_JSON_VALUE) - public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, + public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, @RequestParam(defaultValue = "") String status, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) { var postStatus = StringUtils.hasText(status) ? Status.valueOf(status) : null; var data = this.posts.findAll(Specifications.findByKeyword(q, postStatus), PageRequest.of(page, size)) .map(p -> new PostSummary(p.getTitle(), p.getCreatedAt())); - return ok(data); + return ok(PaginatedResult.of(data.getContent(), data.getTotalElements())); } @PostMapping(value = "", consumes = APPLICATION_JSON_VALUE) diff --git a/boot/src/main/java/com/example/demo/web/PostSummary.java b/boot/src/main/java/com/example/demo/web/PostSummary.java index 971266de2..c08f75cc0 100644 --- a/boot/src/main/java/com/example/demo/web/PostSummary.java +++ b/boot/src/main/java/com/example/demo/web/PostSummary.java @@ -1,5 +1,6 @@ package com.example.demo.web; +import java.io.Serializable; import java.time.LocalDateTime; public record PostSummary(String title, LocalDateTime createdAt) { diff --git a/boot/src/main/resources/application.properties b/boot/src/main/resources/application.properties index cf490c5fa..75dc179cc 100644 --- a/boot/src/main/resources/application.properties +++ b/boot/src/main/resources/application.properties @@ -10,7 +10,7 @@ spring.mvc.problemdetails.enabled=true # logging logging.level.root=INFO -logging.level.web=DEBUG +logging.level.web=TRACE logging.level.sql=TRACE logging.level.com.example.demo=DEBUG # SQL statements and parameters diff --git a/boot/src/test/java/com/example/demo/domain/PostRepositoryTest.java b/boot/src/test/java/com/example/demo/domain/PostRepositoryTest.java index 8b18ed1b9..934b77c18 100644 --- a/boot/src/test/java/com/example/demo/domain/PostRepositoryTest.java +++ b/boot/src/test/java/com/example/demo/domain/PostRepositoryTest.java @@ -47,7 +47,7 @@ public void setup() { @Test public void testSaveAll() { var data = List.of( - Post.builder().title("test").content("content").status(Status.PENDING_MODERATION).build(), + Post.builder().title("test").content("data").status(Status.PENDING_MODERATION).build(), Post.builder().title("test1").content("content1").build()); data.forEach(this.posts::save); @@ -65,7 +65,7 @@ public void testSaveAll() { public void testSaveAllAndFindAll_QueryDSL() { var data = List.of( - Post.builder().title("test").content("content").status(Status.PENDING_MODERATION).build(), + Post.builder().title("test").content("data").status(Status.PENDING_MODERATION).build(), Post.builder().title("test1").content("content1").build()); data.forEach(this.posts::save); @@ -81,7 +81,7 @@ public void testSaveAllAndFindAll_QueryDSL() { @Test public void testInsertAndQuery() { - var data = Post.builder().title("test").content("test content").status(Status.DRAFT).build(); + var data = Post.builder().title("test").content("test data").status(Status.DRAFT).build(); var saved = this.posts.save(data); this.posts.findById(saved.getId()).ifPresent( p -> { @@ -96,7 +96,7 @@ public void testInsertAndQuery() { @Test public void testInsertAndQuery_QueryDSL() { - var data = Post.builder().title("test").content("test content").status(Status.DRAFT).build(); + var data = Post.builder().title("test").content("test data").status(Status.DRAFT).build(); var saved = this.posts.save(data); this.posts.findOne(QPost.post.id.eq(saved.getId())).ifPresent( p -> assertThat(p.getStatus()).isEqualTo(Status.DRAFT) @@ -105,7 +105,7 @@ public void testInsertAndQuery_QueryDSL() { @Test public void testInsertAndQuery_QueryByExample() { - var data = Post.builder().title("test").content("test content").status(Status.DRAFT).build(); + var data = Post.builder().title("test").content("test data").status(Status.DRAFT).build(); var saved = this.posts.save(data); var probe = Post.builder().id(saved.getId()).build(); this.posts.findOne(Example.of(probe, ExampleMatcher.matching().withIgnorePaths("status"))).ifPresent( @@ -116,7 +116,7 @@ public void testInsertAndQuery_QueryByExample() { @Test public void testLabels() { var data = List.of( - Post.builder().title("test").content("content").labels(Set.of("java17", "spring6")).build(), + Post.builder().title("test").content("data").labels(Set.of("java17", "spring6")).build(), Post.builder().title("test1").content("content1").labels(Set.of("spring6")).build()); data.forEach(this.posts::save); diff --git a/boot/src/test/java/com/example/demo/domain/PostRepositoryTestWithTestcontainers.java b/boot/src/test/java/com/example/demo/domain/PostRepositoryTestWithTestcontainers.java index 15d35882a..f8958d84b 100644 --- a/boot/src/test/java/com/example/demo/domain/PostRepositoryTestWithTestcontainers.java +++ b/boot/src/test/java/com/example/demo/domain/PostRepositoryTestWithTestcontainers.java @@ -61,7 +61,7 @@ public void setup() { @Test public void testSaveAll() { var data = List.of( - Post.builder().title("test").content("content").status(Status.PENDING_MODERATION).build(), + Post.builder().title("test").content("data").status(Status.PENDING_MODERATION).build(), Post.builder().title("test1").content("content1").build()); this.posts.saveAllAndFlush(data); @@ -74,7 +74,7 @@ public void testSaveAll() { @Test public void testInsertAndQuery() { - var data = Post.builder().title("test").content("test content").status(Status.DRAFT).build(); + var data = Post.builder().title("test").content("test data").status(Status.DRAFT).build(); var saved = this.posts.save(data); this.posts.findById(saved.getId()).ifPresent( p -> assertThat(p.getStatus()).isEqualTo(Status.DRAFT) @@ -85,7 +85,7 @@ public void testInsertAndQuery() { @Test @Disabled public void testUpdateStatus() { - var data = Post.builder().title("test").content("test content").status(Status.DRAFT).build(); + var data = Post.builder().title("test").content("test data").status(Status.DRAFT).build(); var saved = this.posts.save(data); log.debug("saved post : {}", saved); diff --git a/boot/src/test/java/com/example/demo/web/PostControllerTest.java b/boot/src/test/java/com/example/demo/web/PostControllerTest.java index 274afe51f..83e0d5524 100644 --- a/boot/src/test/java/com/example/demo/web/PostControllerTest.java +++ b/boot/src/test/java/com/example/demo/web/PostControllerTest.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -17,7 +16,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.http.MediaType; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; import java.util.List; @@ -70,14 +68,14 @@ public void tetGetAllPosts() throws Exception { when(this.posts.findAll(isA(Specification.class), isA(Pageable.class))) .thenReturn(new PageImpl( List.of( - Post.builder().title("test").content("content of test1").build(), - Post.builder().title("test2").content("content of test2").build() + Post.builder().title("test").content("data of test1").build(), + Post.builder().title("test2").content("data of test2").build() ) ) ); this.rest.perform(get("/posts").accept(MediaType.APPLICATION_JSON)) - .andExpectAll(status().isOk(), jsonPath("$.totalElements", equalTo(2))); + .andExpectAll(status().isOk(), jsonPath("$.count", equalTo(2))); verify(this.posts, times(1)).findAll(isA(Specification.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); @@ -86,14 +84,14 @@ public void tetGetAllPosts() throws Exception { @Test public void testGetPostById() throws Exception { when(this.posts.findById(any(UUID.class))) - .thenReturn(Optional.of(Post.builder().title("test").content("content of test").build())); + .thenReturn(Optional.of(Post.builder().title("test").content("data of test").build())); var id = UUID.randomUUID(); this.rest.perform(get("/posts/{id}", id).accept(MediaType.APPLICATION_JSON)) .andExpectAll( status().isOk(), jsonPath("$.title", is("test")), - jsonPath("$.content", is("content of test")) + jsonPath("$.content", is("data of test")) ); verify(this.posts, times(1)).findById(id); @@ -117,9 +115,9 @@ public void testGetPostById_nonExisting() throws Exception { public void testCreatePost() throws Exception { var id = UUID.randomUUID(); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("test").content("content of test").build()); + .thenReturn(Post.builder().id(id).title("test").content("data of test").build()); - var data = new CreatePostCommand("test post", "content of test"); + var data = new CreatePostCommand("test post", "data of test"); this.rest.perform(post("/posts").content(objectMapper.writeValueAsBytes(data)).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()) .andExpect(header().exists("Location")) @@ -148,11 +146,11 @@ public void testCreatePost_validationFailed() throws Exception { public void testUpdatePost() throws Exception { var id = UUID.randomUUID(); when(this.posts.findById(any(UUID.class))) - .thenReturn(Optional.of(Post.builder().id(id).title("test").content("content of test").build())); + .thenReturn(Optional.of(Post.builder().id(id).title("test").content("data of test").build())); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("updated test").content("updated content of test").build()); + .thenReturn(Post.builder().id(id).title("updated test").content("updated data of test").build()); - var data = new UpdatePostCommand("updated test", "updated content of test", Status.PUBLISHED); + var data = new UpdatePostCommand("updated test", "updated data of test", Status.PUBLISHED); this.rest.perform(put("/posts/{id}", id).content(objectMapper.writeValueAsBytes(data)).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNoContent()); @@ -167,9 +165,9 @@ public void testUpdatePost_nonExisting() throws Exception { when(this.posts.findById(any(UUID.class))) .thenReturn(Optional.ofNullable(null)); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("updated test").content("updated content of test").build()); + .thenReturn(Post.builder().id(id).title("updated test").content("updated data of test").build()); - var data = new UpdatePostCommand("updated test", "updated content of test", Status.PUBLISHED); + var data = new UpdatePostCommand("updated test", "updated data of test", Status.PUBLISHED); this.rest.perform(put("/posts/{id}", id).content(objectMapper.writeValueAsBytes(data)).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); diff --git a/boot/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java b/boot/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java index 8cae51b0f..d9c36ef7a 100644 --- a/boot/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java +++ b/boot/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java @@ -45,8 +45,8 @@ public void getAllPostsWillBeOk() throws Exception { when(this.posts.findAll(isA(Specification.class), isA(Pageable.class))) .thenReturn(new PageImpl( List.of( - Post.builder().title("test").content("content of test1").build(), - Post.builder().title("test2").content("content of test2").build() + Post.builder().title("test").content("data of test1").build(), + Post.builder().title("test2").content("data of test2").build() ) ) ); @@ -56,7 +56,7 @@ public void getAllPostsWillBeOk() throws Exception { .uri("/posts") .exchange() .expectStatus().isOk() - .expectBody().jsonPath("$.totalElements").isEqualTo(2); + .expectBody().jsonPath("$.count").isEqualTo(2); verify(this.posts, times(1)).findAll(isA(Specification.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); diff --git a/boot/src/test/java/com/example/demo/web/PostControllerTestWithRestAssuredMockMvc.java b/boot/src/test/java/com/example/demo/web/PostControllerTestWithRestAssuredMockMvc.java index ac22ee8ae..b079e42d9 100644 --- a/boot/src/test/java/com/example/demo/web/PostControllerTestWithRestAssuredMockMvc.java +++ b/boot/src/test/java/com/example/demo/web/PostControllerTestWithRestAssuredMockMvc.java @@ -75,8 +75,8 @@ public void tetGetAllPosts() throws Exception { when(this.posts.findAll(isA(Specification.class), isA(Pageable.class))) .thenReturn(new PageImpl( List.of( - Post.builder().title("test").content("content of test1").build(), - Post.builder().title("test2").content("content of test2").build() + Post.builder().title("test").content("data of test1").build(), + Post.builder().title("test2").content("data of test2").build() ) ) ); @@ -88,7 +88,7 @@ public void tetGetAllPosts() throws Exception { .get("/posts") .then() .status(HttpStatus.OK) - .expect(jsonPath("$.totalElements", equalTo(2))); + .expect(jsonPath("$.count", equalTo(2))); //@formatter:on verify(this.posts, times(1)).findAll(isA(Specification.class), isA(Pageable.class)); @@ -98,7 +98,7 @@ public void tetGetAllPosts() throws Exception { @Test public void testGetPostById() throws Exception { when(this.posts.findById(any(UUID.class))) - .thenReturn(Optional.of(Post.builder().title("test").content("content of test").build())); + .thenReturn(Optional.of(Post.builder().title("test").content("data of test").build())); var id = UUID.randomUUID(); @@ -110,7 +110,7 @@ public void testGetPostById() throws Exception { .then() .status(HttpStatus.OK) .expect(jsonPath("$.title", is("test"))) - .expect(jsonPath("$.content", is("content of test"))); + .expect(jsonPath("$.content", is("data of test"))); //@formatter:on verify(this.posts, times(1)).findById(id); @@ -141,9 +141,9 @@ public void testGetPostById_nonExisting() throws Exception { public void testCreatePost() throws Exception { var id = UUID.randomUUID(); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("test").content("content of test").build()); + .thenReturn(Post.builder().id(id).title("test").content("data of test").build()); - var data = new CreatePostCommand("test post", "content of test"); + var data = new CreatePostCommand("test post", "data of test"); //@formatter:off given() @@ -189,11 +189,11 @@ public void testCreatePost_validationFailed() throws Exception { public void testUpdatePost() throws Exception { var id = UUID.randomUUID(); when(this.posts.findById(any(UUID.class))) - .thenReturn(Optional.of(Post.builder().id(id).title("test").content("content of test").build())); + .thenReturn(Optional.of(Post.builder().id(id).title("test").content("data of test").build())); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("updated test").content("updated content of test").build()); + .thenReturn(Post.builder().id(id).title("updated test").content("updated data of test").build()); - var data = new UpdatePostCommand("updated test", "updated content of test", Status.PUBLISHED); + var data = new UpdatePostCommand("updated test", "updated data of test", Status.PUBLISHED); //@formatter:off given() @@ -216,9 +216,9 @@ public void testUpdatePost_nonExisting() throws Exception { when(this.posts.findById(any(UUID.class))) .thenReturn(Optional.ofNullable(null)); when(this.posts.save(any(Post.class))) - .thenReturn(Post.builder().id(id).title("updated test").content("updated content of test").build()); + .thenReturn(Post.builder().id(id).title("updated test").content("updated data of test").build()); - var data = new UpdatePostCommand("updated test", "updated content of test", Status.PUBLISHED); + var data = new UpdatePostCommand("updated test", "updated data of test", Status.PUBLISHED); //@formatter:off given() diff --git a/cache/pom.xml b/cache/pom.xml index 6ccbc77f3..e6c78effb 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 diff --git a/cache/src/main/java/com/example/demo/PostRepository.java b/cache/src/main/java/com/example/demo/PostRepository.java index 2819b10c4..ab1dfd640 100644 --- a/cache/src/main/java/com/example/demo/PostRepository.java +++ b/cache/src/main/java/com/example/demo/PostRepository.java @@ -1,6 +1,7 @@ package com.example.demo; import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.repository.CrudRepository; @@ -9,7 +10,7 @@ public interface PostRepository extends CrudRepository { @Override - @Cacheable(value = "posts", key = "#p0") + @CachePut(value = "posts", key = "#p0") Optional findById(UUID id); @Override diff --git a/data-jdbc/pom.xml b/data-jdbc/pom.xml index 6bdcea3db..610aea365 100644 --- a/data-jdbc/pom.xml +++ b/data-jdbc/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -31,7 +32,7 @@ 10.1.13 - 11.0.15 + 11.0.16 true diff --git a/data-jpa/pom.xml b/data-jpa/pom.xml index 85ef9dea8..06b54d071 100644 --- a/data-jpa/pom.xml +++ b/data-jpa/pom.xml @@ -36,7 +36,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final diff --git a/data-jpa/src/main/java/com/example/demo/web/PaginatedResult.java b/data-jpa/src/main/java/com/example/demo/web/PaginatedResult.java new file mode 100644 index 000000000..10d83a770 --- /dev/null +++ b/data-jpa/src/main/java/com/example/demo/web/PaginatedResult.java @@ -0,0 +1,6 @@ +package com.example.demo.web; + +import java.util.List; + +public record PaginatedResult(List data, Long count) { +} diff --git a/data-jpa/src/main/java/com/example/demo/web/PostController.java b/data-jpa/src/main/java/com/example/demo/web/PostController.java index 99071205b..8b88cbffb 100644 --- a/data-jpa/src/main/java/com/example/demo/web/PostController.java +++ b/data-jpa/src/main/java/com/example/demo/web/PostController.java @@ -28,14 +28,14 @@ public class PostController { private final PostRepository posts; @GetMapping(value = "", produces = APPLICATION_JSON_VALUE) - public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, + public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, @RequestParam(defaultValue = "") String status, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) { var postStatus = StringUtils.hasText(status) ? Status.valueOf(status) : null; var data = this.posts.findAll(Specifications.findByKeyword(q, postStatus), PageRequest.of(page, size)) .map(p -> new PostSummary(p.getTitle(), p.getCreatedAt())); - return ok(data); + return ok(new PaginatedResult<>(data.getContent(), data.getTotalElements())); } @PostMapping(value = "", consumes = APPLICATION_JSON_VALUE) diff --git a/data-jpa/src/test/java/com/example/demo/web/PostControllerTest.java b/data-jpa/src/test/java/com/example/demo/web/PostControllerTest.java index db3c6d392..67f871104 100644 --- a/data-jpa/src/test/java/com/example/demo/web/PostControllerTest.java +++ b/data-jpa/src/test/java/com/example/demo/web/PostControllerTest.java @@ -87,7 +87,7 @@ public void tetGetAllPosts() throws Exception { ); this.rest.perform(get("/posts").accept(MediaType.APPLICATION_JSON)) - .andExpectAll(status().isOk(), jsonPath("$.totalElements", equalTo(2))); + .andExpectAll(status().isOk(), jsonPath("$.count", equalTo(2))); verify(this.posts, times(1)).findAll(isA(Specification.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); diff --git a/data-jpa/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java b/data-jpa/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java index 4e239747a..b1ad557f3 100644 --- a/data-jpa/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java +++ b/data-jpa/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java @@ -60,8 +60,8 @@ public void getAllPostsWillBeOk() throws Exception { .get() .uri("/posts") .exchange() - .expectStatus().isOk(); - // .expectBody().jsonPath("$.totalElements").isEqualTo(2); + .expectStatus().isOk() + .expectBody().jsonPath("$.count").isEqualTo(2); verify(this.posts, times(1)).findAll(isA(Specification.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); diff --git a/data-mongo/pom.xml b/data-mongo/pom.xml index b76fc3127..5f9e846e5 100644 --- a/data-mongo/pom.xml +++ b/data-mongo/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.11.0 @@ -36,7 +37,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final diff --git a/data-mongo/src/main/java/com/example/demo/web/PaginatedResult.java b/data-mongo/src/main/java/com/example/demo/web/PaginatedResult.java new file mode 100644 index 000000000..10d83a770 --- /dev/null +++ b/data-mongo/src/main/java/com/example/demo/web/PaginatedResult.java @@ -0,0 +1,6 @@ +package com.example.demo.web; + +import java.util.List; + +public record PaginatedResult(List data, Long count) { +} diff --git a/data-mongo/src/main/java/com/example/demo/web/PostController.java b/data-mongo/src/main/java/com/example/demo/web/PostController.java index cf49db4c4..69de5032a 100644 --- a/data-mongo/src/main/java/com/example/demo/web/PostController.java +++ b/data-mongo/src/main/java/com/example/demo/web/PostController.java @@ -26,14 +26,14 @@ public class PostController { private final PostRepository posts; @GetMapping(value = "", produces = APPLICATION_JSON_VALUE) - public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, + public ResponseEntity> getAll(@RequestParam(defaultValue = "") String q, @RequestParam(defaultValue = "") String status, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) { var postStatus = StringUtils.hasText(status) ? Status.valueOf(status) : null; var data = this.posts.findAll(Predicates.findByKeyword(q, postStatus), PageRequest.of(page, size)) .map(p -> new PostSummary(p.getTitle(), p.getCreatedAt())); - return ok(data); + return ok(new PaginatedResult(data.getContent(), data.getTotalElements())); } @PostMapping(value = "", consumes = APPLICATION_JSON_VALUE) diff --git a/data-mongo/src/test/java/com/example/demo/web/PostControllerTest.java b/data-mongo/src/test/java/com/example/demo/web/PostControllerTest.java index 9ee9c7266..cbf8bf7b7 100644 --- a/data-mongo/src/test/java/com/example/demo/web/PostControllerTest.java +++ b/data-mongo/src/test/java/com/example/demo/web/PostControllerTest.java @@ -75,7 +75,7 @@ public void tetGetAllPosts() throws Exception { ); this.rest.perform(get("/posts").accept(MediaType.APPLICATION_JSON)) - .andExpectAll(status().isOk(), jsonPath("$.totalElements", equalTo(2))); + .andExpectAll(status().isOk(), jsonPath("$.count", equalTo(2))); verify(this.posts, times(1)).findAll(isA(Predicate.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); diff --git a/data-mongo/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java b/data-mongo/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java index 062012ba2..6c8afe3ed 100644 --- a/data-mongo/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java +++ b/data-mongo/src/test/java/com/example/demo/web/PostControllerTestWithMockMvcWebTestClient.java @@ -58,7 +58,7 @@ public void getAllPostsWillBeOk() throws Exception { .uri("/posts") .exchange() .expectStatus().isOk() - .expectBody().jsonPath("$.totalElements").isEqualTo(2); + .expectBody().jsonPath("$.count").isEqualTo(2); verify(this.posts, times(1)).findAll(isA(Predicate.class), isA(Pageable.class)); verifyNoMoreInteractions(this.posts); diff --git a/events/pom.xml b/events/pom.xml index ac0969834..a6e160a3a 100644 --- a/events/pom.xml +++ b/events/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -34,7 +35,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final @@ -217,6 +218,11 @@ hibernate-validator 8.0.1.Final + + org.glassfish.expressly + expressly + 5.0.0 + diff --git a/hibernate/pom.xml b/hibernate/pom.xml index 00c855c6b..4d2a4cfef 100644 --- a/hibernate/pom.xml +++ b/hibernate/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -31,7 +32,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final diff --git a/jdbc-client/pom.xml b/jdbc-client/pom.xml index 54adb6aab..7052d81e6 100644 --- a/jdbc-client/pom.xml +++ b/jdbc-client/pom.xml @@ -29,7 +29,7 @@ 10.1.13 - 11.0.15 + 11.0.16 true diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 60f6b4443..5f203e8d7 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -29,7 +29,7 @@ 10.1.13 - 11.0.15 + 11.0.16 true diff --git a/jpa/pom.xml b/jpa/pom.xml index 2b9b7b91f..f92e0d485 100644 --- a/jpa/pom.xml +++ b/jpa/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -31,7 +32,7 @@ 10.1.13 - 11.0.15 + 11.0.16 29.0.1.Final diff --git a/mvc-freemarker/pom.xml b/mvc-freemarker/pom.xml index 03f81e4ba..759459a1c 100644 --- a/mvc-freemarker/pom.xml +++ b/mvc-freemarker/pom.xml @@ -14,6 +14,7 @@ UTF-8 UTF-8 17 + true 3.1.2 @@ -27,13 +28,13 @@ 42.6.0 2022.0.10 2023.1.0-M2 - 6.1.2 + 6.2.0-M2 10.1.13 - 11.0.15 + 11.0.16 true diff --git a/problem-details/pom.xml b/problem-details/pom.xml index 714c0e23d..abf95cc01 100644 --- a/problem-details/pom.xml +++ b/problem-details/pom.xml @@ -13,6 +13,7 @@ UTF-8 UTF-8 17 + true 3.1.2