Removal of JAXB annotations - #1807
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates several Nexo model classes, including AbortRequest, DisplayRequest, LoginRequest, and MessageHeader, from JAXB XML annotations to GSON @SerializedName annotations. The changes also involve removing JAXB-specific metadata and adding unit tests to verify that serialization and deserialization remain functional even when fields previously marked as required are missing from the JSON payload. I have no feedback to provide.
|
@jeandersonbc is my understanding correct that we were using the jaxb annotation with GSON as the serializer / deserializer, so there is no actual change in behavior other than using GSON annotations? |
Correct @thomas-cools (cc @gcatanese)! I also pushed this test that verifies how GSON handles the JAXB annotations. The target class ( I'm going to proceed to JAXB -> Gson annontations as part of the original task. |
34c0d98 to
4ade44d
Compare
4ade44d to
f0f5cce
Compare
gcatanese
left a comment
There was a problem hiding this comment.
Great work Jean, this is a challenging issue.
I left few comments in the code and there is here one about test coverage, they might be edge cases so please assess whether they are applicable or not
Test Coverage Gaps
• No direct unit tests for
XMLEnumTypeAdapterwith @SerializedName, especially the edge case where the annotation is absent on an enum constant.
• No round-trip tests forSaleToPOIRequest— only SaleToPOIResponse is covered despite the same migration pattern.
•RepeatedMessageResponseBody/RepeatedResponseMessageBody— migrated but zero test coverage.
•TerminalAPIGsonBuilderfallback behavior — no test verifying the behavior when @SerializedName is missing.
f0f5cce to
e0d6100
Compare
This PR removes the JAXB-bind related annotations. This change is needed due to Jakarta EE +9 compatibility. The existing code in `com.adyen.terminal.serialization` relies on GSON; thus, the JAXB annotations were replaced by the GSON's @SerializedName. The JAXB validations (e.g., type checks and required fields) were not processed by GSON and have no equivalent (see `AbortRequestTest` for instance). The migration was guided by test coverage and focused on serialization and deserialization of JSON payloads. POM XML changes: - removal of jaxb dependency - addition of plugin enforcement to block unwanted dependencies
e0d6100 to
e6a3ee3
Compare
Description
Removal the JAXB-bind related annotations. This change is needed due to Jakarta EE +9 compatibility.
In addition, we Improved type safety for
AuthenticatedData.keyTransportOrKEKdeserialization**:Previously, items in the keyTransportOrKEK list were deserialized as raw Object (a Gson LinkedTreeMap at runtime), requiring brittle map access to read fields. The
TerminalAPIGsonBuildernow registers a custom adapter that detects the concrete type of each list item at deserialization time — objects containing a KEKIdentifier field are deserialized as KEK, all others as KeyTransport. This makes safe casting possible:Further details:
Since the underlying serializer relies on Gson lib, we are unable to use directly Jackson annotations since they don't work as expected. This was verified via test coverage. Furthermore, the
required=truevalidation was never enforced (see AbortRequestTest tests).The existing code in
com.adyen.terminal.serializationrelies on GSON; thus,the JAXB annotations were replaced by the GSON's @SerializedName.The migration was guided by test coverage and focused on serialization and deserialization of JSON payloads.
POM XML changes:
Tested scenarios