@@ -151,4 +151,64 @@ void onlyApiKeyWithoutUriShouldSetBothProperties() {
151
151
assertThat (this .properties ).containsEntry ("spring.ai.mistralai.base-url" , null );
152
152
}
153
153
154
+ @ Test
155
+ void extraPropertiesAreIgnored () {
156
+ Bindings extraPropsBinding = new Bindings (new Binding ("test-name" , Paths .get ("test-path" ),
157
+ Map .of (Binding .TYPE , MistralAiBindingsPropertiesProcessor .TYPE , "api-key" , "demo" , "uri" ,
158
+ "https://mistralai.example.com" , "extra-property" , "should-be-ignored" , "another-prop" ,
159
+ "also-ignored" )));
160
+
161
+ new MistralAiBindingsPropertiesProcessor ().process (this .environment , extraPropsBinding , this .properties );
162
+
163
+ assertThat (this .properties ).hasSize (2 );
164
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.api-key" , "demo" );
165
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.base-url" , "https://mistralai.example.com" );
166
+ assertThat (this .properties ).doesNotContainKey ("spring.ai.mistralai.extra-property" );
167
+ }
168
+
169
+ @ Test
170
+ void existingPropertiesAreOverwritten () {
171
+ this .properties .put ("spring.ai.mistralai.api-key" , "old-key" );
172
+ this .properties .put ("spring.ai.mistralai.base-url" , "https://old.example.com" );
173
+
174
+ new MistralAiBindingsPropertiesProcessor ().process (this .environment , this .bindings , this .properties );
175
+
176
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.api-key" , "demo" );
177
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.base-url" , "https://my.mistralai.example.net" );
178
+ }
179
+
180
+ @ Test
181
+ void bindingWithDifferentKeyNamesAreIgnored () {
182
+ // Using different key names (not "api-key" and "uri")
183
+ Bindings wrongKeysBinding = new Bindings (new Binding ("test-name" , Paths .get ("test-path" ),
184
+ Map .of (Binding .TYPE , MistralAiBindingsPropertiesProcessor .TYPE , "apiKey" , "demo" , // Wrong
185
+ // key
186
+ // name
187
+ // (camelCase)
188
+ "url" , "https://mistralai.example.com" ))); // Wrong key name
189
+
190
+ new MistralAiBindingsPropertiesProcessor ().process (this .environment , wrongKeysBinding , this .properties );
191
+
192
+ // Should set null for missing expected keys
193
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.api-key" , null );
194
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.base-url" , null );
195
+ }
196
+
197
+ @ Test
198
+ void multipleBindingsWithMistralAiTypeShouldProcessLast () {
199
+ Binding mistralBinding1 = new Binding ("mistral-1" , Paths .get ("path-1" ), Map .of (Binding .TYPE ,
200
+ MistralAiBindingsPropertiesProcessor .TYPE , "api-key" , "key1" , "uri" , "https://mistral1.example.com" ));
201
+
202
+ Binding mistralBinding2 = new Binding ("mistral-2" , Paths .get ("path-2" ), Map .of (Binding .TYPE ,
203
+ MistralAiBindingsPropertiesProcessor .TYPE , "api-key" , "key2" , "uri" , "https://mistral2.example.com" ));
204
+
205
+ Bindings multipleBindings = new Bindings (mistralBinding1 , mistralBinding2 );
206
+
207
+ new MistralAiBindingsPropertiesProcessor ().process (this .environment , multipleBindings , this .properties );
208
+
209
+ // Should process the last matching binding (overrides previous)
210
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.api-key" , "key2" );
211
+ assertThat (this .properties ).containsEntry ("spring.ai.mistralai.base-url" , "https://mistral2.example.com" );
212
+ }
213
+
154
214
}
0 commit comments