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

chore(deps): update dependency org.eclipse.jetty:jetty-home to v11.0.16 #422

Merged
merged 14 commits into from
Sep 11, 2023
3 changes: 2 additions & 1 deletion async/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.complier.parameters>true</maven.complier.parameters>

<!-- maven plugins -->
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
Expand All @@ -34,7 +35,7 @@
<tomcat.version>10.1.13</tomcat.version>

<!-- Eclipse Jetty -->
<jetty.version>11.0.15</jetty.version>
<jetty.version>11.0.16</jetty.version>

<!-- WildFly preview for Jakarta EE 10 -->
<wildfly.version>29.0.1.Final</wildfly.version>
Expand Down
2 changes: 1 addition & 1 deletion boot/src/main/java/com/example/demo/domain/model/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
10 changes: 10 additions & 0 deletions boot/src/main/java/com/example/demo/web/PaginatedResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.demo.web;

import java.util.List;

public record PaginatedResult<T>(List<T> data, Long count ) {

public static <E> PaginatedResult<E> of(List<E> content, Long count) {
return new PaginatedResult<>(content, count);
}
}
5 changes: 2 additions & 3 deletions boot/src/main/java/com/example/demo/web/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,14 +27,14 @@ public class PostController {
private final PostRepository posts;

@GetMapping(value = "", produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Page<PostSummary>> getAll(@RequestParam(defaultValue = "") String q,
public ResponseEntity<PaginatedResult<PostSummary>> 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)
Expand Down
1 change: 1 addition & 0 deletions boot/src/main/java/com/example/demo/web/PostSummary.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.demo.web;

import java.io.Serializable;
import java.time.LocalDateTime;

public record PostSummary(String title, LocalDateTime createdAt) {
Expand Down
2 changes: 1 addition & 1 deletion boot/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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 -> {
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand All @@ -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);

Expand Down
26 changes: 12 additions & 14 deletions boot/src/test/java/com/example/demo/web/PostControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -70,14 +68,14 @@ public void tetGetAllPosts() throws Exception {
when(this.posts.findAll(isA(Specification.class), isA(Pageable.class)))
.thenReturn(new PageImpl<Post>(
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);
Expand All @@ -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);
Expand All @@ -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"))
Expand Down Expand Up @@ -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());

Expand All @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void getAllPostsWillBeOk() throws Exception {
when(this.posts.findAll(isA(Specification.class), isA(Pageable.class)))
.thenReturn(new PageImpl<Post>(
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()
)
)
);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void tetGetAllPosts() throws Exception {
when(this.posts.findAll(isA(Specification.class), isA(Pageable.class)))
.thenReturn(new PageImpl<Post>(
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()
)
)
);
Expand All @@ -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));
Expand All @@ -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();

Expand All @@ -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);
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>

<!-- maven plugins -->
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
Expand Down
3 changes: 2 additions & 1 deletion cache/src/main/java/com/example/demo/PostRepository.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -9,7 +10,7 @@

public interface PostRepository extends CrudRepository<Post, UUID> {
@Override
@Cacheable(value = "posts", key = "#p0")
@CachePut(value = "posts", key = "#p0")
Optional<Post> findById(UUID id);

@Override
Expand Down
3 changes: 2 additions & 1 deletion data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>

<!-- maven plugins -->
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
Expand All @@ -31,7 +32,7 @@
<tomcat.version>10.1.13</tomcat.version>

<!-- Eclipse Jetty -->
<jetty.version>11.0.15</jetty.version>
<jetty.version>11.0.16</jetty.version>

<!-- Skip tests by default -->
<skip.unit.tests>true</skip.unit.tests>
Expand Down
2 changes: 1 addition & 1 deletion data-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<tomcat.version>10.1.13</tomcat.version>

<!-- Eclipse Jetty -->
<jetty.version>11.0.15</jetty.version>
<jetty.version>11.0.16</jetty.version>

<!-- WildFly preview for Jakarta EE 10 -->
<wildfly.version>29.0.1.Final</wildfly.version>
Expand Down
Loading
Loading