You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/21 14:48:27 UTC

[camel] branch main updated: Refactor assertTrue(!) with assertFalse & Add explanatory messages (#11156)

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

orpiske 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 9ab43ac33eb Refactor assertTrue(!) with assertFalse & Add explanatory messages (#11156)
9ab43ac33eb is described below

commit 9ab43ac33eb5b01f11017d1de6be414b2f97b415
Author: Taher Ghaleb <ta...@gmail.com>
AuthorDate: Mon Aug 21 10:48:20 2023 -0400

    Refactor assertTrue(!) with assertFalse & Add explanatory messages (#11156)
    
    * Refactor assertTrue(!) with assertFalse & Add explanatory messages
    
    * Reorder assert message parameter
---
 .../apache/camel/component/mail/RawMailMessageTest.java  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
index 51cac5e2dc3..58f4b7bd968 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/RawMailMessageTest.java
@@ -38,7 +38,7 @@ import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 /**
  * Unit test for Mail using camel headers to set recipient subject.
@@ -84,7 +84,7 @@ public class RawMailMessageTest extends CamelTestSupport {
         // START SNIPPET: e1
         // get access to the raw jakarta.mail.Message as shown below
         Message javaMailMessage = exchange.getIn(MailMessage.class).getMessage();
-        assertNotNull(javaMailMessage);
+        assertNotNull(javaMailMessage, "The mail message should not be null");
 
         assertEquals("Camel rocks", javaMailMessage.getSubject());
         // END SNIPPET: e1
@@ -102,7 +102,7 @@ public class RawMailMessageTest extends CamelTestSupport {
 
     private void testRawMessageConsumer(String type, MailboxUser user) throws Exception {
         Mailbox mailboxRaw = user.getInbox();
-        assertEquals(1, mailboxRaw.getMessageCount());
+        assertEquals(1, mailboxRaw.getMessageCount(), "expected 1 message in the mailbox");
 
         MockEndpoint mock = getMockEndpoint("mock://rawMessage" + type);
         mock.expectedMessageCount(1);
@@ -115,8 +115,8 @@ public class RawMailMessageTest extends CamelTestSupport {
         assertEquals("hurz", mailMessage.getSubject(), "mail subject should be hurz");
 
         Map<String, Object> headers = mock.getExchanges().get(0).getIn().getHeaders();
-        assertNotNull(headers);
-        assertTrue(!headers.isEmpty());
+        assertNotNull(headers, "headers should not be null");
+        assertFalse(headers.isEmpty(), "headers should not be empty");
     }
 
     @Test
@@ -131,7 +131,7 @@ public class RawMailMessageTest extends CamelTestSupport {
 
     private void testNormalMessageConsumer(String type, MailboxUser user) throws Exception {
         Mailbox mailbox = user.getInbox();
-        assertEquals(1, mailbox.getMessageCount());
+        assertEquals(1, mailbox.getMessageCount(), "expected 1 message in the mailbox");
 
         MockEndpoint mock = getMockEndpoint("mock://normalMessage" + type);
         mock.expectedMessageCount(1);
@@ -145,8 +145,8 @@ public class RawMailMessageTest extends CamelTestSupport {
         assertNull(subject, "mail subject should not be available");
 
         Map<String, Object> headers = mock.getExchanges().get(0).getIn().getHeaders();
-        assertNotNull(headers);
-        assertTrue(!headers.isEmpty());
+        assertNotNull(headers, "headers should not be null");
+        assertFalse(headers.isEmpty(), "headers should not be empty");
     }
 
     private void prepareMailbox(MailboxUser user) throws Exception {