You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/12/10 02:30:14 UTC

[james-project] 11/27: [Refactoring] More self described test in MessageFastViewProjectionContract

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

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

commit 7c3b95f58fc7713bd3c0fdc1f4166ebb75d949a1
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Fri Dec 6 15:44:16 2019 +0700

    [Refactoring] More self described test in MessageFastViewProjectionContract
    
    By less mathematics involved
---
 .../MessageFastViewProjectionContract.java            | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionContract.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionContract.java
index 1e5fa66..f57ff23 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionContract.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/projections/MessageFastViewProjectionContract.java
@@ -234,27 +234,26 @@ public interface MessageFastViewProjectionContract {
     }
 
     @Test
-    default void storeShouldBeConsistentUponSingleKeyOperation() throws Exception {
+    default void storeShouldReturnAnyLatestPreviewOnConcurrentUpdate() throws Exception {
         MessageId messageId = newMessageId();
-        int threadCount = 10;
-        int operationCount = 100;
 
         ConcurrentTestRunner.builder()
             .reactorOperation((thread, step) -> testee()
                 .store(messageId, MessageFastViewPrecomputedProperties.builder()
-                    .preview(Preview.from(String.valueOf(step * threadCount + thread)))
+                    .preview(Preview.from(thread + "-" + step))
                     .hasAttachment()
                     .build()))
-            .threadCount(threadCount)
-            .operationCount(operationCount)
+            .threadCount(10)
+            .operationCount(100)
             .runSuccessfullyWithin(Duration.ofMinutes(1));
 
-        MessageFastViewPrecomputedProperties preview = Mono.from(testee().retrieve(messageId)).block();
-        Integer previewAsInt = Integer.valueOf(preview.getPreview().getValue());
+        String previewAsString = Mono.from(testee().retrieve(messageId)).block()
+            .getPreview()
+            .getValue();
 
-        assertThat(previewAsInt)
+        assertThat(previewAsString)
             .describedAs("Ensure the stored result was generated by the last operation of one of the threads")
-            .isBetween(threadCount * (operationCount - 1), threadCount * operationCount);
+            .isIn("0-99", "1-99", "2-99", "3-99", "4-99", "5-99", "6-99", "7-99", "8-99", "9-99");
     }
 
     @Test


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