|
17 | 17 | package org.springframework.aot.hint.support;
|
18 | 18 |
|
19 | 19 | import java.net.URI;
|
| 20 | +import java.time.Instant; |
20 | 21 | import java.time.LocalDate;
|
21 | 22 |
|
22 | 23 | import org.junit.jupiter.api.BeforeEach;
|
23 | 24 | import org.junit.jupiter.api.Test;
|
24 | 25 |
|
25 | 26 | import org.springframework.aot.hint.RuntimeHints;
|
26 | 27 | import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
27 |
| -import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
28 | 28 | import org.springframework.core.io.support.SpringFactoriesLoader;
|
29 | 29 | import org.springframework.util.ClassUtils;
|
30 | 30 |
|
31 | 31 | import static org.assertj.core.api.Assertions.assertThat;
|
| 32 | +import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.reflection; |
32 | 33 |
|
33 | 34 | /**
|
34 | 35 | * Tests for {@link ObjectToObjectConverterRuntimeHints}.
|
35 | 36 | *
|
36 | 37 | * @author Sebastien Deleuze
|
| 38 | + * @author Sam Brannen |
37 | 39 | */
|
38 | 40 | class ObjectToObjectConverterRuntimeHintsTests {
|
39 | 41 |
|
40 |
| - private RuntimeHints hints; |
| 42 | + private final RuntimeHints hints = new RuntimeHints(); |
| 43 | + |
41 | 44 |
|
42 | 45 | @BeforeEach
|
43 | 46 | void setup() {
|
44 |
| - this.hints = new RuntimeHints(); |
45 | 47 | SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
46 |
| - .load(RuntimeHintsRegistrar.class).forEach(registrar -> registrar |
47 |
| - .registerHints(this.hints, ClassUtils.getDefaultClassLoader())); |
| 48 | + .load(RuntimeHintsRegistrar.class) |
| 49 | + .forEach(registrar -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader())); |
48 | 50 | }
|
49 | 51 |
|
50 | 52 | @Test
|
51 | 53 | void javaSqlDateHasHints() throws NoSuchMethodException {
|
52 |
| - assertThat(RuntimeHintsPredicates.reflection().onMethod(java.sql.Date.class, "toLocalDate")).accepts(this.hints); |
53 |
| - assertThat(RuntimeHintsPredicates.reflection().onMethod(java.sql.Date.class.getMethod("valueOf", LocalDate.class))).accepts(this.hints); |
| 54 | + assertThat(reflection().onMethod(java.sql.Date.class, "toLocalDate")).accepts(this.hints); |
| 55 | + assertThat(reflection().onMethod(java.sql.Date.class.getMethod("valueOf", LocalDate.class))).accepts(this.hints); |
| 56 | + } |
| 57 | + |
| 58 | + @Test // gh-35156 |
| 59 | + void javaSqlTimestampHasHints() throws NoSuchMethodException { |
| 60 | + assertThat(reflection().onMethod(java.sql.Timestamp.class.getMethod("from", Instant.class))).accepts(this.hints); |
54 | 61 | }
|
55 | 62 |
|
56 | 63 | @Test
|
57 | 64 | void uriHasHints() throws NoSuchMethodException {
|
58 |
| - assertThat(RuntimeHintsPredicates.reflection().onConstructor(URI.class.getConstructor(String.class))).accepts(this.hints); |
| 65 | + assertThat(reflection().onConstructor(URI.class.getConstructor(String.class))).accepts(this.hints); |
59 | 66 | }
|
60 | 67 |
|
61 | 68 | }
|
0 commit comments