1616
1717package org .springframework .ai .oci .cohere ;
1818
19+ import java .util .Collections ;
1920import java .util .List ;
2021import java .util .Map ;
2122
2223import com .oracle .bmc .generativeaiinference .model .CohereTool ;
2324import org .junit .jupiter .api .Test ;
25+ import org .junit .jupiter .api .BeforeEach ;
2426
2527import static org .assertj .core .api .Assertions .assertThat ;
2628
3133 */
3234class OCICohereChatOptionsTests {
3335
36+ private OCICohereChatOptions options ;
37+
38+ @ BeforeEach
39+ void setUp () {
40+ options = new OCICohereChatOptions ();
41+ }
42+
3443 @ Test
3544 void testBuilderWithAllFields () {
3645 OCICohereChatOptions options = OCICohereChatOptions .builder ()
@@ -55,6 +64,34 @@ void testBuilderWithAllFields() {
5564 0.6 , 50 , List .of ("test" ), 0.5 , 0.5 , List .of ("doc1" , "doc2" ));
5665 }
5766
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+
5895 @ Test
5996 void testCopy () {
6097 OCICohereChatOptions original = OCICohereChatOptions .builder ()
@@ -82,9 +119,20 @@ void testCopy() {
82119 assertThat (copied .getTools ()).isNotSameAs (original .getTools ());
83120 }
84121
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+
85134 @ Test
86135 void testSetters () {
87- OCICohereChatOptions options = new OCICohereChatOptions ();
88136 options .setModel ("test-model" );
89137 options .setMaxTokens (10 );
90138 options .setCompartment ("test-compartment" );
@@ -114,7 +162,6 @@ void testSetters() {
114162
115163 @ Test
116164 void testDefaultValues () {
117- OCICohereChatOptions options = new OCICohereChatOptions ();
118165 assertThat (options .getModel ()).isNull ();
119166 assertThat (options .getMaxTokens ()).isNull ();
120167 assertThat (options .getCompartment ()).isNull ();
@@ -130,4 +177,77 @@ void testDefaultValues() {
130177 assertThat (options .getTools ()).isNull ();
131178 }
132179
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+
133253}
0 commit comments