This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 71fa9ce96bf9 Improve assertions
71fa9ce96bf9 is described below

commit 71fa9ce96bf9e0d7da201eb06fabc47ef4c02a5e
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Fri Jul 31 14:20:06 2026 +0200

    Improve assertions
    
    initially looking to rule "Add an assertion predicate after calling this
    method." 
https://sonarcloud.io/project/issues?impactSeverities=MEDIUM&impactSoftwareQualities=RELIABILITY&rules=java%3AS5833&issueStatuses=OPEN%2CCONFIRMED&id=apache_camel
    
    I improved the 2 incriminated files to get rid of all Sonar issue
    reports
    
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../LangChain4jAgentWithMemoryServiceTest.java     | 11 ++++----
 .../springai/chat/SpringAiChatOllamaIT.java        | 33 +++++++++++-----------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git 
a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java
 
b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java
index 46a01bd0ea34..d98bebe4a72a 100644
--- 
a/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java
+++ 
b/components/camel-ai/camel-langchain4j-agent/src/test/java/org/apache/camel/component/langchain4j/agent/LangChain4jAgentWithMemoryServiceTest.java
@@ -72,7 +72,7 @@ public class LangChain4jAgentWithMemoryServiceTest extends 
BaseLangChain4jAgent
     }
 
     @Test
-    public void testToolThenMemoryThenAnotherTool() throws Exception {
+    void testToolThenMemoryThenAnotherTool() throws Exception {
         MockEndpoint mockEndpoint = 
this.context.getEndpoint("mock:agent-response", MockEndpoint.class);
         mockEndpoint.expectedMessageCount(3);
 
@@ -87,10 +87,11 @@ public class LangChain4jAgentWithMemoryServiceTest extends 
BaseLangChain4jAgent
                 String.class);
 
         assertNotNull(firstResponse, "First response should not be null");
-        Assertions.assertThat(firstResponse).contains("John Smith", "Gold")
-                .withFailMessage("Response should contain user information 
from tools");
-        Assertions.assertThat(firstResponse).contains("21", "age", "rental")
-                .withFailMessage("Response should contain rental policy 
information from RAG");
+        Assertions.assertThat(firstResponse)
+                .withFailMessage("Response should contain user information 
from tools")
+                .contains("John Smith", "Gold")
+                .withFailMessage("Response should contain rental policy 
information from RAG")
+                .contains("21", "age", "rental");
 
         // Second interaction: Follow-up question
         AiAgentBody<?> secondRequest = new AiAgentBody<>(
diff --git 
a/components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatOllamaIT.java
 
b/components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatOllamaIT.java
index 920c3b2397ea..950efcd10448 100644
--- 
a/components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatOllamaIT.java
+++ 
b/components/camel-spring-parent/camel-spring-ai/camel-spring-ai-chat/src/test/java/org/apache/camel/component/springai/chat/SpringAiChatOllamaIT.java
@@ -26,28 +26,29 @@ import static org.assertj.core.api.Assertions.assertThat;
  * Integration test for Spring AI Chat component using Ollama.
  */
 @DisabledIfSystemProperty(named = "ci.env.name", matches = ".*", 
disabledReason = "Disabled unless running in CI")
-public class SpringAiChatOllamaIT extends OllamaTestSupport {
+class SpringAiChatOllamaIT extends OllamaTestSupport {
 
     @Test
-    public void testSimpleChatWithOllama() {
+    void testSimpleChatWithOllama() {
         String response
                 = template.requestBody("direct:chat", "What is the capital of 
Italy? Answer in one word.", String.class);
 
-        assertThat(response).isNotNull();
-        assertThat(response).isNotEmpty();
-        assertThat(response.toLowerCase()).contains("rome")
-                .as("Expected to contain rome but was " + 
response.toLowerCase());
+        assertThat(response)
+                .isNotNull()
+                .isNotEmpty()
+                .containsIgnoringCase("rome");
     }
 
     @Test
-    public void testChatWithTokenUsageHeaders() {
+    void testChatWithTokenUsageHeaders() {
         var exchange = template.request("direct:chat", e -> {
             e.getIn().setBody("Say 'hello' in one word");
         });
 
         String response = exchange.getMessage().getBody(String.class);
-        assertThat(response).isNotNull();
-        assertThat(response).isNotEmpty();
+        assertThat(response)
+                .isNotNull()
+                .isNotEmpty();
 
         // Verify token usage headers are set
         Integer inputTokens = 
exchange.getMessage().getHeader(SpringAiChatConstants.INPUT_TOKEN_COUNT, 
Integer.class);
@@ -56,23 +57,21 @@ public class SpringAiChatOllamaIT extends OllamaTestSupport 
{
 
         assertThat(inputTokens).isNotNull();
         assertThat(outputTokens).isNotNull();
-        assertThat(totalTokens).isNotNull();
-        assertThat(totalTokens).isEqualTo(inputTokens + outputTokens);
+        assertThat(totalTokens).isNotNull().isEqualTo(inputTokens + 
outputTokens);
     }
 
     @Test
-    public void testMultipleChatRequests() {
+    void testMultipleChatRequests() {
         String response1 = template.requestBody("direct:chat", "What is 2+2? 
Answer with just the number.", String.class);
         String response2
                 = template.requestBody("direct:chat", "What is the color of 
the sky? Answer in one word.", String.class);
 
-        assertThat(response1).isNotNull();
-        assertThat(response1).contains("4")
-                .as("Expected to contain 4 " + response1);
+        assertThat(response1)
+                .isNotNull()
+                .contains("4");
 
         assertThat(response2).isNotNull();
-        assertThat(response2.toLowerCase()).containsAnyOf("blue", "azure")
-                .as("Expected to contain any of blue or azure, but was " + 
response2);
+        assertThat(response2.toLowerCase()).containsAnyOf("blue", "azure");
     }
 
     @Override

Reply via email to