@@ -196,12 +196,9 @@ void dynamicApiKeyRestClient() throws InterruptedException {
196196
197197 @ Test
198198 void dynamicApiKeyRestClientWithAdditionalApiKeyHeader () throws InterruptedException {
199- AnthropicApi api = AnthropicApi .builder ()
200- .apiKey (() -> {
201- throw new AssertionFailedError ("Should not be called, API key is provided in headers" );
202- })
203- .baseUrl (mockWebServer .url ("/" ).toString ())
204- .build ();
199+ AnthropicApi api = AnthropicApi .builder ().apiKey (() -> {
200+ throw new AssertionFailedError ("Should not be called, API key is provided in headers" );
201+ }).baseUrl (mockWebServer .url ("/" ).toString ()).build ();
205202
206203 MockResponse mockResponse = new MockResponse ().setResponseCode (200 )
207204 .addHeader (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_VALUE )
@@ -231,7 +228,8 @@ void dynamicApiKeyRestClientWithAdditionalApiKeyHeader() throws InterruptedExcep
231228 .build ();
232229 MultiValueMap <String , String > additionalHeaders = new LinkedMultiValueMap <>();
233230 additionalHeaders .add ("x-api-key" , "additional-key" );
234- ResponseEntity <AnthropicApi .ChatCompletionResponse > response = api .chatCompletionEntity (request , additionalHeaders );
231+ ResponseEntity <AnthropicApi .ChatCompletionResponse > response = api .chatCompletionEntity (request ,
232+ additionalHeaders );
235233 assertThat (response .getStatusCode ()).isEqualTo (HttpStatus .OK );
236234 RecordedRequest recordedRequest = mockWebServer .takeRequest ();
237235 assertThat (recordedRequest .getHeader (HttpHeaders .AUTHORIZATION )).isNull ();
@@ -248,8 +246,7 @@ void dynamicApiKeyWebClient() throws InterruptedException {
248246
249247 MockResponse mockResponse = new MockResponse ().setResponseCode (200 )
250248 .addHeader (HttpHeaders .CONTENT_TYPE , MediaType .TEXT_EVENT_STREAM_VALUE )
251- .setBody (
252- """
249+ .setBody ("""
253250 {
254251 "type": "message_start",
255252 "message": {
@@ -278,9 +275,7 @@ void dynamicApiKeyWebClient() throws InterruptedException {
278275 .messages (List .of (chatCompletionMessage ))
279276 .stream (true )
280277 .build ();
281- api .chatCompletionStream (request )
282- .collectList ()
283- .block ();
278+ api .chatCompletionStream (request ).collectList ().block ();
284279 RecordedRequest recordedRequest = mockWebServer .takeRequest ();
285280 assertThat (recordedRequest .getHeader (HttpHeaders .AUTHORIZATION )).isNull ();
286281 assertThat (recordedRequest .getHeader ("x-api-key" )).isEqualTo ("key1" );
@@ -301,26 +296,25 @@ void dynamicApiKeyWebClientWithAdditionalApiKey() throws InterruptedException {
301296 .build ();
302297
303298 MockResponse mockResponse = new MockResponse ().setResponseCode (200 )
304- .addHeader (HttpHeaders .CONTENT_TYPE , MediaType .TEXT_EVENT_STREAM_VALUE )
305- .setBody (
306- """
307- {
308- "type": "message_start",
309- "message": {
310- "id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY",
311- "type": "message",
312- "role": "assistant",
313- "content": [],
314- "model": "claude-opus-4-20250514",
315- "stop_reason": null,
316- "stop_sequence": null,
317- "usage": {
318- "input_tokens": 25,
319- "output_tokens": 1
320- }
299+ .addHeader (HttpHeaders .CONTENT_TYPE , MediaType .TEXT_EVENT_STREAM_VALUE )
300+ .setBody ("""
301+ {
302+ "type": "message_start",
303+ "message": {
304+ "id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY",
305+ "type": "message",
306+ "role": "assistant",
307+ "content": [],
308+ "model": "claude-opus-4-20250514",
309+ "stop_reason": null,
310+ "stop_sequence": null,
311+ "usage": {
312+ "input_tokens": 25,
313+ "output_tokens": 1
321314 }
322315 }
323- """ .replace ("\n " , "" ));
316+ }
317+ """ .replace ("\n " , "" ));
324318 mockWebServer .enqueue (mockResponse );
325319
326320 AnthropicApi .AnthropicMessage chatCompletionMessage = new AnthropicApi .AnthropicMessage (
@@ -334,9 +328,7 @@ void dynamicApiKeyWebClientWithAdditionalApiKey() throws InterruptedException {
334328 MultiValueMap <String , String > additionalHeaders = new LinkedMultiValueMap <>();
335329 additionalHeaders .add ("x-api-key" , "additional-key" );
336330
337- api .chatCompletionStream (request , additionalHeaders )
338- .collectList ()
339- .block ();
331+ api .chatCompletionStream (request , additionalHeaders ).collectList ().block ();
340332 RecordedRequest recordedRequest = mockWebServer .takeRequest ();
341333 assertThat (recordedRequest .getHeader (HttpHeaders .AUTHORIZATION )).isNull ();
342334 assertThat (recordedRequest .getHeader ("x-api-key" )).isEqualTo ("additional-key" );
0 commit comments