Skip to content

Commit

Permalink
Upgrade Spring Boot to v3.3.4; apply Java 17 standards and Spring Boo…
Browse files Browse the repository at this point in the history
…t best practises
  • Loading branch information
jkosternl committed Sep 20, 2024
1 parent c6236b8 commit e78c2f4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public class CsChecks {
if (!CsDataSets.CUTOFF_DATE_TIME_CODES.contains(
cutOffDateTimeCode.asText())) {
issues.add(
String.format(
"Invalid cutOffDateTimeCode: %s",
"Invalid cutOffDateTimeCode: %s".formatted(
cutOffDateTimeCode.asText()));
}
}));
Expand Down Expand Up @@ -120,7 +119,7 @@ private static JsonContentCheck paginationCheck(Supplier<DynamicScenarioParamete

private static JsonContentCheck createLocationCheckPtp(String locationType) {
return JsonAttribute.customValidator(
String.format("Check any one of the location is available for '%s'", locationType),
"Check any one of the location is available for '%s'".formatted(locationType),
body -> {
var issues = new LinkedHashSet<String>();
for (JsonNode routing : body) {
Expand Down Expand Up @@ -228,14 +227,14 @@ private static JsonContentCheck createLocationCheckVs() {

private static void checkAnyLocationIsPresent(
String locationType, JsonNode data, LinkedHashSet<String> issues) {
String locationPath = String.format("/%s/location", locationType);
String locationPath = "/%s/location".formatted(locationType);
JsonNode address = data.at(locationPath + "/address");
JsonNode unLocationCode = data.at(locationPath + "/UNLocationCode");
JsonNode facility = data.at(locationPath + "/facility");
if (JsonAttribute.isJsonNodeAbsent(address)
&& JsonAttribute.isJsonNodeAbsent(unLocationCode)
&& JsonAttribute.isJsonNodeAbsent(facility)) {
issues.add(String.format("Any one of the location should be present for '%s'", locationType));
issues.add("Any one of the location should be present for '%s'".formatted(locationType));
}
}

Expand Down Expand Up @@ -310,9 +309,9 @@ private String compareDates(

// Compare the dates
if (dateType.equals("startDate") && !dateTimeAsDate.isAfter(date)) {
return String.format("The %s date should be after the start date", operation);
return "The %s date should be after the start date".formatted(operation);
} else if (dateType.equals("endDate") && !dateTimeAsDate.isBefore(date)) {
return String.format("The %s date should be before the end date", operation);
return "The %s date should be before the end date".formatted(operation);
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import org.junit.jupiter.api.Test;

Expand All @@ -16,7 +15,7 @@ void validateJsonSchemaValidator() throws IOException {
JsonSchemaValidator validator =
JsonSchemaValidator.getInstance("/schemas/booking-api-v20.json", "CreateBooking");

Path path = Paths.get("src/test/resources/examples/booking-request.json");
Path path = Path.of("src/test/resources/examples/booking-request.json");
assertTrue(Files.exists(path));
String read = String.join("\n", Files.readAllLines(path));
Set<String> validate = validator.validate(read);
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<log4j.version>2.20.0</log4j.version>
Expand Down Expand Up @@ -152,7 +153,7 @@
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<release>${maven.compiler.target}</release>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<description>DCSA Conformance Spring Boot</description>

<properties>
<spring-cloud.version>2022.0.3</spring-cloud.version>
<spring.boot.version>3.2.8</spring.boot.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<spring.boot.version>3.3.4</spring.boot.version>
</properties>

<dependencies>
Expand All @@ -41,7 +41,7 @@
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>

Expand Down
1 change: 1 addition & 0 deletions spring-boot/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
conformance.createAutoTestingSandboxes = true
conformance.createManualTestingSandboxes = true
conformance.useDynamoDb = false
spring.threads.virtual.enabled=true
conformance.showOnlyAllInOneSandboxes=true
#conformance.simulatedLambdaDelay=2000
1 change: 1 addition & 0 deletions spring-boot/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
server.port = 8080
spring.threads.virtual.enabled=true

logging.level.org.dcsa.conformance.standards = WARN
logging.level.org.dcsa.conformance.core.state = WARN
Expand Down

0 comments on commit e78c2f4

Please sign in to comment.