james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [8/9] james-project git commit: JAMES-2544 Replace assertAll by assertSoftly
Date Tue, 02 Oct 2018 02:57:10 GMT
JAMES-2544 Replace assertAll by assertSoftly


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2d6d67f5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2d6d67f5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2d6d67f5

Branch: refs/heads/master
Commit: 2d6d67f583e7d2350fc2520509c6e70c027b0d29
Parents: 8073483
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Fri Sep 28 10:47:07 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Oct 2 09:20:43 2018 +0700

----------------------------------------------------------------------
 .../mailrepository/MailRepositoryContract.java  | 27 ++++++------
 .../CassandraMailRepositoryMailDAOTest.java     | 44 ++++++++++----------
 .../view/cassandra/EnqueuedMailsDaoTest.java    | 15 +++----
 3 files changed, 45 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/2d6d67f5/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
index fd7d997..6384798 100644
--- a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
@@ -20,7 +20,7 @@
 package org.apache.james.mailrepository;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.assertj.core.api.SoftAssertions.assertSoftly;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Date;
@@ -33,6 +33,7 @@ import java.util.stream.IntStream;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
+import com.github.fge.lambdas.Throwing;
 import org.apache.james.core.MailAddress;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.mailrepository.api.MailKey;
@@ -85,18 +86,18 @@ public interface MailRepositoryContract {
     }
 
     default void checkMailEquality(Mail actual, Mail expected) {
-        assertAll(
-            () -> assertThat(actual.getMessage().getContent()).isEqualTo(expected.getMessage().getContent()),
-            () -> assertThat(actual.getMessageSize()).isEqualTo(expected.getMessageSize()),
-            () -> assertThat(actual.getName()).isEqualTo(expected.getName()),
-            () -> assertThat(actual.getState()).isEqualTo(expected.getState()),
-            () -> assertThat(actual.getAttribute(TEST_ATTRIBUTE)).isEqualTo(expected.getAttribute(TEST_ATTRIBUTE)),
-            () -> assertThat(actual.getErrorMessage()).isEqualTo(expected.getErrorMessage()),
-            () -> assertThat(actual.getRemoteHost()).isEqualTo(expected.getRemoteHost()),
-            () -> assertThat(actual.getRemoteAddr()).isEqualTo(expected.getRemoteAddr()),
-            () -> assertThat(actual.getLastUpdated()).isEqualTo(expected.getLastUpdated()),
-            () -> assertThat(actual.getPerRecipientSpecificHeaders()).isEqualTo(expected.getPerRecipientSpecificHeaders())
-        );
+        assertSoftly(Throwing.consumer(softly -> {
+            softly.assertThat(actual.getMessage().getContent()).isEqualTo(expected.getMessage().getContent());
+            softly.assertThat(actual.getMessageSize()).isEqualTo(expected.getMessageSize());
+            softly.assertThat(actual.getName()).isEqualTo(expected.getName());
+            softly.assertThat(actual.getState()).isEqualTo(expected.getState());
+            softly.assertThat(actual.getAttribute(TEST_ATTRIBUTE)).isEqualTo(expected.getAttribute(TEST_ATTRIBUTE));
+            softly.assertThat(actual.getErrorMessage()).isEqualTo(expected.getErrorMessage());
+            softly.assertThat(actual.getRemoteHost()).isEqualTo(expected.getRemoteHost());
+            softly.assertThat(actual.getRemoteAddr()).isEqualTo(expected.getRemoteAddr());
+            softly.assertThat(actual.getLastUpdated()).isEqualTo(expected.getLastUpdated());
+            softly.assertThat(actual.getPerRecipientSpecificHeaders()).isEqualTo(expected.getPerRecipientSpecificHeaders());
+        }));
     }
 
     MailRepository retrieveRepository() throws Exception;

http://git-wip-us.apache.org/repos/asf/james-project/blob/2d6d67f5/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
index 55aa601..7d62d4c 100644
--- a/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
+++ b/server/mailrepository/mailrepository-cassandra/src/test/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAOTest.java
@@ -20,7 +20,7 @@
 package org.apache.james.mailrepository.cassandra;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.assertj.core.api.SoftAssertions.assertSoftly;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.CassandraClusterExtension;
@@ -90,22 +90,23 @@ class CassandraMailRepositoryMailDAOTest {
         CassandraMailRepositoryMailDAO.MailDTO mailDTO = testee.read(URL, KEY_1).join().get();
 
         Mail partialMail = mailDTO.getMailBuilder().build();
-        assertAll(
-            () -> assertThat(mailDTO.getBodyBlobId()).isEqualTo(blobIdBody),
-            () -> assertThat(mailDTO.getHeaderBlobId()).isEqualTo(blobIdHeader),
-            () -> assertThat(partialMail.getName()).isEqualTo(KEY_1.asString()),
-            () -> assertThat(partialMail.getErrorMessage()).isEqualTo(errorMessage),
-            () -> assertThat(partialMail.getState()).isEqualTo(state),
-            () -> assertThat(partialMail.getRemoteAddr()).isEqualTo(remoteAddr),
-            () -> assertThat(partialMail.getRemoteHost()).isEqualTo(remoteHost),
-            () -> assertThat(partialMail.getAttributeNames()).containsOnly(attributeName),
-            () -> assertThat(partialMail.getAttribute(attributeName)).isEqualTo(attributeValue),
-            () -> assertThat(partialMail.getPerRecipientSpecificHeaders().getRecipientsWithSpecificHeaders())
-                .containsOnly(MailAddressFixture.RECIPIENT1),
-            () -> assertThat(partialMail.getPerRecipientSpecificHeaders().getHeadersForRecipient(MailAddressFixture.RECIPIENT1))
-                .containsOnly(header),
-            () -> assertThat(partialMail.getSender()).isEqualTo(MailAddressFixture.SENDER),
-            () -> assertThat(partialMail.getRecipients()).containsOnly(MailAddressFixture.RECIPIENT1,
MailAddressFixture.RECIPIENT2));
+        assertSoftly(softly -> {
+            softly.assertThat(mailDTO.getBodyBlobId()).isEqualTo(blobIdBody);
+            softly.assertThat(mailDTO.getHeaderBlobId()).isEqualTo(blobIdHeader);
+            softly.assertThat(partialMail.getName()).isEqualTo(KEY_1.asString());
+            softly.assertThat(partialMail.getErrorMessage()).isEqualTo(errorMessage);
+            softly.assertThat(partialMail.getState()).isEqualTo(state);
+            softly.assertThat(partialMail.getRemoteAddr()).isEqualTo(remoteAddr);
+            softly.assertThat(partialMail.getRemoteHost()).isEqualTo(remoteHost);
+            softly.assertThat(partialMail.getAttributeNames()).containsOnly(attributeName);
+            softly.assertThat(partialMail.getAttribute(attributeName)).isEqualTo(attributeValue);
+            softly.assertThat(partialMail.getPerRecipientSpecificHeaders().getRecipientsWithSpecificHeaders())
+                    .containsOnly(MailAddressFixture.RECIPIENT1);
+            softly.assertThat(partialMail.getPerRecipientSpecificHeaders().getHeadersForRecipient(MailAddressFixture.RECIPIENT1))
+                    .containsOnly(header);
+            softly.assertThat(partialMail.getSender()).isEqualTo(MailAddressFixture.SENDER);
+            softly.assertThat(partialMail.getRecipients()).containsOnly(MailAddressFixture.RECIPIENT1,
MailAddressFixture.RECIPIENT2);
+        });
     }
 
     @Test
@@ -124,10 +125,11 @@ class CassandraMailRepositoryMailDAOTest {
         CassandraMailRepositoryMailDAO.MailDTO mailDTO = testee.read(URL, KEY_1).join().get();
 
         Mail partialMail = mailDTO.getMailBuilder().build();
-        assertAll(
-            () -> assertThat(mailDTO.getBodyBlobId()).isEqualTo(blobIdBody),
-            () -> assertThat(mailDTO.getHeaderBlobId()).isEqualTo(blobIdHeader),
-            () -> assertThat(partialMail.getName()).isEqualTo(KEY_1.asString()));
+        assertSoftly(softly -> {
+            softly.assertThat(mailDTO.getBodyBlobId()).isEqualTo(blobIdBody);
+            softly.assertThat(mailDTO.getHeaderBlobId()).isEqualTo(blobIdHeader);
+            softly.assertThat(partialMail.getName()).isEqualTo(KEY_1.asString());
+        });
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/2d6d67f5/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
index f649a48..580ba9f 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/view/cassandra/EnqueuedMailsDaoTest.java
@@ -22,6 +22,7 @@ package org.apache.james.queue.rabbitmq.view.cassandra;
 import static org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.BucketId;
 import static org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.Slice;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.SoftAssertions.assertSoftly;
 
 import java.time.Instant;
 import java.util.stream.Stream;
@@ -113,13 +114,13 @@ class EnqueuedMailsDaoTest {
         assertThat(selectedEnqueuedMails)
             .hasSize(1)
             .hasOnlyOneElementSatisfying(selectedEnqueuedMail -> {
-                SoftAssertions softly = new SoftAssertions();
-                softly.assertThat(selectedEnqueuedMail.getMailQueueName()).isEqualTo(OUT_GOING_1);
-                softly.assertThat(selectedEnqueuedMail.getBucketId()).isEqualTo(BUCKET_ID);
-                softly.assertThat(selectedEnqueuedMail.getTimeRangeStart()).isEqualTo(NOW);
-                softly.assertThat(selectedEnqueuedMail.getEnqueuedTime()).isEqualTo(NOW);
-                softly.assertThat(selectedEnqueuedMail.getMailKey()).isEqualTo(MAIL_KEY_1);
-                softly.assertAll();
+                assertSoftly(softly -> {
+                    softly.assertThat(selectedEnqueuedMail.getMailQueueName()).isEqualTo(OUT_GOING_1);
+                    softly.assertThat(selectedEnqueuedMail.getBucketId()).isEqualTo(BUCKET_ID);
+                    softly.assertThat(selectedEnqueuedMail.getTimeRangeStart()).isEqualTo(NOW);
+                    softly.assertThat(selectedEnqueuedMail.getEnqueuedTime()).isEqualTo(NOW);
+                    softly.assertThat(selectedEnqueuedMail.getMailKey()).isEqualTo(MAIL_KEY_1);
+                });
             });
     }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message