Add reflection-based Jackson round-trip test for all generated types#1509
Merged
Conversation
The shell runs with 'set -e -o pipefail', so when head -1 closes the pipe early, grep exits with SIGPIPE (exit 141) and pipefail propagates that as the pipeline's exit status, failing the step. Using 'grep -m 1' makes grep stop after the first match itself, eliminating the broken pipe entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
GeneratedTypesJacksonRoundTripTest— a zero-maintenance test that uses reflection to auto-discover every generated record and enum incom.github.copilot.generatedandcom.github.copilot.generated.rpc, then Jackson round-trips each one.What it does
{}, serializes back to JSON, deserializes again, asserts equality.@JsonValue, deserializes back via@JsonCreator, asserts equality.@TestFactory+DynamicTestso each class gets its own named test case (571 tests today).ProtectionDomain.getCodeSource().getLocation()to find the compiled.classdirectory, which works on both JDK 17 and JDK 25 (unlikeClass.getResource(), which returns null under stricter JPMS encapsulation on JDK 25).Why
Generated code coverage was at 46.4%. This single test brings it to 83.6% — above the 80% target — without any hand-written per-class boilerplate. When generated types are added or removed, the test automatically adapts.
Testing
mvn spotless:checkpasses