16
16
17
17
package org .springframework .ai .oci .cohere ;
18
18
19
+ import java .util .Collections ;
19
20
import java .util .List ;
20
21
import java .util .Map ;
21
22
22
23
import com .oracle .bmc .generativeaiinference .model .CohereTool ;
23
24
import org .junit .jupiter .api .Test ;
25
+ import org .junit .jupiter .api .BeforeEach ;
24
26
25
27
import static org .assertj .core .api .Assertions .assertThat ;
26
28
31
33
*/
32
34
class OCICohereChatOptionsTests {
33
35
36
+ private OCICohereChatOptions options ;
37
+
38
+ @ BeforeEach
39
+ void setUp () {
40
+ options = new OCICohereChatOptions ();
41
+ }
42
+
34
43
@ Test
35
44
void testBuilderWithAllFields () {
36
45
OCICohereChatOptions options = OCICohereChatOptions .builder ()
@@ -55,6 +64,34 @@ void testBuilderWithAllFields() {
55
64
0.6 , 50 , List .of ("test" ), 0.5 , 0.5 , List .of ("doc1" , "doc2" ));
56
65
}
57
66
67
+ @ Test
68
+ void testBuilderWithMinimalFields () {
69
+ OCICohereChatOptions options = OCICohereChatOptions .builder ().model ("minimal-model" ).build ();
70
+
71
+ assertThat (options .getModel ()).isEqualTo ("minimal-model" );
72
+ assertThat (options .getMaxTokens ()).isNull ();
73
+ assertThat (options .getTemperature ()).isNull ();
74
+ }
75
+
76
+ @ Test
77
+ void testBuilderWithNullValues () {
78
+ OCICohereChatOptions options = OCICohereChatOptions .builder ()
79
+ .model (null )
80
+ .maxTokens (null )
81
+ .temperature (null )
82
+ .stop (null )
83
+ .documents (null )
84
+ .tools (null )
85
+ .build ();
86
+
87
+ assertThat (options .getModel ()).isNull ();
88
+ assertThat (options .getMaxTokens ()).isNull ();
89
+ assertThat (options .getTemperature ()).isNull ();
90
+ assertThat (options .getStop ()).isNull ();
91
+ assertThat (options .getDocuments ()).isNull ();
92
+ assertThat (options .getTools ()).isNull ();
93
+ }
94
+
58
95
@ Test
59
96
void testCopy () {
60
97
OCICohereChatOptions original = OCICohereChatOptions .builder ()
@@ -82,9 +119,20 @@ void testCopy() {
82
119
assertThat (copied .getTools ()).isNotSameAs (original .getTools ());
83
120
}
84
121
122
+ @ Test
123
+ void testCopyWithNullValues () {
124
+ OCICohereChatOptions original = new OCICohereChatOptions ();
125
+ OCICohereChatOptions copied = (OCICohereChatOptions ) original .copy ();
126
+
127
+ assertThat (copied ).isNotSameAs (original ).isEqualTo (original );
128
+ assertThat (copied .getModel ()).isNull ();
129
+ assertThat (copied .getStop ()).isNull ();
130
+ assertThat (copied .getDocuments ()).isNull ();
131
+ assertThat (copied .getTools ()).isNull ();
132
+ }
133
+
85
134
@ Test
86
135
void testSetters () {
87
- OCICohereChatOptions options = new OCICohereChatOptions ();
88
136
options .setModel ("test-model" );
89
137
options .setMaxTokens (10 );
90
138
options .setCompartment ("test-compartment" );
@@ -114,7 +162,6 @@ void testSetters() {
114
162
115
163
@ Test
116
164
void testDefaultValues () {
117
- OCICohereChatOptions options = new OCICohereChatOptions ();
118
165
assertThat (options .getModel ()).isNull ();
119
166
assertThat (options .getMaxTokens ()).isNull ();
120
167
assertThat (options .getCompartment ()).isNull ();
@@ -130,4 +177,77 @@ void testDefaultValues() {
130
177
assertThat (options .getTools ()).isNull ();
131
178
}
132
179
180
+ @ Test
181
+ void testBoundaryValues () {
182
+ options .setMaxTokens (0 );
183
+ options .setTemperature (0.0 );
184
+ options .setTopP (0.0 );
185
+ options .setTopK (1 );
186
+ options .setFrequencyPenalty (0.0 );
187
+ options .setPresencePenalty (0.0 );
188
+
189
+ assertThat (options .getMaxTokens ()).isEqualTo (0 );
190
+ assertThat (options .getTemperature ()).isEqualTo (0.0 );
191
+ assertThat (options .getTopP ()).isEqualTo (0.0 );
192
+ assertThat (options .getTopK ()).isEqualTo (1 );
193
+ assertThat (options .getFrequencyPenalty ()).isEqualTo (0.0 );
194
+ assertThat (options .getPresencePenalty ()).isEqualTo (0.0 );
195
+ }
196
+
197
+ @ Test
198
+ void testMaximumBoundaryValues () {
199
+ options .setMaxTokens (Integer .MAX_VALUE );
200
+ options .setTemperature (1.0 );
201
+ options .setTopP (1.0 );
202
+ options .setTopK (Integer .MAX_VALUE );
203
+ options .setFrequencyPenalty (1.0 );
204
+ options .setPresencePenalty (1.0 );
205
+
206
+ assertThat (options .getMaxTokens ()).isEqualTo (Integer .MAX_VALUE );
207
+ assertThat (options .getTemperature ()).isEqualTo (1.0 );
208
+ assertThat (options .getTopP ()).isEqualTo (1.0 );
209
+ assertThat (options .getTopK ()).isEqualTo (Integer .MAX_VALUE );
210
+ assertThat (options .getFrequencyPenalty ()).isEqualTo (1.0 );
211
+ assertThat (options .getPresencePenalty ()).isEqualTo (1.0 );
212
+ }
213
+
214
+ @ Test
215
+ void testEmptyCollections () {
216
+ options .setStop (Collections .emptyList ());
217
+ options .setDocuments (Collections .emptyList ());
218
+ options .setTools (Collections .emptyList ());
219
+
220
+ assertThat (options .getStop ()).isEmpty ();
221
+ assertThat (options .getDocuments ()).isEmpty ();
222
+ assertThat (options .getTools ()).isEmpty ();
223
+ }
224
+
225
+ @ Test
226
+ void testMultipleSetterCalls () {
227
+ options .setModel ("first-model" );
228
+ options .setModel ("second-model" );
229
+ options .setMaxTokens (50 );
230
+ options .setMaxTokens (100 );
231
+
232
+ assertThat (options .getModel ()).isEqualTo ("second-model" );
233
+ assertThat (options .getMaxTokens ()).isEqualTo (100 );
234
+ }
235
+
236
+ @ Test
237
+ void testNullSetters () {
238
+ // Set values first
239
+ options .setModel ("test-model" );
240
+ options .setMaxTokens (100 );
241
+ options .setStop (List .of ("test" ));
242
+
243
+ // Then set to null
244
+ options .setModel (null );
245
+ options .setMaxTokens (null );
246
+ options .setStop (null );
247
+
248
+ assertThat (options .getModel ()).isNull ();
249
+ assertThat (options .getMaxTokens ()).isNull ();
250
+ assertThat (options .getStop ()).isNull ();
251
+ }
252
+
133
253
}
0 commit comments