diff --git a/pdf-umbenenner-adapter-out/src/test/java/de/gecheckt/pdf/umbenenner/adapter/out/ai/AnthropicClaudeAdapterIntegrationTest.java b/pdf-umbenenner-adapter-out/src/test/java/de/gecheckt/pdf/umbenenner/adapter/out/ai/AnthropicClaudeAdapterIntegrationTest.java index d122881..e143001 100644 --- a/pdf-umbenenner-adapter-out/src/test/java/de/gecheckt/pdf/umbenenner/adapter/out/ai/AnthropicClaudeAdapterIntegrationTest.java +++ b/pdf-umbenenner-adapter-out/src/test/java/de/gecheckt/pdf/umbenenner/adapter/out/ai/AnthropicClaudeAdapterIntegrationTest.java @@ -115,9 +115,7 @@ class AnthropicClaudeAdapterIntegrationTest { + "\"stop_reason\":\"end_turn\"" + "}"; - HttpResponse mockHttpResponse = mock(HttpResponse.class); - when(mockHttpResponse.statusCode()).thenReturn(200); - when(mockHttpResponse.body()).thenReturn(anthropicResponseBody); + HttpResponse mockHttpResponse = mockStringResponse(200, anthropicResponseBody); doReturn(mockHttpResponse).when(mockHttpClient).send(any(HttpRequest.class), any()); // --- Create the Claude adapter with the mocked HTTP client --- @@ -178,6 +176,19 @@ class AnthropicClaudeAdapterIntegrationTest { // Helpers // ========================================================================= + /** + * Creates a typed mock {@link HttpResponse} to avoid unchecked-cast warnings at call sites. + * The suppression is confined to this helper because the raw-type cast is technically + * unavoidable due to type erasure when mocking generic interfaces. + */ + @SuppressWarnings("unchecked") + private static HttpResponse mockStringResponse(int statusCode, String body) { + HttpResponse response = (HttpResponse) mock(HttpResponse.class); + when(response.statusCode()).thenReturn(statusCode); + when(response.body()).thenReturn(body); + return response; + } + /** * Creates a single-page searchable PDF with embedded text using PDFBox. */