diff --git a/scheduler/boot-scheduler-quartz/Dockerfile b/scheduler/boot-scheduler-quartz/Dockerfile index a5783b2a1..b3580a29c 100644 --- a/scheduler/boot-scheduler-quartz/Dockerfile +++ b/scheduler/boot-scheduler-quartz/Dockerfile @@ -1,11 +1,11 @@ -FROM eclipse-temurin:17.0.8_7-jre-focal as builder +FROM eclipse-temurin:17.0.9_9-jre-focal as builder WORKDIR application ARG JAR_FILE=target/boot-scheduler-quartz-0.0.1-SNAPSHOT.jar COPY ${JAR_FILE} application.jar RUN java -Djarmode=layertools -jar application.jar extract # the second stage of our build will copy the extracted layers -FROM eclipse-temurin:17.0.8_7-jre-focal +FROM eclipse-temurin:17.0.9_9-jre-focal WORKDIR application COPY --from=builder application/dependencies/ ./ COPY --from=builder application/spring-boot-loader/ ./ diff --git a/scheduler/boot-scheduler-quartz/mvnw b/scheduler/boot-scheduler-quartz/mvnw old mode 100644 new mode 100755 diff --git a/scheduler/boot-scheduler-quartz/pom.xml b/scheduler/boot-scheduler-quartz/pom.xml index e00a537fe..1b4f00842 100644 --- a/scheduler/boot-scheduler-quartz/pom.xml +++ b/scheduler/boot-scheduler-quartz/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.5 + 3.2.0-RC2 com.scheduler.quartz @@ -20,8 +20,7 @@ UTF-8 UTF-8 - 17 - 2022.0.4 + 21 2.2.0 2.15.0 @@ -124,18 +123,6 @@ - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - @@ -237,7 +224,7 @@ - 2.30.0 + 2.38.0 @@ -350,4 +337,24 @@ + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/GlobalExceptionHandler.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/GlobalExceptionHandler.java index baf0b7378..daf5ab89d 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/GlobalExceptionHandler.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/GlobalExceptionHandler.java @@ -25,22 +25,19 @@ public class GlobalExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValidException) { ProblemDetail problemDetail = - ProblemDetail.forStatusAndDetail( - HttpStatusCode.valueOf(400), "Invalid request content."); + ProblemDetail.forStatusAndDetail(HttpStatusCode.valueOf(400), "Invalid request content."); problemDetail.setTitle("Constraint Violation"); - List validationErrorsList = - methodArgumentNotValidException.getAllErrors().stream() - .map( - objectError -> { - FieldError fieldError = (FieldError) objectError; - return new ApiValidationError( - fieldError.getObjectName(), - fieldError.getField(), - fieldError.getRejectedValue(), - Objects.requireNonNull(fieldError.getDefaultMessage(), "")); - }) - .sorted(Comparator.comparing(ApiValidationError::field)) - .toList(); + List validationErrorsList = methodArgumentNotValidException.getAllErrors().stream() + .map(objectError -> { + FieldError fieldError = (FieldError) objectError; + return new ApiValidationError( + fieldError.getObjectName(), + fieldError.getField(), + fieldError.getRejectedValue(), + Objects.requireNonNull(fieldError.getDefaultMessage(), "")); + }) + .sorted(Comparator.comparing(ApiValidationError::field)) + .toList(); problemDetail.setProperty("violations", validationErrorsList); return problemDetail; } @@ -48,18 +45,17 @@ ProblemDetail onException(MethodArgumentNotValidException methodArgumentNotValid @ExceptionHandler(Exception.class) ProblemDetail onException(Exception exception) { if (exception instanceof ResourceNotFoundException resourceNotFoundException) { - ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail( - resourceNotFoundException.getHttpStatus(), resourceNotFoundException.getMessage()); - problemDetail.setTitle("Not Found"); - problemDetail.setType(URI.create("http://api.boot-scheduler-quartz.com/errors/not-found")); - problemDetail.setProperty("errorCategory", "Generic"); - problemDetail.setProperty("timestamp", Instant.now()); - return problemDetail; + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail( + resourceNotFoundException.getHttpStatus(), resourceNotFoundException.getMessage()); + problemDetail.setTitle("Not Found"); + problemDetail.setType(URI.create("http://api.boot-scheduler-quartz.com/errors/not-found")); + problemDetail.setProperty("errorCategory", "Generic"); + problemDetail.setProperty("timestamp", Instant.now()); + return problemDetail; } else { return ProblemDetail.forStatusAndDetail(HttpStatusCode.valueOf(500), exception.getMessage()); } } record ApiValidationError(String object, String field, Object rejectedValue, String message) {} - } diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/SwaggerConfig.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/SwaggerConfig.java index 14179b626..dadbedf82 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/SwaggerConfig.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/SwaggerConfig.java @@ -6,7 +6,5 @@ import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@OpenAPIDefinition( - info = @Info(title = "boot-scheduler-quartz", version = "v1"), - servers = @Server(url = "/")) +@OpenAPIDefinition(info = @Info(title = "boot-scheduler-quartz", version = "v1"), servers = @Server(url = "/")) public class SwaggerConfig {} diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/logging/LoggingAspect.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/logging/LoggingAspect.java index e9c1bdb82..a88ebc050 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/logging/LoggingAspect.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/config/logging/LoggingAspect.java @@ -25,17 +25,15 @@ public LoggingAspect(Environment env) { this.env = env; } - @Pointcut( - "within(@org.springframework.stereotype.Repository *)" - + " || within(@org.springframework.stereotype.Service *)" - + " || within(@org.springframework.web.bind.annotation.RestController *)") + @Pointcut("within(@org.springframework.stereotype.Repository *)" + + " || within(@org.springframework.stereotype.Service *)" + + " || within(@org.springframework.web.bind.annotation.RestController *)") public void springBeanPointcut() { // pointcut definition } - @Pointcut( - "@within(com.scheduler.quartz.config.logging.Loggable) || " - + "@annotation(com.scheduler.quartz.config.logging.Loggable)") + @Pointcut("@within(com.scheduler.quartz.config.logging.Loggable) || " + + "@annotation(com.scheduler.quartz.config.logging.Loggable)") public void applicationPackagePointcut() { // pointcut definition } diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/exception/ResourceNotFoundException.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/exception/ResourceNotFoundException.java index f6b8fb45c..0bceffa7d 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/exception/ResourceNotFoundException.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/exception/ResourceNotFoundException.java @@ -1,4 +1,5 @@ package com.scheduler.quartz.exception; + import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/response/PagedResult.java b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/response/PagedResult.java index 788d0a750..2232af03c 100644 --- a/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/response/PagedResult.java +++ b/scheduler/boot-scheduler-quartz/src/main/java/com/scheduler/quartz/model/response/PagedResult.java @@ -1,9 +1,7 @@ package com.scheduler.quartz.model.response; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; - import org.springframework.data.domain.Page; public record PagedResult( @@ -11,17 +9,13 @@ public record PagedResult( long totalElements, int pageNumber, int totalPages, - @JsonProperty("isFirst") - boolean isFirst, - @JsonProperty("isLast") - boolean isLast, - @JsonProperty("hasNext") - boolean hasNext, - @JsonProperty("hasPrevious") - boolean hasPrevious -) { + @JsonProperty("isFirst") boolean isFirst, + @JsonProperty("isLast") boolean isLast, + @JsonProperty("hasNext") boolean hasNext, + @JsonProperty("hasPrevious") boolean hasPrevious) { public PagedResult(Page page, List data) { - this(data, + this( + data, page.getTotalElements(), page.getNumber() + 1, page.getTotalPages(), @@ -30,4 +24,4 @@ public PagedResult(Page page, List data) { page.hasNext(), page.hasPrevious()); } -} \ No newline at end of file +} diff --git a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/SchemaValidationTest.java b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/SchemaValidationTest.java deleted file mode 100644 index 9ff629325..000000000 --- a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/SchemaValidationTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.scheduler.quartz; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; - -@DataJpaTest(properties = { - "spring.jpa.hibernate.ddl-auto=validate", - "spring.test.database.replace=none", - "spring.datasource.url=jdbc:tc:postgresql:16.0-alpine:///db" -}) -class SchemaValidationTest { - - @Test - void validateJpaMappingsWithDbSchema() { - } -} diff --git a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/TestApplication.java b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/TestApplication.java index 8c6277601..01dd8d456 100644 --- a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/TestApplication.java +++ b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/TestApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication; public class TestApplication { - + public static void main(String[] args) { System.setProperty("spring.profiles.active", "local"); SpringApplication.from(Application::main).with(ContainersConfig.class).run(args); diff --git a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/AbstractIntegrationTest.java b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/AbstractIntegrationTest.java index f5e6a48bf..f4d27c1e8 100644 --- a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/AbstractIntegrationTest.java +++ b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/AbstractIntegrationTest.java @@ -11,11 +11,15 @@ import org.springframework.test.web.servlet.MockMvc; @ActiveProfiles({PROFILE_TEST}) -@SpringBootTest(webEnvironment = RANDOM_PORT, classes = {ContainersConfig.class}) +@SpringBootTest( + webEnvironment = RANDOM_PORT, + classes = {ContainersConfig.class}) @AutoConfigureMockMvc public abstract class AbstractIntegrationTest { - @Autowired protected MockMvc mockMvc; + @Autowired + protected MockMvc mockMvc; - @Autowired protected ObjectMapper objectMapper; + @Autowired + protected ObjectMapper objectMapper; } diff --git a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/ContainersConfig.java b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/ContainersConfig.java index 3a29b22bf..c4368ea28 100644 --- a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/ContainersConfig.java +++ b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/common/ContainersConfig.java @@ -11,8 +11,7 @@ public class ContainersConfig { @Bean @ServiceConnection - PostgreSQLContainer postgreSQLContainer() { + PostgreSQLContainer postgreSQLContainer() { return new PostgreSQLContainer<>(DockerImageName.parse("postgres:16.0-alpine")); } - } diff --git a/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/repository/SchemaValidationTest.java b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/repository/SchemaValidationTest.java new file mode 100644 index 000000000..f83675dea --- /dev/null +++ b/scheduler/boot-scheduler-quartz/src/test/java/com/scheduler/quartz/repository/SchemaValidationTest.java @@ -0,0 +1,24 @@ +package com.scheduler.quartz; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.scheduler.quartz.common.ContainersConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.testcontainers.context.ImportTestcontainers; + +@DataJpaTest(properties = {"spring.jpa.hibernate.ddl-auto=validate", "spring.test.database.replace=none"}) +@ImportTestcontainers(ContainersConfig.class) +class SchemaValidationTest { + + @Autowired + private DataSource dataSource; + + @Test + void validateJpaMappingsWithDbSchema() { + assertThat(dataSource).isNotNull().isInstanceOf(HikariDataSource.class); + } +}