@@ -53,4 +53,72 @@ void registerHints() {
53
53
assertThat (registeredTypes .contains (TypeReference .of (VertexAiGeminiChatOptions .class ))).isTrue ();
54
54
}
55
55
56
+ @ Test
57
+ void registerHintsWithNullClassLoader () {
58
+ RuntimeHints runtimeHints = new RuntimeHints ();
59
+ VertexAiGeminiRuntimeHints vertexAiGeminiRuntimeHints = new VertexAiGeminiRuntimeHints ();
60
+
61
+ // Should not throw exception with null ClassLoader
62
+ org .assertj .core .api .Assertions
63
+ .assertThatCode (() -> vertexAiGeminiRuntimeHints .registerHints (runtimeHints , null ))
64
+ .doesNotThrowAnyException ();
65
+ }
66
+
67
+ @ Test
68
+ void ensureReflectionHintsAreRegistered () {
69
+ RuntimeHints runtimeHints = new RuntimeHints ();
70
+ VertexAiGeminiRuntimeHints vertexAiGeminiRuntimeHints = new VertexAiGeminiRuntimeHints ();
71
+ vertexAiGeminiRuntimeHints .registerHints (runtimeHints , null );
72
+
73
+ // Ensure reflection hints are properly registered
74
+ assertThat (runtimeHints .reflection ().typeHints ().spliterator ().estimateSize ()).isGreaterThan (0 );
75
+ }
76
+
77
+ @ Test
78
+ void verifyMultipleRegistrationCallsAreIdempotent () {
79
+ RuntimeHints runtimeHints = new RuntimeHints ();
80
+ VertexAiGeminiRuntimeHints vertexAiGeminiRuntimeHints = new VertexAiGeminiRuntimeHints ();
81
+
82
+ // Register hints multiple times
83
+ vertexAiGeminiRuntimeHints .registerHints (runtimeHints , null );
84
+ long firstCount = runtimeHints .reflection ().typeHints ().spliterator ().estimateSize ();
85
+
86
+ vertexAiGeminiRuntimeHints .registerHints (runtimeHints , null );
87
+ long secondCount = runtimeHints .reflection ().typeHints ().spliterator ().estimateSize ();
88
+
89
+ // Should not register duplicate hints
90
+ assertThat (firstCount ).isEqualTo (secondCount );
91
+ }
92
+
93
+ @ Test
94
+ void verifyJsonAnnotatedClassesFromCorrectPackage () {
95
+ Set <TypeReference > jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage (
96
+ "org.springframework.ai.vertexai.gemini" );
97
+
98
+ // Ensure we found some JSON annotated classes in the expected package
99
+ assertThat (jsonAnnotatedClasses .spliterator ().estimateSize ()).isGreaterThan (0 );
100
+
101
+ // Verify all found classes are from the expected package
102
+ for (TypeReference classRef : jsonAnnotatedClasses ) {
103
+ assertThat (classRef .getName ()).startsWith ("org.springframework.ai.vertexai.gemini" );
104
+ }
105
+ }
106
+
107
+ @ Test
108
+ void verifyNoUnnecessaryHintsRegistered () {
109
+ RuntimeHints runtimeHints = new RuntimeHints ();
110
+ VertexAiGeminiRuntimeHints vertexAiGeminiRuntimeHints = new VertexAiGeminiRuntimeHints ();
111
+ vertexAiGeminiRuntimeHints .registerHints (runtimeHints , null );
112
+
113
+ Set <TypeReference > jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage (
114
+ "org.springframework.ai.vertexai.gemini" );
115
+
116
+ Set <TypeReference > registeredTypes = new HashSet <>();
117
+ runtimeHints .reflection ().typeHints ().forEach (typeHint -> registeredTypes .add (typeHint .getType ()));
118
+
119
+ // Ensure we don't register significantly more types than needed
120
+ // Allow for some additional utility types but prevent hint bloat
121
+ assertThat (registeredTypes .size ()).isLessThanOrEqualTo (jsonAnnotatedClasses .size () + 10 );
122
+ }
123
+
56
124
}
0 commit comments