| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…#4082) Verify that source="items.first" and source="items.last" correctly resolve to List.getFirst() / List.getLast() when compiled under JDK 21, and document the null-list safety and empty-list NoSuchElementException behavior of the generated code. Signed-off-by: klouds27 <adalwolf@gmail.com>
There was a problem hiding this comment.
Adds JDK 21-only processor tests to validate nested property-path mappings using items.first / items.last against List (SequencedCollection) sources, covering normal, null, and empty-list behaviors.
Changes:
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| processor/src/test/java/org/mapstruct/ap/test/bugs/_4082/jdk21/Target.java | Target bean with first / last properties for assertions. |
| processor/src/test/java/org/mapstruct/ap/test/bugs/_4082/jdk21/SourceMapper.java | Mapper exercising source="items.first" and source="items.last". |
| processor/src/test/java/org/mapstruct/ap/test/bugs/_4082/jdk21/Source.java | Source bean with List<String> items used by the tests. |
| processor/src/test/java/org/mapstruct/ap/test/bugs/_4082/jdk21/Issue4082Test.java | JDK-only tests validating mapping and edge cases for SequencedCollection accessors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| Source source = new Source( List.of() ); | ||
|
|
||
| assertThatThrownBy( () -> SourceMapper.INSTANCE.map( source ) ) | ||
| .isInstanceOf( java.util.NoSuchElementException.class ); | ||
| } |
| Back | FazBrowse Home | New Git URL |
Closes #4082
Adds @ProcessorTest(Compiler.JDK) tests covering source="items.first" and source="items.last" nested property paths on a List field.
The three tests cover the happy path (three-element list maps first and last correctly), null-list safety (generated null guard returns null), and empty-list behavior (NoSuchElementException from getFirst() on an empty list).
Note: --release < 21 suppresses these methods from the javax.lang.model view of List via CT.sym, so the tests are JDK-only. With JDK 21 as MapStruct's minimum, the feature resolves correctly in all supported environments.