diff --git a/pom.xml b/pom.xml
index 2e1713a..e14174b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,10 +10,15 @@
org.springframework.bootspring-boot-starter-parent
- 2.0.5.RELEASE
+ 3.2.12
+
+ jakarta.validation
+ jakarta.validation-api
+ 3.1.1
+ software.amazon.awssdkbom
@@ -43,7 +48,7 @@
org.jsonjson
- 20200518
+ 20240303org.springframework.boot
@@ -54,38 +59,29 @@
org.apache.logging.log4jlog4j-api
- 2.13.3
-
-
-
- junit
- junit
- 4.13.1
- test
+ 2.23.1org.apache.logging.log4jlog4j-core
- 2.13.3
+ 2.23.1org.mockito
- mockito-all
- 1.10.19
+ mockito-coretest
- javax.validation
- validation-api
- 2.0.1.Final
+ jakarta.validation
+ jakarta.validation-api
- 1.8
+ 21
@@ -97,10 +93,9 @@
org.apache.maven.pluginsmaven-compiler-plugin
- 3.8.1
+ 3.14.0
- ${java.version}
- ${java.version}
+ ${java.version}
diff --git a/src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java b/src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java
index f22a653..d2a721a 100644
--- a/src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java
+++ b/src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java
@@ -19,15 +19,13 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import software.amazon.awssdk.services.appconfig.AppConfigClient;
import software.amazon.awssdk.services.appconfig.model.GetConfigurationResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import javax.validation.Valid;
-
-import static org.springframework.web.bind.annotation.RequestMethod.POST;
+import jakarta.validation.Valid;
@RestController
public class MoviesController {
@@ -109,8 +107,8 @@ public String movie() {
}
}
- @RequestMapping(value = "/movies/{movie}/edit", method = POST)
- public String processUpdateMovie(@Valid Movie movie, BindingResult result, @PathVariable("movieId") int movieId) {
+ @PostMapping("/movies/{movie}/edit")
+ public String processUpdateMovie(@Valid Movie movie, BindingResult result, @PathVariable int movieId) {
if (!MovieUtils.isValidMovieName(movie.getMovieName())) {
result.rejectValue("name", "error.name", "Invalid movie name");
return "editMovieForm";
diff --git a/src/main/java/com/amazonaws/samples/appconfig/utils/Math.java b/src/main/java/com/amazonaws/samples/appconfig/utils/Math.java
index 259b286..226f6fb 100644
--- a/src/main/java/com/amazonaws/samples/appconfig/utils/Math.java
+++ b/src/main/java/com/amazonaws/samples/appconfig/utils/Math.java
@@ -1,27 +1,28 @@
//example from https://docs.openrewrite.org/running-recipes/popular-recipe-guides/migrate-to-java-17
package com.amazonaws.samples.appconfig.utils;
import java.math.BigDecimal;
+import java.math.RoundingMode;
public class Math {
- Boolean bool = new Boolean(true);
- Byte b = new Byte("1");
- Character c = new Character('c');
- Double d = new Double(1.0);
- Float f = new Float(1.1f);
- Long l = new Long(1);
- Short sh = new Short("12");
+ Boolean bool = Boolean.valueOf(true);
+ Byte b = Byte.valueOf("1");
+ Character c = Character.valueOf('c');
+ Double d = Double.valueOf(1.0);
+ Float f = Float.valueOf(1.1f);
+ Long l = Long.valueOf(1);
+ Short sh = Short.valueOf("12");
short s3 = 3;
- Short sh3 = new Short(s3);
- Integer i = new Integer(1);
+ Short sh3 = Short.valueOf(s3);
+ Integer i = Integer.valueOf(1);
public void divide() {
BigDecimal bd = BigDecimal.valueOf(10);
BigDecimal bd2 = BigDecimal.valueOf(2);
- bd.divide(bd2, BigDecimal.ROUND_DOWN);
- bd.divide(bd2, 1);
- bd.divide(bd2, 1, BigDecimal.ROUND_CEILING);
- bd.divide(bd2, 1, 1);
- bd.setScale(2, 1);
+ bd.divide(bd2, RoundingMode.DOWN);
+ bd.divide(bd2, RoundingMode.DOWN);
+ bd.divide(bd2, 1, RoundingMode.CEILING);
+ bd.divide(bd2, 1, RoundingMode.DOWN);
+ bd.setScale(2, RoundingMode.DOWN);
}
}
\ No newline at end of file
diff --git a/src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java b/src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java
index 04972c1..11e9f7d 100644
--- a/src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java
+++ b/src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java
@@ -1,11 +1,13 @@
package com.amazonaws.samples.appconfig.movies;
-import org.junit.Test;
-
import java.math.BigDecimal;
+import java.math.RoundingMode;
+
import com.amazonaws.samples.appconfig.utils.Math;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MathTest {
@@ -18,21 +20,21 @@ public void testDivide() {
BigDecimal bd = BigDecimal.valueOf(10);
BigDecimal bd2 = BigDecimal.valueOf(2);
BigDecimal expectedResult1 = BigDecimal.valueOf(5);
- assertEquals(expectedResult1, bd.divide(bd2, BigDecimal.ROUND_DOWN));
+ assertEquals(expectedResult1, bd.divide(bd2, RoundingMode.DOWN));
// Test divide(BigDecimal, int)
BigDecimal expectedResult2 = BigDecimal.valueOf(5.0);
// Test divide(BigDecimal, int, int)
BigDecimal expectedResult3 = BigDecimal.valueOf(5.0);
- assertEquals(expectedResult3, bd.divide(bd2, 1, BigDecimal.ROUND_CEILING));
+ assertEquals(expectedResult3, bd.divide(bd2, 1, RoundingMode.CEILING));
BigDecimal expectedResult4 = BigDecimal.valueOf(5.0);
- assertEquals(expectedResult4, bd.divide(bd2, 1, 1));
+ assertEquals(expectedResult4, bd.divide(bd2, 1, RoundingMode.DOWN));
// Test setScale(int, int)
BigDecimal expectedResult5 = BigDecimal.valueOf(10);
- bd.setScale(2, 1);
+ bd.setScale(2, RoundingMode.DOWN);
assertEquals(expectedResult5, bd);
}
}
diff --git a/summary/buildCommandOutput.log b/summary/buildCommandOutput.log
new file mode 100644
index 0000000..c51eca3
--- /dev/null
+++ b/summary/buildCommandOutput.log
@@ -0,0 +1,56 @@
+[[1;34mINFO[m] Scanning for projects...
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m----------------< [0;36morg.amazonaws.samples:movie-service[0;1m >-----------------[m
+[[1;34mINFO[m] [1mBuilding movie-service 0.1.0[m
+[[1;34mINFO[m] [1m--------------------------------[ jar ]---------------------------------[m
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-clean-plugin:3.3.2:clean[m [1m(default-clean)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:3.3.1:resources[m [1m(default-resources)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m] Copying 1 resource from src/main/resources to target/classes
+[[1;34mINFO[m] Copying 1 resource from src/main/resources to target/classes
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.14.0:compile[m [1m(default-compile)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m] Recompiling the module because of [1mchanged source code[m.
+[[1;34mINFO[m] Compiling 9 source files with javac [debug parameters release 21] to target/classes
+[[1;34mINFO[m] Annotation processing is enabled because one or more processors were found
+ on the class path. A future release of javac may disable annotation processing
+ unless at least one processor is specified by name (-processor), or a search
+ path is specified (--processor-path, --processor-module-path), or annotation
+ processing is enabled explicitly (-proc:only, -proc:full).
+ Use -Xlint:-options to suppress this message.
+ Use -proc:none to disable annotation processing.
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:3.3.1:testResources[m [1m(default-testResources)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m] skip non existing resourceDirectory /tmp/originalCopy_53ab3758-8530-47a8-920e-ecc32b663ebf_588a0b62-85c5-4058-86a9-3407babc676a/sources/src/test/resources
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.14.0:testCompile[m [1m(default-testCompile)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m] Recompiling the module because of [1mchanged dependency[m.
+[[1;34mINFO[m] Compiling 1 source file with javac [debug parameters release 21] to target/test-classes
+[[1;34mINFO[m] Annotation processing is enabled because one or more processors were found
+ on the class path. A future release of javac may disable annotation processing
+ unless at least one processor is specified by name (-processor), or a search
+ path is specified (--processor-path, --processor-module-path), or annotation
+ processing is enabled explicitly (-proc:only, -proc:full).
+ Use -Xlint:-options to suppress this message.
+ Use -proc:none to disable annotation processing.
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m--- [0;32mmaven-surefire-plugin:3.1.2:test[m [1m(default-test)[m @ [36mmovie-service[0;1m ---[m
+[[1;34mINFO[m] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
+[[1;34mINFO[m]
+[[1;34mINFO[m] -------------------------------------------------------
+[[1;34mINFO[m] T E S T S
+[[1;34mINFO[m] -------------------------------------------------------
+[[1;34mINFO[m] Running com.amazonaws.samples.appconfig.movies.[1mMathTest[m
+[[1;34mINFO[m] [1;32mTests run: [0;1;32m1[m, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 s -- in com.amazonaws.samples.appconfig.movies.[1mMathTest[m
+[[1;34mINFO[m]
+[[1;34mINFO[m] Results:
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1;32mTests run: 1, Failures: 0, Errors: 0, Skipped: 0[m
+[[1;34mINFO[m]
+[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
+[[1;34mINFO[m] [1;32mBUILD SUCCESS[m
+[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
+[[1;34mINFO[m] Total time: 3.136 s
+[[1;34mINFO[m] Finished at: 2025-09-18T12:51:12Z
+[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
diff --git a/summary/qct-icons/transform-build-dark.svg b/summary/qct-icons/transform-build-dark.svg
new file mode 100644
index 0000000..6a3d121
--- /dev/null
+++ b/summary/qct-icons/transform-build-dark.svg
@@ -0,0 +1,5 @@
+
+
diff --git a/summary/qct-icons/transform-clock-dark.svg b/summary/qct-icons/transform-clock-dark.svg
new file mode 100644
index 0000000..4fba7b4
--- /dev/null
+++ b/summary/qct-icons/transform-clock-dark.svg
@@ -0,0 +1,8 @@
+
diff --git a/summary/qct-icons/transform-dependencies-dark.svg b/summary/qct-icons/transform-dependencies-dark.svg
new file mode 100644
index 0000000..67e2654
--- /dev/null
+++ b/summary/qct-icons/transform-dependencies-dark.svg
@@ -0,0 +1,6 @@
+
+
diff --git a/summary/qct-icons/transform-dependencyAnalyzer-dark.svg b/summary/qct-icons/transform-dependencyAnalyzer-dark.svg
new file mode 100644
index 0000000..360dd03
--- /dev/null
+++ b/summary/qct-icons/transform-dependencyAnalyzer-dark.svg
@@ -0,0 +1,7 @@
+
+
diff --git a/summary/qct-icons/transform-file-dark.svg b/summary/qct-icons/transform-file-dark.svg
new file mode 100644
index 0000000..6dc7dda
--- /dev/null
+++ b/summary/qct-icons/transform-file-dark.svg
@@ -0,0 +1,4 @@
+
diff --git a/summary/qct-icons/transform-listFiles-dark.svg b/summary/qct-icons/transform-listFiles-dark.svg
new file mode 100644
index 0000000..7f75386
--- /dev/null
+++ b/summary/qct-icons/transform-listFiles-dark.svg
@@ -0,0 +1,8 @@
+
+
diff --git a/summary/qct-icons/transform-logo.svg b/summary/qct-icons/transform-logo.svg
new file mode 100644
index 0000000..51f68cf
--- /dev/null
+++ b/summary/qct-icons/transform-logo.svg
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/summary/qct-icons/transform-smartStepInto-dark.svg b/summary/qct-icons/transform-smartStepInto-dark.svg
new file mode 100644
index 0000000..bf66ecd
--- /dev/null
+++ b/summary/qct-icons/transform-smartStepInto-dark.svg
@@ -0,0 +1,8 @@
+
+
diff --git a/summary/qct-icons/transform-step-into-dark.svg b/summary/qct-icons/transform-step-into-dark.svg
new file mode 100644
index 0000000..07fd107
--- /dev/null
+++ b/summary/qct-icons/transform-step-into-dark.svg
@@ -0,0 +1,7 @@
+
diff --git a/summary/qct-icons/transform-variables-dark.svg b/summary/qct-icons/transform-variables-dark.svg
new file mode 100644
index 0000000..f36d366
--- /dev/null
+++ b/summary/qct-icons/transform-variables-dark.svg
@@ -0,0 +1,7 @@
+
+
diff --git a/summary/summary.md b/summary/summary.md
new file mode 100644
index 0000000..919889f
--- /dev/null
+++ b/summary/summary.md
@@ -0,0 +1,100 @@
+
+
+
Code Transformation Summary by Amazon Q
+
Q has made the following changes during the transformation process.
+
Lines of code in your application: 492
+
Transformation duration: 25 min(s)
+
Dependencies upgraded: 10 out of 10
+
There are no deprecated APIs detected in this app
+
Files changed: 4
+
Build status in Java 21: SUCCEEDED
+
+### Table of Contents
+
+1. Build log summary
+1. Q Generated Summary and Recommendations
+1. Planned dependencies replaced
+1. Additional dependencies added
+1. Deprecated code replaced
+1. All files changed
+
+
+### Build log summary Scroll to top
+
+Amazon Q successfully built the upgraded code in Java 21. Here is a relevant snippet from the build log. To view the full build log, open [`buildCommandOutput.log`](./buildCommandOutput.log)
+
+```
+The build log shows a successful Maven build for a Java 21 project. The compilation, resource processing, and testing phases completed without errors. One unit test was executed and passed successfully.
+```
+
+
+### Q Generated Summary and Recommendations Scroll to top
+
+
+ #### Summary
+ Q has made the following changes during the transformation process. Please note that the summary is generated by GenAI.
+1. **JUnit Migration**: Updated from JUnit 4 to JUnit Jupiter (JUnit 5). This involved changing import statements from `org.junit.Test` to `org.junit.jupiter.api.Test` and from `org.junit.Assert.assertEquals` to `org.junit.jupiter.api.Assertions.assertEquals` in `MathTest.java`. JUnit 5 provides better support for Java 8+ features and has a more modular architecture.
+2. **BigDecimal Rounding Mode Update**: Replaced deprecated `BigDecimal.ROUND_*` constants with the `RoundingMode` enum in both `Math.java` and `MathTest.java`. For example, `BigDecimal.ROUND_DOWN` was replaced with `RoundingMode.DOWN`. This follows the Java recommendation to use the more type-safe enum introduced in Java 5.
+3. **Boxed Primitive Constructors Replacement**: Replaced deprecated boxed primitive constructors (e.g., `new Boolean(true)`, `new Integer(1)`) with their corresponding factory methods (`Boolean.valueOf(true)`, `Integer.valueOf(1)`) in `Math.java`. This change follows best practices as these constructors have been deprecated since Java 9.
+4. **Spring Boot Upgrade**: Updated Spring Boot from version `2.0.5.RELEASE` to `3.2.12` in the `pom.xml`. This is a major version upgrade that brings numerous improvements, security fixes, and compatibility with newer Java versions.
+5. **Jakarta EE Migration**: Replaced `javax.validation` dependencies with `jakarta.validation` and updated the import statements in the code (e.g., changing from `javax.validation.Valid` to `jakarta.validation.Valid` in `MoviesController.java`). This reflects the migration from Java EE to Jakarta EE that occurred when the platform moved to the Eclipse Foundation.
+6. **REST Controller Annotation Update**: Changed from using `@RequestMapping(method = POST)` to the more specific `@PostMapping` annotation in `MoviesController.java`. This follows Spring best practices by using the more concise and readable annotation.
+7. **Dependencies Version Updates**: Updated several dependencies to their newer versions, including:
+ - `org.json:json` from `20200518` to `20240303`
+ - `org.apache.logging.log4j:log4j-api` and `log4j-core` from `2.13.3` to `2.23.1`
+ - Changed `mockito-all` to `mockito-core` and removed explicit version to use Spring Boot's managed version
+8. **Maven Compiler Configuration**: Updated the Maven compiler plugin from `3.8.1` to `3.14.0` and changed from using `` and `` parameters to the more modern `` parameter, which better handles cross-compilation.
+9. **Path Variable Simplification**: Simplified `@PathVariable("movieId") int movieId` to just `@PathVariable int movieId` in `MoviesController.java`, leveraging Spring's capability to infer the variable name when it matches the path parameter.
+
+ #### Recommendations
+ Q was able to compile the upgraded app successfully. Here are detailed recommendations to further improve the upgrade. Please note that these recommendations are generated by GenAI, apply them accordingly.
+
+
+1. Please review and accept the code changes using the diff viewer. If you are using a Private Repository, please ensure that updated dependencies are available.
+2. If this project uses `Maven CheckStyle`, `Enforcer`, `FindBugs` or `SpotBugs plugins`, Q disabled these plugins when building the project to verify proposed upgrades. Please enable them and verify the code again.
+3. To help transform the rest of your code, you can use Amazon Q chat in the IDE. You can ask Amazon Q to review the partially updated files and provide new code to address issues, such as compilation errors. You can also use features like `/dev` and `@workspace` to include more of your project as context and get suggestions for multiple files at a time.
+
+
+
+### Planned dependencies replaced Scroll to top
+
+Amazon Q updated the following dependencies that it identified in the transformation plan
+
+| Dependency | Action | Previous version in Java 8 | Current version in Java 21 |
+|--------------|--------|--------|--------|
+
+
+### Additional dependencies added Scroll to top
+
+Amazon Q updated the following additional dependencies during the upgrade
+
+| Dependency | Action | Previous version in Java 8 | Current version in Java 21 |
+|--------------|--------|--------|--------|
+| `jakarta.validation:jakarta.validation-api` | Added | - | 3.1.1 |
+| `javax.validation:validation-api` | Removed | 2.0.1.Final | - |
+| `junit:junit` | Removed | 4.13.1 | - |
+| `org.apache.logging.log4j:log4j-api` | Updated | 2.13.3 | 2.23.1 |
+| `org.apache.logging.log4j:log4j-core` | Updated | 2.13.3 | 2.23.1 |
+| `org.apache.maven.plugins:maven-compiler-plugin` | Updated | 3.8.1 | 3.13.0 |
+| `org.json:json` | Updated | 20200518 | 20240303 |
+| `org.mockito:mockito-all` | Removed | 1.10.19 | - |
+| `org.mockito:mockito-core` | Added | - | - |
+| `org.springframework.boot:spring-boot-starter-parent` | Updated | 2.0.5.RELEASE | 3.2.12 |
+
+### Deprecated code replaced Scroll to top
+
+Amazon Q replaced the following instances of deprecated code. An instance with 0 files
+changed indicates Amazon Q wasn't able to replace the deprecated code.
+
+| Deprecated code | Files changed |
+|----------------|----------------|
+
+
+### All files changed Scroll to top
+
+| File | Action |
+|----------------|--------|
+| [pom.xml](../pom.xml) | Updated |
+| [src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java](../src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java) | Updated |
+| [src/main/java/com/amazonaws/samples/appconfig/utils/Math.java](../src/main/java/com/amazonaws/samples/appconfig/utils/Math.java) | Updated |
+| [src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java](../src/test/java/com/amazonaws/samples/appconfig/movies/MathTest.java) | Updated |
\ No newline at end of file
diff --git a/transformation-plan.md b/transformation-plan.md
new file mode 100644
index 0000000..9fa59a1
--- /dev/null
+++ b/transformation-plan.md
@@ -0,0 +1,3 @@
+
+
+
Code Transformation plan by Amazon Q
Amazon Q reviewed your code and generated a transformation plan. Amazon Q will suggest code changes according to the plan, and you can review the updated code before accepting changes to your files.
Lines of code in your application: 492
Planned transformation changes
Amazon Q will use the proposed changes as guidance during the transformation. The final code updates might differ from this plan. Read more.
Step 1 - Apply code changes and resolve compilation errors
Amazon Q will generate code changes that you can review before accepting changes to your files. You can also view a transformation summary with details about the upgrade and build logs for future reference and troubleshooting.