|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*; |
19 | 19 |
|
| 20 | +import java.util.ArrayList; |
| 21 | +import java.util.List; |
| 22 | + |
20 | 23 | import reactor.core.publisher.Mono; |
21 | 24 | import reactor.test.StepVerifier; |
22 | 25 |
|
|
26 | 29 | import org.springframework.context.annotation.Configuration; |
27 | 30 | import org.springframework.data.mapping.Person; |
28 | 31 | import org.springframework.data.mapping.PersonDocument; |
| 32 | +import org.springframework.data.mapping.PersonNoId; |
29 | 33 | import org.springframework.data.mapping.callback.CapturingEntityCallback.FirstCallback; |
30 | 34 | import org.springframework.data.mapping.callback.CapturingEntityCallback.SecondCallback; |
31 | 35 | import org.springframework.data.mapping.callback.CapturingEntityCallback.ThirdCallback; |
|
35 | 39 | * |
36 | 40 | * @author Mark Paluch |
37 | 41 | * @author Christoph Strobl |
| 42 | + * @author Michael J. Simons |
38 | 43 | */ |
39 | 44 | class DefaultReactiveEntityCallbacksUnitTests { |
40 | 45 |
|
@@ -124,6 +129,24 @@ void errorsOnNullValueReturnedByCallbackEntity() { |
124 | 129 | assertThat(third.capturedValues()).isEmpty(); |
125 | 130 | } |
126 | 131 |
|
| 132 | + @Test // GH-2808 |
| 133 | + void skipsInvocationUsingJava18ReflectiveTypeRejection() { |
| 134 | + |
| 135 | + DefaultReactiveEntityCallbacks callbacks = new DefaultReactiveEntityCallbacks(); |
| 136 | + callbacks.addEntityCallback(new DefaultEntityCallbacksUnitTests.Java18ClassCastStyle()); |
| 137 | + |
| 138 | + Person person = new PersonNoId(42, "Walter", "White"); |
| 139 | + List<Person> capturedPerson = new ArrayList<>(); |
| 140 | + |
| 141 | + callbacks.callback(DefaultEntityCallbacksUnitTests.BeforeConvertCallback.class, person) // |
| 142 | + .as(StepVerifier::create) |
| 143 | + .recordWith(() -> capturedPerson) |
| 144 | + .expectNextCount(1) |
| 145 | + .verifyComplete(); |
| 146 | + |
| 147 | + assertThat(capturedPerson.get(0)).isSameAs(person); |
| 148 | + } |
| 149 | + |
127 | 150 | @Configuration |
128 | 151 | static class MyConfig { |
129 | 152 |
|
|
0 commit comments