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

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7ce02483a4fe3eece4d8ad6e33e35af548639376
Author: RĂ©mi KOWALSKI <rkowal...@linagora.com>
AuthorDate: Wed Dec 4 16:53:52 2019 +0100

    [refactoring] use untilAsserted in place of until in 
EventBusConcurrentTestContract
---
 .../events/EventBusConcurrentTestContract.java     | 39 +++++++++++-----------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusConcurrentTestContract.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusConcurrentTestContract.java
index 5f08968..99b64c1 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusConcurrentTestContract.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusConcurrentTestContract.java
@@ -25,6 +25,7 @@ import static 
org.apache.james.mailbox.events.EventBusTestFixture.KEY_2;
 import static org.apache.james.mailbox.events.EventBusTestFixture.KEY_3;
 import static org.apache.james.mailbox.events.EventBusTestFixture.NO_KEYS;
 import static org.apache.james.mailbox.events.EventDeadLettersContract.GROUP_A;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.awaitility.Awaitility.await;
 
 import java.time.Duration;
@@ -55,7 +56,7 @@ public interface EventBusConcurrentTestContract {
 
     static int 
totalEventsReceived(ImmutableList<EventBusTestFixture.MailboxListenerCountingSuccessfulExecution>
 allListeners) {
         return allListeners.stream()
-            .mapToInt(listener -> listener.numberOfEventCalls())
+            
.mapToInt(EventBusTestFixture.MailboxListenerCountingSuccessfulExecution::numberOfEventCalls)
             .sum();
     }
 
@@ -78,9 +79,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalGlobalRegistrations * TOTAL_DISPATCH_OPERATIONS));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalGlobalRegistrations * 
TOTAL_DISPATCH_OPERATIONS));
         }
 
         @Test
@@ -101,9 +102,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalKeyListenerRegistrations * totalEventBus * 
TOTAL_DISPATCH_OPERATIONS));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalKeyListenerRegistrations * totalEventBus * 
TOTAL_DISPATCH_OPERATIONS));
         }
 
         @Test
@@ -131,9 +132,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalEventDeliveredGlobally + 
totalEventDeliveredByKeys));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalEventDeliveredGlobally + 
totalEventDeliveredByKeys));
         }
     }
 
@@ -163,9 +164,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalGlobalRegistrations * TOTAL_DISPATCH_OPERATIONS));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalGlobalRegistrations * 
TOTAL_DISPATCH_OPERATIONS));
         }
 
         @Test
@@ -191,9 +192,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalKeyListenerRegistrations * totalEventBus * 
TOTAL_DISPATCH_OPERATIONS));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalKeyListenerRegistrations * totalEventBus * 
TOTAL_DISPATCH_OPERATIONS));
         }
 
         @Test
@@ -227,9 +228,9 @@ public interface EventBusConcurrentTestContract {
                 .operationCount(OPERATION_COUNT)
                 .runSuccessfullyWithin(FIVE_SECONDS);
 
-            AWAIT_CONDITION.until(() ->
-                totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3))
-                    == (totalEventDeliveredGlobally + 
totalEventDeliveredByKeys));
+            AWAIT_CONDITION.untilAsserted(() ->
+                
assertThat(totalEventsReceived(ImmutableList.of(countingListener1, 
countingListener2, countingListener3)))
+                    .isEqualTo(totalEventDeliveredGlobally + 
totalEventDeliveredByKeys));
         }
     }
 }


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

Reply via email to