@@ -131,4 +131,63 @@ void mutateAndCloneAreEquivalent() {
131131		assertThat (mutated ).isNotSameAs (cloned );
132132	}
133133
134+ 	@ Test 
135+ 	void  testApiMutateWithComplexHeaders () {
136+ 		LinkedMultiValueMap <String , String > complexHeaders  = new  LinkedMultiValueMap <>();
137+ 		complexHeaders .add ("Authorization" , "Bearer custom-token" );
138+ 		complexHeaders .add ("X-Custom-Header" , "value1" );
139+ 		complexHeaders .add ("X-Custom-Header" , "value2" );
140+ 		complexHeaders .add ("User-Agent" , "Custom-Client/1.0" );
141+ 
142+ 		OpenAiApi  mutatedApi  = this .baseApi .mutate ().headers (complexHeaders ).build ();
143+ 
144+ 		assertThat (mutatedApi .getHeaders ()).containsKey ("Authorization" );
145+ 		assertThat (mutatedApi .getHeaders ()).containsKey ("X-Custom-Header" );
146+ 		assertThat (mutatedApi .getHeaders ()).containsKey ("User-Agent" );
147+ 		assertThat (mutatedApi .getHeaders ().get ("X-Custom-Header" )).hasSize (2 );
148+ 	}
149+ 
150+ 	@ Test 
151+ 	void  testMutateWithEmptyOptions () {
152+ 		OpenAiChatOptions  emptyOptions  = OpenAiChatOptions .builder ().build ();
153+ 
154+ 		OpenAiChatModel  mutated  = this .baseModel .mutate ().defaultOptions (emptyOptions ).build ();
155+ 
156+ 		assertThat (mutated .getDefaultOptions ()).isNotNull ();
157+ 		assertThat (mutated .getDefaultOptions ()).isNotSameAs (this .baseModel .getDefaultOptions ());
158+ 	}
159+ 
160+ 	@ Test 
161+ 	void  testApiMutateWithEmptyHeaders () {
162+ 		LinkedMultiValueMap <String , String > emptyHeaders  = new  LinkedMultiValueMap <>();
163+ 
164+ 		OpenAiApi  mutatedApi  = this .baseApi .mutate ().headers (emptyHeaders ).build ();
165+ 
166+ 		assertThat (mutatedApi .getHeaders ()).isEmpty ();
167+ 	}
168+ 
169+ 	@ Test 
170+ 	void  testCloneAndMutateIndependence () {
171+ 		// Test that clone and mutate produce independent instances 
172+ 		OpenAiChatModel  cloned  = this .baseModel .clone ();
173+ 		OpenAiChatModel  mutated  = this .baseModel .mutate ().build ();
174+ 
175+ 		// Modify cloned instance (if options are mutable) 
176+ 		// This test verifies that operations on one don't affect the other 
177+ 		assertThat (cloned ).isNotSameAs (mutated );
178+ 		assertThat (cloned ).isNotSameAs (this .baseModel );
179+ 		assertThat (mutated ).isNotSameAs (this .baseModel );
180+ 	}
181+ 
182+ 	@ Test 
183+ 	void  testMutateBuilderValidation () {
184+ 		// Test that mutate builder validates inputs appropriately 
185+ 		assertThat (this .baseModel .mutate ()).isNotNull ();
186+ 
187+ 		// Test building without any changes 
188+ 		OpenAiChatModel  unchanged  = this .baseModel .mutate ().build ();
189+ 		assertThat (unchanged ).isNotNull ();
190+ 		assertThat (unchanged ).isNotSameAs (this .baseModel );
191+ 	}
192+ 
134193}
0 commit comments