21
21
import org .springframework .ai .mistralai .MistralAiChatModel ;
22
22
import org .springframework .ai .mistralai .MistralAiEmbeddingModel ;
23
23
import org .springframework .ai .mistralai .moderation .MistralAiModerationModel ;
24
- import org .springframework .boot .autoconfigure .AutoConfigurations ;
25
24
import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
26
25
27
26
import static org .assertj .core .api .Assertions .assertThat ;
@@ -39,26 +38,23 @@ public class MistralModelConfigurationTests {
39
38
40
39
@ Test
41
40
void chatModelActivation () {
42
- this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ))
43
- .run (context -> {
44
- assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isNotEmpty ();
45
- assertThat (context .getBeansOfType (MistralAiChatModel .class )).isNotEmpty ();
46
- assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
47
- assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
48
- assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
49
- assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
50
- });
51
-
52
- this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ))
41
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiChatAutoConfig ()).run (context -> {
42
+ assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isNotEmpty ();
43
+ assertThat (context .getBeansOfType (MistralAiChatModel .class )).isNotEmpty ();
44
+ assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
45
+ assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
46
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
47
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
48
+ });
49
+
50
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiChatAutoConfig ())
53
51
.withPropertyValues ("spring.ai.model.chat=none" , "spring.ai.model.embedding=none" )
54
52
.run (context -> {
55
53
assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isEmpty ();
56
54
assertThat (context .getBeansOfType (MistralAiChatModel .class )).isEmpty ();
57
55
});
58
56
59
- this .contextRunner
60
- .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ,
61
- MistralAiEmbeddingAutoConfiguration .class ))
57
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiChatAutoConfig ())
62
58
.withPropertyValues ("spring.ai.model.chat=mistral" , "spring.ai.model.embedding=none" )
63
59
.run (context -> {
64
60
assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isNotEmpty ();
@@ -72,17 +68,17 @@ void chatModelActivation() {
72
68
73
69
@ Test
74
70
void embeddingModelActivation () {
75
- this .contextRunner .withConfiguration (AutoConfigurations . of ( MistralAiEmbeddingAutoConfiguration . class ))
71
+ this .contextRunner .withConfiguration (BaseMistralAiIT . mistralAiEmbeddingAutoConfig ( ))
76
72
.run (context -> assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isNotEmpty ());
77
73
78
- this .contextRunner .withConfiguration (AutoConfigurations . of ( MistralAiEmbeddingAutoConfiguration . class ))
74
+ this .contextRunner .withConfiguration (BaseMistralAiIT . mistralAiEmbeddingAutoConfig ( ))
79
75
.withPropertyValues ("spring.ai.model.embedding=none" )
80
76
.run (context -> {
81
77
assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
82
78
assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
83
79
});
84
80
85
- this .contextRunner .withConfiguration (AutoConfigurations . of ( MistralAiEmbeddingAutoConfiguration . class ))
81
+ this .contextRunner .withConfiguration (BaseMistralAiIT . mistralAiEmbeddingAutoConfig ( ))
86
82
.withPropertyValues ("spring.ai.model.embedding=mistral" )
87
83
.run (context -> {
88
84
assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isNotEmpty ();
@@ -92,33 +88,30 @@ void embeddingModelActivation() {
92
88
93
89
@ Test
94
90
void moderationModelActivation () {
95
- this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiModerationAutoConfiguration .class ))
96
- .run (context -> {
97
- assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
98
- assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isNotEmpty ();
99
- assertThat (context .getBeansOfType (MistralAiChatModel .class )).isEmpty ();
100
- assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isEmpty ();
101
- assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
102
- assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
103
- });
104
-
105
- this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiModerationAutoConfiguration .class ))
91
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiModerationAutoConfig ()).run (context -> {
92
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
93
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isNotEmpty ();
94
+ assertThat (context .getBeansOfType (MistralAiChatModel .class )).isEmpty ();
95
+ assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isEmpty ();
96
+ assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
97
+ assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
98
+ });
99
+
100
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiModerationAutoConfig ())
106
101
.withPropertyValues ("spring.ai.model.moderation=none" )
107
102
.run (context -> {
108
103
assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
109
104
assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
110
105
});
111
106
112
- this .contextRunner .withConfiguration (AutoConfigurations . of ( MistralAiModerationAutoConfiguration . class ))
107
+ this .contextRunner .withConfiguration (BaseMistralAiIT . mistralAiModerationAutoConfig ( ))
113
108
.withPropertyValues ("spring.ai.model.moderation=mistral" )
114
109
.run (context -> {
115
110
assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isNotEmpty ();
116
111
assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
117
112
});
118
113
119
- this .contextRunner
120
- .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ,
121
- MistralAiEmbeddingAutoConfiguration .class , MistralAiModerationAutoConfiguration .class ))
114
+ this .contextRunner .withConfiguration (BaseMistralAiIT .mistralAiModerationAutoConfig ())
122
115
.withPropertyValues ("spring.ai.model.chat=none" , "spring.ai.model.embedding=none" ,
123
116
"spring.ai.model.moderation=mistral" )
124
117
.run (context -> {
0 commit comments