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 rc...@apache.org on 2019/12/09 03:09:25 UTC

[james-project] branch master updated (e9e97e0 -> 8ae9166)

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

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


    from e9e97e0  JAMES-3000 bump scala version to 2.13.1
     new 3bdff20  [Refactoring] Remove MailboxManager::logout(session, force)
     new 4800262  [Refactoring] Move MailboxAnnotationListenerTest to JUnit 5
     new b7dbec9  [Refactoring] Move DefaultTextExtractorTest to JUnit 5
     new cb4bcdd  [Refactoring] Move JsoupTextExtractorTest to JUnit 5
     new 23de340  [Refactoring] Move MailboxACLJsonConverterTest to JUnit 5
     new b5a6943  [Refactoring] Move MessageParserTest to JUnit 5
     new 644c75e  [Refactoring] Move PropertyBuilderTest to JUnit 5
     new 74fd6c1  [Refactoring] Move SimpleMailboxMessageTest to JUnit 5
     new 7051baf  [Refactoring] Move DefaultMessageIdTest to JUnit 5
     new b4f70be  [Refactoring] Move DelegatingMailboxMessageTest to JUnit 5
     new 60489d8  [Refactoring] Move FlagsFactoryTest to JUnit 5
     new deec3a0  [Refactoring] Move FlagsFilterTest to JUnit 5
     new 78952e1  [Refactoring] Move ListMailboxAssertTest to JUnit 5
     new b3a7434  [Refactoring] Move ListMessageAssertTest to JUnit 5
     new 96d7a6a  [Refactoring] Move ListMessagePropertiesAssert to JUnit 5
     new de884ed  [Refactoring] Move MailboxMessageAssertTest to JUnit 5
     new 7f10047  [Refactoring] Move MessageUidProviderTest to JUnit 5
     new 533c63c  [Refactoring] Move MetadataMapAssertTest to JUnit 5
     new 7289cc6  [Refactoring] Move ApplicableFlagCalculatorTest to JUnit 5
     new 07b742d  [Refactoring] Move DefaultUserQuotaRootResolverTest to JUnit 5
     new 90fd154  [Refactoring] Move ListeningCurrentQuotaUpdaterTest to JUnit 5
     new 42fdad9  [Refactoring] Move QuotaCheckerTest to JUnit 5
     new dc182f0  [Refactoring] Move StoreQuotaManagerTest to JUnit 5
     new 23cc15e  [Refactoring] Move SentDateComparatorTest to JUnit 5
     new 93216f2  [Refactoring] Move CombinedComparatorTest to JUnit 5
     new 77df56c  [Refactoring] Move SearchUtilTest to JUnit 5
     new de2ca97  [Refactoring] Move BatchSizesTest to JUnit 5
     new 52640e0  [Refactoring] Move FlagsUpdateCalculatorTest to JUnit 5
     new d205631  [Refactoring] Move MailboxMessageResultImplTest to JUnit 5
     new 4d2045b  [Refactoring] Move MessageBatcherTest to JUnit 5
     new f71a854  [Refactoring] Move PartContentBuilderComplexMultipartTest to JUnit 5
     new a11449d  [Refactoring] Move PartContentBuilderMultipartAlternativeTest to JUnit 5
     new e22f732  [Refactoring] Move SearchUtilsMultipartMixedTest to JUnit 5
     new d3621ca  [Refactoring] Move SearchUtilsRFC822Test to JUnit 5
     new 86903bc  [Refactoring] Move SearchUtilsTest to JUnit 5
     new 723fac3  [Refactoring] Move StoreAttachmentManagerTest to JUnit 5
     new 73a9151  [Refactoring] Move StoreBlobManagerTest to JUnit 5
     new 013deb5  [Refactoring] Move StoreMailboxManagerAnnotationTest to JUnit 5
     new 45d161c  [Refactoring] Move StoreMailboxManagerTest to JUnit 5
     new 9e5dc61  [Refactoring] Move StoreMailboxMessageResultIteratorTest to JUnit 5
     new bddcd4c  [Refactoring] Move StoreRightManagerTest to JUnit 5
     new 8ae9166  [Refactoring] Move SystemMailboxesProviderImplTest to JUnit 5

The 42 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/james/mailbox/MailboxManager.java   |  28 --
 .../mailbox/MailboxManagerStressContract.java      |   4 +-
 .../apache/james/mailbox/MailboxManagerTest.java   |   8 +-
 .../apache/james/mailbox/mock/DataProvisioner.java |   8 +-
 .../apache/james/mailbox/store/BatchSizesTest.java | 148 +++++------
 .../mailbox/store/FlagsUpdateCalculatorTest.java   |  14 +-
 .../store/MailboxMessageResultImplTest.java        |  34 +--
 .../james/mailbox/store/MessageBatcherTest.java    |  31 ++-
 .../PartContentBuilderComplexMultipartTest.java    |  64 ++---
 ...PartContentBuilderMultipartAlternativeTest.java |  38 +--
 .../store/SearchUtilsMultipartMixedTest.java       |  42 +--
 .../james/mailbox/store/SearchUtilsRFC822Test.java |  34 +--
 .../james/mailbox/store/SearchUtilsTest.java       | 124 ++++-----
 .../mailbox/store/StoreAttachmentManagerTest.java  |  26 +-
 .../james/mailbox/store/StoreBlobManagerTest.java  |  60 ++---
 .../store/StoreMailboxManagerAnnotationTest.java   |  78 +++---
 .../mailbox/store/StoreMailboxManagerTest.java     | 116 +++++----
 .../StoreMailboxMessageResultIteratorTest.java     |  21 +-
 .../james/mailbox/store/StoreRightManagerTest.java |  70 ++---
 .../store/SystemMailboxesProviderImplTest.java     |  27 +-
 .../store/event/MailboxAnnotationListenerTest.java |  51 ++--
 .../store/extractor/DefaultTextExtractorTest.java  |  16 +-
 .../store/extractor/JsoupTextExtractorTest.java    |  22 +-
 .../store/json/MailboxACLJsonConverterTest.java    |  36 +--
 .../store/mail/model/DefaultMessageIdTest.java     |   8 +-
 .../mail/model/DelegatingMailboxMessageTest.java   |  10 +-
 .../mailbox/store/mail/model/FlagsFactoryTest.java |  38 +--
 .../mailbox/store/mail/model/FlagsFilterTest.java  |  18 +-
 .../store/mail/model/ListMailboxAssert.java        |   2 +-
 .../store/mail/model/ListMailboxAssertTest.java    |  32 +--
 .../store/mail/model/ListMessageAssert.java        |   4 +-
 .../store/mail/model/ListMessageAssertTest.java    |  57 ++--
 .../mail/model/ListMessagePropertiesAssert.java    |   4 +-
 .../model/ListMessagePropertiesAssertTest.java     |  71 ++---
 .../store/mail/model/MailboxMessageAssertTest.java |  32 ++-
 .../store/mail/model/MessageUidProviderTest.java   |  18 +-
 .../store/mail/model/MetadataMapAssertTest.java    |  55 ++--
 .../store/mail/model/impl/MessageParserTest.java   |  76 +++---
 .../store/mail/model/impl/PropertyBuilderTest.java |  10 +-
 .../mail/model/impl/SimpleMailboxMessageTest.java  | 289 ++++++++++-----------
 .../mail/utils/ApplicableFlagCalculatorTest.java   |  36 ++-
 .../quota/DefaultUserQuotaRootResolverTest.java    |  62 ++---
 .../quota/ListeningCurrentQuotaUpdaterTest.java    |  40 +--
 .../mailbox/store/quota/QuotaCheckerTest.java      |  30 +--
 .../mailbox/store/quota/StoreQuotaManagerTest.java |  26 +-
 .../store/search/CombinedComparatorTest.java       |  48 ++--
 .../james/mailbox/store/search/SearchUtilTest.java |  24 +-
 .../search/comparator/SentDateComparatorTest.java  |  34 +--
 .../mailbox/tools/copier/MailboxCopierTest.java    |   3 +-
 .../apache/james/mpt/host/JamesImapHostSystem.java |   4 +-
 .../james/imap/processor/LogoutProcessor.java      |  17 +-
 .../imap/processor/SystemMessageProcessor.java     |  13 +-
 .../org/apache/james/modules/MailboxProbeImpl.java |   6 +-
 .../adapter/mailbox/MailboxManagerManagement.java  |   6 +-
 .../mailets/delivery/MailboxAppender.java          |   6 +-
 .../james/pop3server/mailbox/MailboxAdapter.java   |   4 +-
 56 files changed, 1070 insertions(+), 1113 deletions(-)


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


[james-project] 11/42: [Refactoring] Move FlagsFactoryTest to JUnit 5

Posted by rc...@apache.org.
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 60489d85b47f2ebf95aa63dbb9c8090aa4e8b6bc
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:17:48 2019 +0700

    [Refactoring] Move FlagsFactoryTest to JUnit 5
---
 .../mailbox/store/mail/model/FlagsFactoryTest.java | 38 +++++++++++-----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
index 053bfd1..42e7878 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
@@ -23,20 +23,20 @@ import static org.assertj.core.api.Assertions.assertThat;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class FlagsFactoryTest {
+class FlagsFactoryTest {
 
-    private ImmutableList<Flag> listOfSystemFlags = ImmutableList.of(Flag.SEEN, Flag.RECENT, Flag.ANSWERED);
-    private ImmutableList<String> listOfUserFlags = ImmutableList.of("userFlag", "soCool");
-    private Flags emptyFlags;
-    private Flags someFlags;
+    ImmutableList<Flag> listOfSystemFlags = ImmutableList.of(Flag.SEEN, Flag.RECENT, Flag.ANSWERED);
+    ImmutableList<String> listOfUserFlags = ImmutableList.of("userFlag", "soCool");
+    Flags emptyFlags;
+    Flags someFlags;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         emptyFlags = new Flags();
         someFlags = new Flags();
         listOfSystemFlags.forEach(someFlags::add);
@@ -44,23 +44,23 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldAllowEmptyFactory() {
+    void builderShouldAllowEmptyFactory() {
         assertThat(FlagsFactory.builder().build()).isEqualTo(emptyFlags);
     }
 
     @Test
-    public void builderShouldNotRequireFlagsInstanceWhenUserFlagsDefined() {
+    void builderShouldNotRequireFlagsInstanceWhenUserFlagsDefined() {
         Flags actual = FlagsFactory.builder().addUserFlags("userFlag").build();
         assertThat(actual.getUserFlags()).containsOnly("userFlag");
     }
 
     @Test
-    public void builderShouldNotRequireUserFlagsWhenFlagsInstanceDefined() {
+    void builderShouldNotRequireUserFlagsWhenFlagsInstanceDefined() {
         assertThat(FlagsFactory.builder().flags(new Flags()).build()).isNotNull();
     }
 
     @Test
-    public void builderShouldAcceptNullUserFlags() {
+    void builderShouldAcceptNullUserFlags() {
         assertThat(
             FlagsFactory.builder()
                 .addUserFlags((String)null)
@@ -69,7 +69,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldFilterUserFlags() {
+    void builderShouldFilterUserFlags() {
         Flags actual = FlagsFactory.builder()
             .flags(someFlags)
             .filteringFlags(
@@ -82,7 +82,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldFilterSystemFlags() {
+    void builderShouldFilterSystemFlags() {
         Flags actual = FlagsFactory.builder()
             .flags(someFlags)
             .filteringFlags(
@@ -95,7 +95,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldAllowFilteringOnEmptyFlags() {
+    void builderShouldAllowFilteringOnEmptyFlags() {
         Flags actual = FlagsFactory.builder()
             .flags(emptyFlags)
             .filteringFlags(
@@ -109,7 +109,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldFilterOnFlags() {
+    void builderShouldFilterOnFlags() {
         Flags actual = FlagsFactory.builder()
             .flags(someFlags)
             .filteringFlags(
@@ -124,7 +124,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldTrimEmptyUserFlags() {
+    void builderShouldTrimEmptyUserFlags() {
         Flags flags = new Flags();
         flags.add("");
         flags.add("value2");
@@ -133,7 +133,7 @@ public class FlagsFactoryTest {
     }
 
     @Test
-    public void builderShouldTrimNullUserFlags() {
+    void builderShouldTrimNullUserFlags() {
         Flags actual = FlagsFactory.builder().addUserFlags(null, "value").build();
         assertThat(actual.getUserFlags()).containsOnly("value");
     }


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


[james-project] 32/42: [Refactoring] Move PartContentBuilderMultipartAlternativeTest to JUnit 5

Posted by rc...@apache.org.
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 a11449d18cd05c5908ed55ec8cad9be6a0775ec6
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:05:30 2019 +0700

    [Refactoring] Move PartContentBuilderMultipartAlternativeTest to JUnit 5
---
 ...PartContentBuilderMultipartAlternativeTest.java | 38 +++++++++++-----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
index 5c937b6..813c039 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderMultipartAlternativeTest.java
@@ -30,36 +30,36 @@ import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.model.Header;
 import org.apache.james.mailbox.store.streaming.PartContentBuilder;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class PartContentBuilderMultipartAlternativeTest {
+class PartContentBuilderMultipartAlternativeTest {
 
-    private static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii";
+    static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii";
 
-    private static final String CONTENT_TYPE_HTML = "text/html;charset=us-ascii";
+    static final String CONTENT_TYPE_HTML = "text/html;charset=us-ascii";
 
-    private static final String CONTENT_TYPE_XHTML = "application/xhtml;charset=us-ascii";
+    static final String CONTENT_TYPE_XHTML = "application/xhtml;charset=us-ascii";
 
-    private static final String CONTENT_TYPE = "Content-Type";
+    static final String CONTENT_TYPE = "Content-Type";
 
-    private static final String ALT_PLAIN_BODY = "Rhubarb!Rhubard!Rhubard!\r\n";
+    static final String ALT_PLAIN_BODY = "Rhubarb!Rhubard!Rhubard!\r\n";
 
-    private static final String ALT_XHTML_BODY = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
+    static final String ALT_XHTML_BODY = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
             + "<html><head><title>Rhubard!</title></head><body><p>Rhubarb!Rhubard!Rhubard!</p></body></html>\r\n";
 
-    private static final String ALT_HTML_BODY = "<html><head><title>Rhubard!</title></head><body><p>Rhubarb!Rhubard!Rhubard!</p></body></html>\r\n";
+    static final String ALT_HTML_BODY = "<html><head><title>Rhubard!</title></head><body><p>Rhubarb!Rhubard!Rhubard!</p></body></html>\r\n";
 
-    private static final String ALT_PART_XHTML = CONTENT_TYPE + ": "
+    static final String ALT_PART_XHTML = CONTENT_TYPE + ": "
             + CONTENT_TYPE_XHTML + "\r\n" + "\r\n" + ALT_XHTML_BODY;
 
-    private static final String ALT_PART_HTML = CONTENT_TYPE + ": "
+    static final String ALT_PART_HTML = CONTENT_TYPE + ": "
             + CONTENT_TYPE_HTML + "\r\n" + "\r\n" + ALT_HTML_BODY;
 
-    private static final String ALT_PART_PLAIN = CONTENT_TYPE + ": "
+    static final String ALT_PART_PLAIN = CONTENT_TYPE + ": "
             + CONTENT_TYPE_PLAIN + "\r\n" + "\r\n" + ALT_PLAIN_BODY;
 
-    private static final String MULTIPART_ALTERNATIVE = "From: Samual Smith <sa...@example.org>\r\n"
+    static final String MULTIPART_ALTERNATIVE = "From: Samual Smith <sa...@example.org>\r\n"
             + "To: John Smith <jo...@example.org>\r\n"
             + "Date: Sun, 10 Feb 2008 08:00:00 -0800 (PST)\r\n"
             + "Subject: Rhubarb!\r\n"
@@ -73,27 +73,27 @@ public class PartContentBuilderMultipartAlternativeTest {
 
     PartContentBuilder builder;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         builder = new PartContentBuilder();
     }
 
     @Test
-    public void testShouldLocatePartsOfMultipartAlterative() throws Exception {
+    void testShouldLocatePartsOfMultipartAlterative() throws Exception {
         assertThat(bodyContent(MULTIPART_ALTERNATIVE, 1)).isEqualTo(ALT_PLAIN_BODY);
         assertThat(bodyContent(MULTIPART_ALTERNATIVE, 2)).isEqualTo(ALT_HTML_BODY);
         assertThat(bodyContent(MULTIPART_ALTERNATIVE, 3)).isEqualTo(ALT_XHTML_BODY);
     }
 
     @Test
-    public void testShouldLocateHeadersOfMultipartAlterative() throws Exception {
+    void testShouldLocateHeadersOfMultipartAlterative() throws Exception {
         checkContentType(CONTENT_TYPE_PLAIN, MULTIPART_ALTERNATIVE, 1);
         checkContentType(CONTENT_TYPE_HTML, MULTIPART_ALTERNATIVE, 2);
         checkContentType(CONTENT_TYPE_XHTML, MULTIPART_ALTERNATIVE, 3);
     }
 
     @Test
-    public void testShouldLocateFullContentOfMultipartAlterative()
+    void testShouldLocateFullContentOfMultipartAlterative()
             throws Exception {
         assertThat(fullContent(MULTIPART_ALTERNATIVE, 1)).isEqualTo(ALT_PART_PLAIN);
         assertThat(fullContent(MULTIPART_ALTERNATIVE, 2)).isEqualTo(ALT_PART_HTML);


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


[james-project] 05/42: [Refactoring] Move MailboxACLJsonConverterTest to JUnit 5

Posted by rc...@apache.org.
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 23de3409cc35f939d9f3b5a75c46949e4c3143ef
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:53:04 2019 +0700

    [Refactoring] Move MailboxACLJsonConverterTest to JUnit 5
---
 .../store/json/MailboxACLJsonConverterTest.java    | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/MailboxACLJsonConverterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/MailboxACLJsonConverterTest.java
index 2de43b6..b15fed2 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/MailboxACLJsonConverterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/MailboxACLJsonConverterTest.java
@@ -38,100 +38,100 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxACL.EntryKey;
 import org.apache.james.mailbox.model.MailboxACL.NameType;
 import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import net.javacrumbs.jsonunit.core.Option;
 
-public class MailboxACLJsonConverterTest {
+class MailboxACLJsonConverterTest {
 
-    public class ACLMapBuilder {
-        private final Map<EntryKey, Rfc4314Rights> map;
+    class ACLMapBuilder {
+        final Map<EntryKey, Rfc4314Rights> map;
 
-        public ACLMapBuilder() {
+        ACLMapBuilder() {
             map = new LinkedHashMap<>();
         }
 
-        public ACLMapBuilder addSingleUserEntryToMap() {
+        ACLMapBuilder addSingleUserEntryToMap() {
             Rfc4314Rights rights = new Rfc4314Rights(CreateMailbox, DeleteMailbox, DeleteMessages, Lookup, Post, Read, WriteSeenFlag, Write);
             EntryKey key = new EntryKey("user", NameType.user, true);
             map.put(key, rights);
             return this;
         }
 
-        public ACLMapBuilder addSingleSpecialEntryToMap() {
+        ACLMapBuilder addSingleSpecialEntryToMap() {
             Rfc4314Rights rights = new Rfc4314Rights(DeleteMailbox, DeleteMessages, Lookup, Post, Write, WriteSeenFlag);
             EntryKey key = new EntryKey("special", NameType.special, true);
             map.put(key, rights);
             return this;
         }
 
-        public ACLMapBuilder addSingleGroupEntryToMap() {
+        ACLMapBuilder addSingleGroupEntryToMap() {
             Rfc4314Rights rights = new Rfc4314Rights(DeleteMailbox, DeleteMessages, Lookup, Post, Read, Write, WriteSeenFlag);
             EntryKey key = new EntryKey("group", NameType.group, true);
             map.put(key, rights);
             return this;
         }
 
-        public MailboxACL buildAsACL() {
+        MailboxACL buildAsACL() {
             return new MailboxACL(new HashMap<>(map));
         }
 
     }
 
     @Test
-    public void emptyACLShouldBeWellSerialized() throws Exception {
+    void emptyACLShouldBeWellSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toJson(MailboxACL.EMPTY))
             .when(Option.IGNORING_ARRAY_ORDER)
             .isEqualTo("{\"entries\":{}}");
     }
 
     @Test
-    public void singleUserEntryACLShouldBeWellSerialized() throws Exception {
+    void singleUserEntryACLShouldBeWellSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toJson(new ACLMapBuilder().addSingleUserEntryToMap().buildAsACL()))
             .when(Option.IGNORING_ARRAY_ORDER)
             .isEqualTo("{\"entries\":{\"-user\":\"klprstwx\"}}");
     }
 
     @Test
-    public void singleGroupEntryACLShouldBeWellSerialized() throws Exception {
+    void singleGroupEntryACLShouldBeWellSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toJson(new ACLMapBuilder().addSingleGroupEntryToMap().buildAsACL()))
             .when(Option.IGNORING_ARRAY_ORDER)
             .isEqualTo("{\"entries\":{\"-$group\":\"lprstwx\"}}");
     }
 
     @Test
-    public void singleSpecialEntryACLShouldBeWellSerialized() throws Exception {
+    void singleSpecialEntryACLShouldBeWellSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toJson(new ACLMapBuilder().addSingleSpecialEntryToMap().buildAsACL()))
             .when(Option.IGNORING_ARRAY_ORDER)
             .isEqualTo("{\"entries\":{\"-special\":\"lpstwx\"}}");
     }
 
     @Test
-    public void multipleEntriesACLShouldBeWellSerialized() throws Exception {
+    void multipleEntriesACLShouldBeWellSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toJson(new ACLMapBuilder().addSingleUserEntryToMap().addSingleGroupEntryToMap().buildAsACL()))
             .when(Option.IGNORING_ARRAY_ORDER)
             .isEqualTo("{\"entries\":{\"-user\":\"klprstwx\",\"-$group\":\"lprstwx\"}}");
     }
 
     @Test
-    public void emptyACLShouldBeWellDeSerialized() throws Exception {
+    void emptyACLShouldBeWellDeSerialized() throws Exception {
         assertThat(MailboxACLJsonConverter.toACL("{\"entries\":{}}")).isEqualTo(MailboxACL.EMPTY);
     }
 
     @Test
-    public void singleUserEntryACLShouldBeWellDeSerialized() throws Exception {
+    void singleUserEntryACLShouldBeWellDeSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":\"klprstwx\"}}"))
             .isEqualTo(new ACLMapBuilder().addSingleUserEntryToMap().buildAsACL());
     }
 
     @Test
-    public void singleGroupEntryACLShouldBeWellDeSerialized() throws Exception {
+    void singleGroupEntryACLShouldBeWellDeSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toACL("{\"entries\":{\"-$group\":\"lprstwx\"}}"))
             .isEqualTo(new ACLMapBuilder().addSingleGroupEntryToMap().buildAsACL());
     }
 
     @Test
-    public void multipleEntriesACLShouldBeWellDeSerialized() throws Exception {
+    void multipleEntriesACLShouldBeWellDeSerialized() throws Exception {
         assertThatJson(MailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":\"klprstwx\",\"-$group\":\"lprstwx\"}}"))
             .isEqualTo(new ACLMapBuilder().addSingleUserEntryToMap().addSingleGroupEntryToMap().buildAsACL());
     }


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


[james-project] 31/42: [Refactoring] Move PartContentBuilderComplexMultipartTest to JUnit 5

Posted by rc...@apache.org.
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 f71a854619e54e893f0605eb61c4056c6d757108
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:03:50 2019 +0700

    [Refactoring] Move PartContentBuilderComplexMultipartTest to JUnit 5
---
 .../PartContentBuilderComplexMultipartTest.java    | 64 +++++++++++-----------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
index 034093a..d2d34ce 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/PartContentBuilderComplexMultipartTest.java
@@ -32,44 +32,44 @@ import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.model.Header;
 import org.apache.james.mailbox.store.streaming.PartContentBuilder;
 import org.apache.james.mailbox.store.streaming.PartContentBuilder.PartNotFoundException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class PartContentBuilderComplexMultipartTest {
+class PartContentBuilderComplexMultipartTest {
 
-    private static final String PREAMBLE = "This is the preamble";
+    static final String PREAMBLE = "This is the preamble";
 
-    private static final String CONTENT_TYPE = "Content-Type";
+    static final String CONTENT_TYPE = "Content-Type";
 
-    private static final String CONTENT_TYPE_HTML = "text/html;charset=us-ascii";
+    static final String CONTENT_TYPE_HTML = "text/html;charset=us-ascii";
 
-    private static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii";
+    static final String CONTENT_TYPE_PLAIN = "text/plain;charset=us-ascii";
 
-    private static final String CONTENT_TYPE_RFC822 = "message/rfc822";
+    static final String CONTENT_TYPE_RFC822 = "message/rfc822";
 
-    private static final String OUTER_HTML_BODY = "<html><head><title>Rhubard!</title></head><body><p>Rhubarb!Rhubard!Rhubard!</p></body></html>\r\n";
+    static final String OUTER_HTML_BODY = "<html><head><title>Rhubard!</title></head><body><p>Rhubarb!Rhubard!Rhubard!</p></body></html>\r\n";
 
-    private static final String FULL_OUTER_HTML = CONTENT_TYPE + ": "
+    static final String FULL_OUTER_HTML = CONTENT_TYPE + ": "
             + CONTENT_TYPE_HTML + "\r\n\r\n" + OUTER_HTML_BODY;
 
-    private static final String OUTER_PLAIN_BODY = "Rhubarb!Rhubard!Rhubard!\r\n";
+    static final String OUTER_PLAIN_BODY = "Rhubarb!Rhubard!Rhubard!\r\n";
 
-    private static final String FULL_OUTER_PLAIN = CONTENT_TYPE + ": "
+    static final String FULL_OUTER_PLAIN = CONTENT_TYPE + ": "
             + CONTENT_TYPE_PLAIN + "\r\n\r\n" + OUTER_PLAIN_BODY;
 
-    private static final String INNER_HTML_BODY = "<html><head><title>Custard!</title></head><body><p>Custard!Custard!Custard!</p></body></html>\r\n";
+    static final String INNER_HTML_BODY = "<html><head><title>Custard!</title></head><body><p>Custard!Custard!Custard!</p></body></html>\r\n";
 
-    private static final String FULL_INNER_HTML = CONTENT_TYPE + ": "
+    static final String FULL_INNER_HTML = CONTENT_TYPE + ": "
             + CONTENT_TYPE_HTML + "\r\n\r\n" + INNER_HTML_BODY;
 
-    private static final String INNER_PLAIN_BODY = "Custard!Custard!Custard!\r\n";
+    static final String INNER_PLAIN_BODY = "Custard!Custard!Custard!\r\n";
 
-    private static final String FULL_INNER_TXT = CONTENT_TYPE + ": "
+    static final String FULL_INNER_TXT = CONTENT_TYPE + ": "
             + CONTENT_TYPE_PLAIN + "\r\n\r\n" + INNER_PLAIN_BODY;
 
-    private static final String INNERMOST_BODY = "Da!Da!Da!Dah!\r\n";
+    static final String INNERMOST_BODY = "Da!Da!Da!Dah!\r\n";
 
-    private static final String RFC822_PLAIN_MAIL = "From:  Samual Smith <sa...@example.org>\r\n"
+    static final String RFC822_PLAIN_MAIL = "From:  Samual Smith <sa...@example.org>\r\n"
             + "To: John Smith <jo...@example.org>\r\n"
             + "Date: Thu, 1 Feb 2007 08:00:00 -0800 (PST)\r\n"
             + "Subject: Rhubard And Custard!\r\n"
@@ -77,10 +77,10 @@ public class PartContentBuilderComplexMultipartTest {
             + ": "
             + CONTENT_TYPE_PLAIN + "\r\n" + "\r\n" + INNERMOST_BODY;
 
-    private static final String FULL_INNERMOST_EMAIL = CONTENT_TYPE + ": "
+    static final String FULL_INNERMOST_EMAIL = CONTENT_TYPE + ": "
             + CONTENT_TYPE_RFC822 + "\r\n\r\n" + RFC822_PLAIN_MAIL;
 
-    private static final String INNER_MAIL = "From: John Smith <jo...@example.org>\r\n"
+    static final String INNER_MAIL = "From: John Smith <jo...@example.org>\r\n"
             + "To: Samual Smith <sa...@example.org>\r\n"
             + "Date: Fri, 1 Feb 2008 08:00:00 -0800 (PST)\r\n"
             + "Subject: Custard!\r\n"
@@ -94,10 +94,10 @@ public class PartContentBuilderComplexMultipartTest {
             + FULL_INNERMOST_EMAIL
             + "\r\n--1729--\r\n";
 
-    private static final String FULL_INNER_MAIL = CONTENT_TYPE + ": "
+    static final String FULL_INNER_MAIL = CONTENT_TYPE + ": "
             + CONTENT_TYPE_RFC822 + "\r\n\r\n" + INNER_MAIL;
 
-    private static final String MULTIPART_MIXED = "From: Samual Smith <sa...@example.org>\r\n"
+    static final String MULTIPART_MIXED = "From: Samual Smith <sa...@example.org>\r\n"
             + "To: John Smith <jo...@example.org>\r\n"
             + "Date: Sun, 10 Feb 2008 08:00:00 -0800 (PST)\r\n"
             + "Subject: Rhubarb!\r\n"
@@ -113,13 +113,13 @@ public class PartContentBuilderComplexMultipartTest {
 
     PartContentBuilder builder;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         builder = new PartContentBuilder();
     }
 
     @Test
-    public void testShouldNotFoundSubPartOfNonMultiPartTopLevel()
+    void testShouldNotFoundSubPartOfNonMultiPartTopLevel()
             throws Exception {
         int[] path = { 1, 1 };
         for (int i = 1; i < 10; i++) {
@@ -129,7 +129,7 @@ public class PartContentBuilderComplexMultipartTest {
     }
 
     @Test
-    public void testShouldNotFoundSubPartOfNonMultiInnerPart() throws Exception {
+    void testShouldNotFoundSubPartOfNonMultiInnerPart() throws Exception {
         int[] path = { 2, 2, 1 };
         for (int i = 1; i < 10; i++) {
             path[2] = i;
@@ -138,38 +138,38 @@ public class PartContentBuilderComplexMultipartTest {
     }
 
     @Test
-    public void testShouldLocateOuterHtml() throws Exception {
+    void testShouldLocateOuterHtml() throws Exception {
         int[] path = { 1 };
         check(FULL_OUTER_HTML, OUTER_HTML_BODY, CONTENT_TYPE_HTML, path);
     }
 
     @Test
-    public void testShouldLocateOuterMail() throws Exception {
+    void testShouldLocateOuterMail() throws Exception {
         int[] path = { 2 };
         check(FULL_INNER_MAIL, INNER_MAIL, CONTENT_TYPE_RFC822, path);
     }
 
     @Test
-    public void testShouldLocateOuterPlain() throws Exception {
+    void testShouldLocateOuterPlain() throws Exception {
         int[] path = { 3 };
         check(FULL_OUTER_PLAIN, OUTER_PLAIN_BODY, CONTENT_TYPE_PLAIN, path);
     }
 
     @Test
-    public void testShouldLocateInnerHtml() throws Exception {
+    void testShouldLocateInnerHtml() throws Exception {
         int[] path = { 2, 2 };
         check(FULL_INNER_HTML, INNER_HTML_BODY, CONTENT_TYPE_HTML, path);
     }
 
     @Test
-    public void testShouldLocateInnerMail() throws Exception {
+    void testShouldLocateInnerMail() throws Exception {
         int[] path = { 2, 3 };
         check(FULL_INNERMOST_EMAIL, RFC822_PLAIN_MAIL, CONTENT_TYPE_RFC822,
                 path);
     }
 
     @Test
-    public void testShouldLocateInnerPlain() throws Exception {
+    void testShouldLocateInnerPlain() throws Exception {
         int[] path = { 2, 1 };
         check(FULL_INNER_TXT, INNER_PLAIN_BODY, CONTENT_TYPE_PLAIN, path);
     }


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


[james-project] 39/42: [Refactoring] Move StoreMailboxManagerTest to JUnit 5

Posted by rc...@apache.org.
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 45d161ced91fc838fd44042120cbaa62d771aff5
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:18:30 2019 +0700

    [Refactoring] Move StoreMailboxManagerTest to JUnit 5
---
 .../mailbox/store/StoreMailboxManagerTest.java     | 116 +++++++++++----------
 1 file changed, 62 insertions(+), 54 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
index 745c8d5..34efd21 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -54,25 +55,25 @@ import org.apache.james.mailbox.store.quota.QuotaComponents;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;
 import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
 import org.apache.james.metrics.api.NoopMetricFactory;
-import org.junit.Before;
-import org.junit.Test;
-
-public class StoreMailboxManagerTest {
-    private static final Username CURRENT_USER = Username.of("user");
-    private static final String CURRENT_USER_PASSWORD = "secret";
-    private static final Username ADMIN = Username.of("admin");
-    private static final String ADMIN_PASSWORD = "adminsecret";
-    private static final MailboxId MAILBOX_ID = TestId.of(123);
-    private static final Username UNKNOWN_USER = Username.of("otheruser");
-    private static final String BAD_PASSWORD = "badpassword";
-    private static final String EMPTY_PREFIX = "";
-
-    private StoreMailboxManager storeMailboxManager;
-    private MailboxMapper mockedMailboxMapper;
-    private MailboxSession mockedMailboxSession;
-
-    @Before
-    public void setUp() throws MailboxException {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class StoreMailboxManagerTest {
+    static final Username CURRENT_USER = Username.of("user");
+    static final String CURRENT_USER_PASSWORD = "secret";
+    static final Username ADMIN = Username.of("admin");
+    static final String ADMIN_PASSWORD = "adminsecret";
+    static final MailboxId MAILBOX_ID = TestId.of(123);
+    static final Username UNKNOWN_USER = Username.of("otheruser");
+    static final String BAD_PASSWORD = "badpassword";
+    static final String EMPTY_PREFIX = "";
+
+    StoreMailboxManager storeMailboxManager;
+    MailboxMapper mockedMailboxMapper;
+    MailboxSession mockedMailboxSession;
+
+    @BeforeEach
+    void setUp() throws MailboxException {
         MailboxSessionMapperFactory mockedMapperFactory = mock(MailboxSessionMapperFactory.class);
         mockedMailboxSession = MailboxSessionUtil.create(CURRENT_USER);
         mockedMailboxMapper = mock(MailboxMapper.class);
@@ -99,15 +100,16 @@ public class StoreMailboxManagerTest {
                 PreDeletionHooks.NO_PRE_DELETION_HOOK);
     }
 
-    @Test(expected = MailboxNotFoundException.class)
-    public void getMailboxShouldThrowWhenUnknownId() throws Exception {
+    @Test
+    void getMailboxShouldThrowWhenUnknownId() throws Exception {
         when(mockedMailboxMapper.findMailboxById(MAILBOX_ID)).thenReturn(null);
 
-        storeMailboxManager.getMailbox(MAILBOX_ID, mockedMailboxSession);
+        assertThatThrownBy(() -> storeMailboxManager.getMailbox(MAILBOX_ID, mockedMailboxSession))
+            .isInstanceOf(MailboxNotFoundException.class);
     }
 
     @Test
-    public void getMailboxShouldReturnMailboxManagerWhenKnownId() throws Exception {
+    void getMailboxShouldReturnMailboxManagerWhenKnownId() throws Exception {
         Mailbox mockedMailbox = mock(Mailbox.class);
         when(mockedMailbox.generateAssociatedPath())
             .thenReturn(MailboxPath.forUser(CURRENT_USER, "mailboxName"));
@@ -120,7 +122,7 @@ public class StoreMailboxManagerTest {
     }
 
     @Test
-    public void getMailboxShouldReturnMailboxManagerWhenKnownIdAndDifferentCaseUser() throws Exception {
+    void getMailboxShouldReturnMailboxManagerWhenKnownIdAndDifferentCaseUser() throws Exception {
         Mailbox mockedMailbox = mock(Mailbox.class);
         when(mockedMailbox.generateAssociatedPath())
             .thenReturn(MailboxPath.forUser(Username.of("uSEr"), "mailboxName"));
@@ -132,8 +134,8 @@ public class StoreMailboxManagerTest {
         assertThat(expected.getId()).isEqualTo(MAILBOX_ID);
     }
 
-    @Test(expected = MailboxNotFoundException.class)
-    public void getMailboxShouldThrowWhenMailboxDoesNotMatchUserWithoutRight() throws Exception {
+    @Test
+    void getMailboxShouldThrowWhenMailboxDoesNotMatchUserWithoutRight() throws Exception {
         Username otherUser = Username.of("other.user");
         Mailbox mockedMailbox = mock(Mailbox.class);
         when(mockedMailbox.getACL()).thenReturn(new MailboxACL());
@@ -144,62 +146,68 @@ public class StoreMailboxManagerTest {
         when(mockedMailboxMapper.findMailboxById(MAILBOX_ID)).thenReturn(mockedMailbox);
         when(mockedMailboxMapper.findMailboxByPath(any())).thenReturn(mockedMailbox);
 
-        MessageManager expected = storeMailboxManager.getMailbox(MAILBOX_ID, mockedMailboxSession);
-
-        assertThat(expected.getId()).isEqualTo(MAILBOX_ID);
+        assertThatThrownBy(() -> storeMailboxManager.getMailbox(MAILBOX_ID, mockedMailboxSession))
+            .isInstanceOf(MailboxNotFoundException.class);
     }
 
     @Test
-    public void loginShouldCreateSessionWhenGoodPassword() throws Exception {
+    void loginShouldCreateSessionWhenGoodPassword() throws Exception {
         MailboxSession expected = storeMailboxManager.login(CURRENT_USER, CURRENT_USER_PASSWORD);
 
         assertThat(expected.getUser()).isEqualTo(CURRENT_USER);
     }
 
-    @Test(expected = BadCredentialsException.class)
-    public void loginShouldThrowWhenBadPassword() throws Exception {
-        storeMailboxManager.login(CURRENT_USER, BAD_PASSWORD);
+    @Test
+    void loginShouldThrowWhenBadPassword() {
+        assertThatThrownBy(() -> storeMailboxManager.login(CURRENT_USER, BAD_PASSWORD))
+            .isInstanceOf(BadCredentialsException.class);
     }
 
-    @Test(expected = BadCredentialsException.class)
-    public void loginAsOtherUserShouldNotCreateUserSessionWhenAdminWithBadPassword() throws Exception {
-        storeMailboxManager.loginAsOtherUser(ADMIN, BAD_PASSWORD, CURRENT_USER);
+    @Test
+    void loginAsOtherUserShouldNotCreateUserSessionWhenAdminWithBadPassword() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(ADMIN, BAD_PASSWORD, CURRENT_USER))
+            .isInstanceOf(BadCredentialsException.class);
     }
 
-    @Test(expected = NotAdminException.class)
-    public void loginAsOtherUserShouldNotCreateUserSessionWhenNotAdmin() throws Exception {
-        storeMailboxManager.loginAsOtherUser(CURRENT_USER, CURRENT_USER_PASSWORD, UNKNOWN_USER);
+    @Test
+    void loginAsOtherUserShouldNotCreateUserSessionWhenNotAdmin() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(CURRENT_USER, CURRENT_USER_PASSWORD, UNKNOWN_USER))
+            .isInstanceOf(NotAdminException.class);
     }
 
-    @Test(expected = BadCredentialsException.class)
-    public void loginAsOtherUserShouldThrowBadCredentialWhenBadPasswordAndNotAdminUser() throws Exception {
-        storeMailboxManager.loginAsOtherUser(CURRENT_USER, BAD_PASSWORD, CURRENT_USER);
+    @Test
+    void loginAsOtherUserShouldThrowBadCredentialWhenBadPasswordAndNotAdminUser() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(CURRENT_USER, BAD_PASSWORD, CURRENT_USER))
+            .isInstanceOf(BadCredentialsException.class);
     }
 
-    @Test(expected = BadCredentialsException.class)
-    public void loginAsOtherUserShouldThrowBadCredentialWhenBadPasswordNotAdminUserAndUnknownUser() throws Exception {
-        storeMailboxManager.loginAsOtherUser(CURRENT_USER, BAD_PASSWORD, UNKNOWN_USER);
+    @Test
+    void loginAsOtherUserShouldThrowBadCredentialWhenBadPasswordNotAdminUserAndUnknownUser() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(CURRENT_USER, BAD_PASSWORD, UNKNOWN_USER))
+            .isInstanceOf(BadCredentialsException.class);
     }
 
-    @Test(expected = BadCredentialsException.class)
-    public void loginAsOtherUserShouldThrowBadCredentialsWhenBadPasswordAndUserDoesNotExists() throws Exception {
-        storeMailboxManager.loginAsOtherUser(ADMIN, BAD_PASSWORD, UNKNOWN_USER);
+    @Test
+    void loginAsOtherUserShouldThrowBadCredentialsWhenBadPasswordAndUserDoesNotExists() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(ADMIN, BAD_PASSWORD, UNKNOWN_USER))
+            .isInstanceOf(BadCredentialsException.class);
     }
 
-    @Test(expected = UserDoesNotExistException.class)
-    public void loginAsOtherUserShouldNotCreateUserSessionWhenDelegatedUserDoesNotExist() throws Exception {
-        storeMailboxManager.loginAsOtherUser(ADMIN, ADMIN_PASSWORD, UNKNOWN_USER);
+    @Test
+    void loginAsOtherUserShouldNotCreateUserSessionWhenDelegatedUserDoesNotExist() {
+        assertThatThrownBy(() -> storeMailboxManager.loginAsOtherUser(ADMIN, ADMIN_PASSWORD, UNKNOWN_USER))
+            .isInstanceOf(UserDoesNotExistException.class);
     }
 
     @Test
-    public void loginAsOtherUserShouldCreateUserSessionWhenAdminWithGoodPassword() throws Exception {
+    void loginAsOtherUserShouldCreateUserSessionWhenAdminWithGoodPassword() throws Exception {
         MailboxSession expected = storeMailboxManager.loginAsOtherUser(ADMIN, ADMIN_PASSWORD, CURRENT_USER);
 
         assertThat(expected.getUser()).isEqualTo(CURRENT_USER);
     }
 
     @Test
-    public void getPathLikeShouldReturnUserPathLikeWhenNoPrefixDefined() {
+    void getPathLikeShouldReturnUserPathLikeWhenNoPrefixDefined() {
         //Given
         MailboxSession session = MailboxSessionUtil.create(CURRENT_USER);
         MailboxQuery.Builder testee = MailboxQuery.builder()
@@ -217,7 +225,7 @@ public class StoreMailboxManagerTest {
     }
 
     @Test
-    public void getPathLikeShouldReturnUserPathLikeWhenPrefixDefined() {
+    void getPathLikeShouldReturnUserPathLikeWhenPrefixDefined() {
         //Given
         MailboxSession session = MailboxSessionUtil.create(CURRENT_USER);
         MailboxQuery.Builder testee = MailboxQuery.builder()


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


[james-project] 30/42: [Refactoring] Move MessageBatcherTest to JUnit 5

Posted by rc...@apache.org.
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 4d2045b7b9b43c2f6228a6d09d05acd4a56b6683
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:01:57 2019 +0700

    [Refactoring] Move MessageBatcherTest to JUnit 5
---
 .../james/mailbox/store/MessageBatcherTest.java    | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageBatcherTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageBatcherTest.java
index 1da24d5..a2f214c 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageBatcherTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MessageBatcherTest.java
@@ -20,15 +20,16 @@
 package org.apache.james.mailbox.store;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MessageRange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.Lists;
 
-public class MessageBatcherTest {
+class MessageBatcherTest {
 
     private MessageBatcher.BatchedOperation incrementBatcher =
         messageRange -> Lists.<MessageRange>newArrayList(MessageRange.range(
@@ -36,7 +37,7 @@ public class MessageBatcherTest {
             messageRange.getUidTo().next()));
 
     @Test
-    public void batchMessagesShouldWorkOnSingleRangeMode() throws Exception {
+    void batchMessagesShouldWorkOnSingleRangeMode() throws Exception {
         MessageBatcher messageBatcher = new MessageBatcher(0);
         
         assertThat(messageBatcher.batchMessages(MessageRange.range(MessageUid.of(1), MessageUid.of(10)), incrementBatcher))
@@ -44,30 +45,32 @@ public class MessageBatcherTest {
     }
 
     @Test
-    public void batchMessagesShouldWorkWithNonZeroBatchedSize() throws Exception {
+    void batchMessagesShouldWorkWithNonZeroBatchedSize() throws Exception {
         MessageBatcher messageBatcher = new MessageBatcher(5);
 
         assertThat(messageBatcher.batchMessages(MessageRange.range(MessageUid.of(1), MessageUid.of(10)), incrementBatcher))
             .containsOnly(MessageRange.range(MessageUid.of(2), MessageUid.of(6)), MessageRange.range(MessageUid.of(7), MessageUid.of(11)));
     }
 
-    @Test(expected = MailboxException.class)
-    public void batchMessagesShouldPropagateExceptions() throws Exception {
+    @Test
+    void batchMessagesShouldPropagateExceptions() {
         MessageBatcher messageBatcher = new MessageBatcher(0);
 
-        messageBatcher.batchMessages(MessageRange.range(MessageUid.of(1), MessageUid.of(10)),
-            messageRange -> {
-                throw new MailboxException();
-            });
+        assertThatThrownBy(() -> messageBatcher.batchMessages(MessageRange.range(MessageUid.of(1), MessageUid.of(10)),
+                messageRange -> {
+                    throw new MailboxException();
+                }))
+            .isInstanceOf(MailboxException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void messageBatcherShouldThrowOnNegativeBatchSize() throws Exception {
-        new MessageBatcher(-1);
+    @Test
+    void messageBatcherShouldThrowOnNegativeBatchSize() {
+        assertThatThrownBy(() -> new MessageBatcher(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void getBatchSizeShouldReturnTheBatchSize() {
+    void getBatchSizeShouldReturnTheBatchSize() {
         int batchSize = 123;
         MessageBatcher messageBatcher = new MessageBatcher(batchSize);
         assertThat(messageBatcher.getBatchSize()).isEqualTo(batchSize);


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


[james-project] 22/42: [Refactoring] Move QuotaCheckerTest to JUnit 5

Posted by rc...@apache.org.
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 42fdad9ab8b465f9e48ce1bb2569b330dba48299
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:49:38 2019 +0700

    [Refactoring] Move QuotaCheckerTest to JUnit 5
---
 .../mailbox/store/quota/QuotaCheckerTest.java      | 30 +++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
index 5473b66..c2b14f3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
@@ -38,26 +38,26 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class QuotaCheckerTest {
+class QuotaCheckerTest {
 
-    public static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("benwa", Optional.empty());
-    public static final MailboxPath MAILBOX_PATH = MailboxPath.inbox(Username.of("benwa"));
-    public static final Mailbox MAILBOX = new Mailbox(MAILBOX_PATH, 10);
+    static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("benwa", Optional.empty());
+    static final MailboxPath MAILBOX_PATH = MailboxPath.inbox(Username.of("benwa"));
+    static final Mailbox MAILBOX = new Mailbox(MAILBOX_PATH, 10);
 
-    private QuotaRootResolver mockedQuotaRootResolver;
-    private QuotaManager mockedQuotaManager;
+    QuotaRootResolver mockedQuotaRootResolver;
+    QuotaManager mockedQuotaManager;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mockedQuotaManager = mock(QuotaManager.class);
         mockedQuotaRootResolver = mock(QuotaRootResolver.class);
     }
 
     @Test
-    public void quotaCheckerShouldNotThrowOnRegularQuotas() throws MailboxException {
+    void quotaCheckerShouldNotThrowOnRegularQuotas() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
         when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(
             Quota.<QuotaCountLimit, QuotaCountUsage>builder().used(QuotaCountUsage.count(10)).computedLimit(QuotaCountLimit.count(100)).build());
@@ -69,7 +69,7 @@ public class QuotaCheckerTest {
     }
 
     @Test
-    public void quotaCheckerShouldNotThrowOnRegularModifiedQuotas() throws MailboxException {
+    void quotaCheckerShouldNotThrowOnRegularModifiedQuotas() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
         when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(
             Quota.<QuotaCountLimit, QuotaCountUsage>builder().used(QuotaCountUsage.count(10)).computedLimit(QuotaCountLimit.count(100)).build());
@@ -81,7 +81,7 @@ public class QuotaCheckerTest {
     }
 
     @Test
-    public void quotaCheckerShouldNotThrowOnReachedMaximumQuotas() throws MailboxException {
+    void quotaCheckerShouldNotThrowOnReachedMaximumQuotas() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
         when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(
             Quota.<QuotaCountLimit, QuotaCountUsage>builder().used(QuotaCountUsage.count(10)).computedLimit(QuotaCountLimit.count(100)).build());
@@ -93,7 +93,7 @@ public class QuotaCheckerTest {
     }
 
     @Test
-    public void quotaCheckerShouldThrowOnExceededMessages() throws MailboxException {
+    void quotaCheckerShouldThrowOnExceededMessages() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
         when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(
             Quota.<QuotaCountLimit, QuotaCountUsage>builder().used(QuotaCountUsage.count(10)).computedLimit(QuotaCountLimit.count(100)).build());
@@ -106,7 +106,7 @@ public class QuotaCheckerTest {
     }
 
     @Test
-    public void quotaCheckerShouldThrowOnExceededStorage() throws MailboxException {
+    void quotaCheckerShouldThrowOnExceededStorage() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
         when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(
             Quota.<QuotaCountLimit, QuotaCountUsage>builder().used(QuotaCountUsage.count(10)).computedLimit(QuotaCountLimit.count(100)).build());


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


[james-project] 19/42: [Refactoring] Move ApplicableFlagCalculatorTest to JUnit 5

Posted by rc...@apache.org.
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 7289cc6c6e48960b95e71acece980f194b58f1fe
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:45:10 2019 +0700

    [Refactoring] Move ApplicableFlagCalculatorTest to JUnit 5
---
 .../mail/utils/ApplicableFlagCalculatorTest.java   | 36 ++++++++++------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/utils/ApplicableFlagCalculatorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/utils/ApplicableFlagCalculatorTest.java
index 3ac6800..db11e31 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/utils/ApplicableFlagCalculatorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/utils/ApplicableFlagCalculatorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store.mail.utils;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Date;
 import java.util.List;
@@ -34,36 +35,28 @@ import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class ApplicableFlagCalculatorTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Rule
-    public final JUnitSoftAssertions softly = new JUnitSoftAssertions();
+class ApplicableFlagCalculatorTest {
 
     @Test
-    public void constructorShouldThrowWhenNull() throws Exception {
-        expectedException.expect(NullPointerException.class);
-        new ApplicableFlagCalculator(null);
+    void constructorShouldThrowWhenNull() {
+        assertThatThrownBy(() -> new ApplicableFlagCalculator(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagsWhenNoMessage() throws Exception {
+    void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagsWhenNoMessage() {
         ApplicableFlagCalculator calculator = new ApplicableFlagCalculator(ImmutableList.<MailboxMessage>of());
 
         assertThat(calculator.computeApplicableFlags()).isEqualTo(getDefaultApplicableFlag());
     }
 
     @Test
-    public void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagWhenNoMessageWithUserCustomFlag() throws Exception {
+    void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagWhenNoMessageWithUserCustomFlag() {
         List<MailboxMessage> mailboxMessages = ImmutableList.of(
             createMessage(new Flags(Flag.ANSWERED)),
             createMessage(new Flags(Flag.DELETED)),
@@ -76,7 +69,7 @@ public class ApplicableFlagCalculatorTest {
     }
 
     @Test
-    public void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagAndAllUserCustomFlagUsedOneMessage() throws Exception {
+    void computeApplicableFlagsShouldReturnOnlyDefaultApplicableFlagAndAllUserCustomFlagUsedOneMessage() {
         List<MailboxMessage> mailboxMessages = ImmutableList.of(
             createMessage(new Flags("capture me")),
             createMessage(new Flags("french")));
@@ -92,7 +85,7 @@ public class ApplicableFlagCalculatorTest {
     }
 
     @Test
-    public void unionFlagsShouldAlwaysIgnoreRecentAndUser() throws  Exception {
+    void unionFlagsShouldAlwaysIgnoreRecentAndUser() {
         List<MailboxMessage> mailboxMessages = ImmutableList.of(
             createMessage(new Flags(Flag.RECENT)),
             createMessage(new Flags(Flag.USER)));
@@ -101,13 +94,16 @@ public class ApplicableFlagCalculatorTest {
 
         Flags result = calculator.computeApplicableFlags();
 
-        softly.assertThat(result.contains(Flag.RECENT)).isFalse();
-        softly.assertThat(result.contains(Flag.USER)).isFalse();
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(result.contains(Flag.RECENT)).isFalse();
+            softly.assertThat(result.contains(Flag.USER)).isFalse();
+        });
     }
 
     private MailboxMessage createMessage(Flags messageFlags) {
         String content = "Any content";
         int bodyStart = 10;
+
         return new SimpleMailboxMessage(new DefaultMessageId(), new Date(), content.length(), bodyStart,
             new SharedByteArrayInputStream(content.getBytes()), messageFlags, new PropertyBuilder(), TestId.of(1));
     }


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


[james-project] 26/42: [Refactoring] Move SearchUtilTest to JUnit 5

Posted by rc...@apache.org.
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 77df56c4d59cdf198609e6d9959fcf69768bd820
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:54:44 2019 +0700

    [Refactoring] Move SearchUtilTest to JUnit 5
---
 .../james/mailbox/store/search/SearchUtilTest.java | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java
index b5210e6..6e4b419 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/SearchUtilTest.java
@@ -24,38 +24,38 @@ import static org.mockito.Mockito.when;
 
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class SearchUtilTest {
+class SearchUtilTest {
 
     @Test
-    public void testSimpleSubject() {
+    void testSimpleSubject() {
         String subject = "This is my subject";
         assertThat(SearchUtil.getBaseSubject(subject)).isEqualTo(subject);
     }
     
     @Test
-    public void testReplaceSpacesAndTabsInSubject() {
+    void testReplaceSpacesAndTabsInSubject() {
         String subject = "This   is my\tsubject";
         assertThat(SearchUtil.getBaseSubject(subject)).isEqualTo("This is my subject");
     }
     
     @Test
-    public void testRemoveTrailingSpace() {
+    void testRemoveTrailingSpace() {
         String subject = "This is my subject ";
         assertThat(SearchUtil.getBaseSubject(subject)).isEqualTo("This is my subject");
     }
     
     
     @Test
-    public void testRemoveTrailingFwd() {
+    void testRemoveTrailingFwd() {
         String subject = "This is my subject (fwd)";
         assertThat(SearchUtil.getBaseSubject(subject)).isEqualTo("This is my subject");
     }
     
 
     @Test
-    public void testSimpleExtraction() {
+    void testSimpleExtraction() {
         String expectedSubject = "Test";
         assertThat(SearchUtil.getBaseSubject("Re: Test")).isEqualTo(expectedSubject);
         assertThat(SearchUtil.getBaseSubject("re: Test")).isEqualTo(expectedSubject);
@@ -66,12 +66,12 @@ public class SearchUtilTest {
     }
   
     @Test
-    public void testComplexExtraction() {
+    void testComplexExtraction() {
         assertThat(SearchUtil.getBaseSubject("Re: re:re: fwd:[fwd: \t  Test]  (fwd)  (fwd)(fwd) ")).isEqualTo("Test");
     }
     
     @Test
-    public void getMessageIdIfSupportedByUnderlyingStorageOrNullForNullMessageIdShouldReturnNull() {
+    void getMessageIdIfSupportedByUnderlyingStorageOrNullForNullMessageIdShouldReturnNull() {
         //given
         MailboxMessage message = mock(MailboxMessage.class);
         when(message.getMessageId())
@@ -85,7 +85,7 @@ public class SearchUtilTest {
     }
 
     @Test
-    public void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForMessageIdThatSerializeReturnNullShouldReturnNull() {
+    void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForMessageIdThatSerializeReturnNullShouldReturnNull() {
         //given
         MessageId invalidMessageIdThatReturnNull = mock(MessageId.class);
         when(invalidMessageIdThatReturnNull.serialize())
@@ -103,7 +103,7 @@ public class SearchUtilTest {
     }
 
     @Test
-    public void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForValidMessageIdShouldReturnSerializedId() {
+    void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForValidMessageIdShouldReturnSerializedId() {
         //given
         String messageIdString = "http://www.labraxeenne.com/#/";
         MessageId messageId = mock(MessageId.class);
@@ -122,7 +122,7 @@ public class SearchUtilTest {
     }
 
     @Test
-    public void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForValidMessageIdShouldReturnNullWhenNotSupported() {
+    void getSerializedMessageIdIfSupportedByUnderlyingStorageOrNullForValidMessageIdShouldReturnNullWhenNotSupported() {
         //given
         MessageId messageId = mock(MessageId.class);
         when(messageId.isSerializable()).thenReturn(false);


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


[james-project] 01/42: [Refactoring] Remove MailboxManager::logout(session, force)

Posted by rc...@apache.org.
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 3bdff207754d475f17d82842544e3237b33254e8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Dec 6 11:18:51 2019 +0700

    [Refactoring] Remove MailboxManager::logout(session, force)
    
    No implementation currently uses the force parameter, making it useless.
    
    MailboxManager::logout(session) should be used instead
---
 .../org/apache/james/mailbox/MailboxManager.java   | 28 ----------------------
 .../mailbox/MailboxManagerStressContract.java      |  4 ++--
 .../apache/james/mailbox/MailboxManagerTest.java   |  8 +++----
 .../apache/james/mailbox/mock/DataProvisioner.java |  8 +++----
 .../mailbox/tools/copier/MailboxCopierTest.java    |  3 +--
 .../apache/james/mpt/host/JamesImapHostSystem.java |  4 ++--
 .../james/imap/processor/LogoutProcessor.java      | 17 ++++---------
 .../imap/processor/SystemMessageProcessor.java     | 13 +++-------
 .../org/apache/james/modules/MailboxProbeImpl.java |  6 +----
 .../adapter/mailbox/MailboxManagerManagement.java  |  6 +----
 .../mailets/delivery/MailboxAppender.java          |  6 +----
 .../james/pop3server/mailbox/MailboxAdapter.java   |  4 +---
 12 files changed, 24 insertions(+), 83 deletions(-)

diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index b1c7134..8ab0941 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -251,34 +251,6 @@ public interface MailboxManager extends RequestAware, RightManager, MailboxAnnot
     }
 
     /**
-     * <p>
-     * Logs the session out, freeing any resources. Clients who open session
-     * should make best efforts to call this when the session is closed.
-     * </p>
-     * <p>
-     * Note that clients may not always be able to call logout (whether forced
-     * or not). Mailboxes that create sessions which are expensive to maintain
-     * <code>MUST</code> retain a reference and periodically check
-     * {@link MailboxSession#isOpen()}.
-     * </p>
-     * <p>
-     * Note that implementations much be aware that it is possible that this
-     * method may be called more than once with the same session.
-     * </p>
-     * 
-     * @param session
-     *            not null
-     * @param force
-     *            true when the session logout is forced by premature connection
-     *            termination
-     * @throws MailboxException
-     *             when logout fails
-     */
-    default void logout(MailboxSession session, boolean force) throws MailboxException {
-        logout(session);
-    }
-
-    /**
      * Return a unmodifiable {@link List} of {@link MailboxPath} objects
      */
     List<MailboxPath> list(MailboxSession session) throws MailboxException;
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressContract.java
index 0112994..3bf6d8f 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressContract.java
@@ -71,7 +71,7 @@ public interface MailboxManagerStressContract<T extends MailboxManager> {
                 uList.add(u);
             }, new MailboxIdRegistrationKey(mailboxId));
         getManager().endProcessingRequest(session);
-        getManager().logout(session, false);
+        getManager().logout(session);
 
         final AtomicBoolean fail = new AtomicBoolean(false);
         final ConcurrentHashMap<MessageUid, Object> uids = new ConcurrentHashMap<>();
@@ -100,7 +100,7 @@ public interface MailboxManagerStressContract<T extends MailboxManager> {
                         fail.set(true);
                     }
                     getManager().endProcessingRequest(mailboxSession);
-                    getManager().logout(mailboxSession, false);
+                    getManager().logout(mailboxSession);
                 } catch (Exception e) {
                     e.printStackTrace();
                     fail.set(true);
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 91bd97f..79a9fb0 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -144,8 +144,8 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
     }
 
     @AfterEach
-    void tearDown() throws Exception {
-        mailboxManager.logout(session, false);
+    void tearDown() {
+        mailboxManager.logout(session);
         mailboxManager.endProcessingRequest(session);
     }
 
@@ -1591,11 +1591,11 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
         }
 
         @Test
-        void closingSessionShouldWork() throws Exception {
+        void closingSessionShouldWork() {
             session = mailboxManager.createSystemSession(USER_1);
             mailboxManager.startProcessingRequest(session);
 
-            mailboxManager.logout(session, false);
+            mailboxManager.logout(session);
             mailboxManager.endProcessingRequest(session);
 
             assertThat(session.isOpen()).isFalse();
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/mock/DataProvisioner.java b/mailbox/api/src/test/java/org/apache/james/mailbox/mock/DataProvisioner.java
index ec59bee..e25ed5c 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/mock/DataProvisioner.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/mock/DataProvisioner.java
@@ -30,8 +30,6 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 
-import com.github.fge.lambdas.Throwing;
-
 public class DataProvisioner {
     
     /**
@@ -81,10 +79,10 @@ public class DataProvisioner {
         IntStream.range(0, USER_COUNT)
             .mapToObj(i -> "user" + i + "@" + domain)
             .map(Username::of)
-            .forEach(Throwing.consumer(user -> provisionUser(mailboxManager, user)));
+            .forEach(user -> provisionUser(mailboxManager, user));
     }
 
-    private static void provisionUser(MailboxManager mailboxManager, Username user) throws MailboxException {
+    private static void provisionUser(MailboxManager mailboxManager, Username user) {
         MailboxSession mailboxSession = mailboxManager.createSystemSession(user);
         mailboxManager.startProcessingRequest(mailboxSession);
 
@@ -96,7 +94,7 @@ public class DataProvisioner {
             .forEach(name ->  createSubSubMailboxes(mailboxManager, mailboxSession, name));
 
         mailboxManager.endProcessingRequest(mailboxSession);
-        mailboxManager.logout(mailboxSession, true);
+        mailboxManager.logout(mailboxSession);
     }
 
     private static void createSubSubMailboxes(MailboxManager mailboxManager,MailboxSession mailboxSession, String subFolderName) {
diff --git a/mailbox/tools/copier/src/test/java/org/apache/james/mailbox/tools/copier/MailboxCopierTest.java b/mailbox/tools/copier/src/test/java/org/apache/james/mailbox/tools/copier/MailboxCopierTest.java
index e51ce03..06dc53e 100644
--- a/mailbox/tools/copier/src/test/java/org/apache/james/mailbox/tools/copier/MailboxCopierTest.java
+++ b/mailbox/tools/copier/src/test/java/org/apache/james/mailbox/tools/copier/MailboxCopierTest.java
@@ -126,8 +126,7 @@ public class MailboxCopierTest {
         }
 
         mailboxManager.endProcessingRequest(mailboxSession);
-        mailboxManager.logout(mailboxSession, true);
-
+        mailboxManager.logout(mailboxSession);
     }
 
     /**
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
index d2a2270..2abd31d 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
@@ -104,7 +104,7 @@ public abstract class JamesImapHostSystem implements ImapHostSystem, GrantRights
         MailboxSession mailboxSession = mailboxManager.createSystemSession(mailboxPath.getUser());
         mailboxManager.startProcessingRequest(mailboxSession);
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
-        mailboxManager.logout(mailboxSession, true);
+        mailboxManager.logout(mailboxSession);
         mailboxManager.endProcessingRequest(mailboxSession);
     }
 
@@ -119,7 +119,7 @@ public abstract class JamesImapHostSystem implements ImapHostSystem, GrantRights
                 .rights(rights)
                 .asAddition()),
             mailboxManager.createSystemSession(username));
-        mailboxManager.logout(mailboxSession, true);
+        mailboxManager.logout(mailboxSession);
         mailboxManager.endProcessingRequest(mailboxSession);
     }
 
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/LogoutProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/LogoutProcessor.java
index c6b9e8c..338f8f3 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/LogoutProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/LogoutProcessor.java
@@ -22,14 +22,12 @@ package org.apache.james.imap.processor;
 import java.io.Closeable;
 
 import org.apache.james.imap.api.ImapSessionUtils;
-import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.message.request.LogoutRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;
 import org.slf4j.Logger;
@@ -45,16 +43,11 @@ public class LogoutProcessor extends AbstractMailboxProcessor<LogoutRequest> {
 
     @Override
     protected void processRequest(LogoutRequest request, ImapSession session, Responder responder) {
-        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
-        try {
-            getMailboxManager().logout(mailboxSession, false);
-            session.logout();
-            bye(responder);
-            okComplete(request, responder);
-        } catch (MailboxException e) {
-            LOGGER.error("Logout failed for user {}", mailboxSession.getUser().asString(), e);
-            no(request, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
-        }
+        MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        getMailboxManager().logout(mailboxSession);
+        session.logout();
+        bye(responder);
+        okComplete(request, responder);
     }
 
     @Override
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
index 632210f..1584d3c 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
@@ -28,7 +28,6 @@ import org.apache.james.imap.message.request.SystemMessage;
 import org.apache.james.imap.processor.base.AbstractChainedProcessor;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.util.MDCBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,17 +47,13 @@ public class SystemMessageProcessor extends AbstractChainedProcessor<SystemMessa
 
     @Override
     protected void doProcess(SystemMessage message, Responder responder, ImapSession session) {
-        try {
-            switch (message) {
+        switch (message) {
             case FORCE_LOGOUT:
                 forceLogout(session);
                 break;
             default:
                 LOGGER.info("Unknown system message {}", message);
                 break;
-            }
-        } catch (MailboxException e) {
-            LOGGER.error("Cannot force logout", e);
         }
     }
 
@@ -67,16 +62,14 @@ public class SystemMessageProcessor extends AbstractChainedProcessor<SystemMessa
      * 
      * @param imapSession
      *            not null
-     * @throws MailboxException
-     *             when forced logout fails
      */
-    private void forceLogout(ImapSession imapSession) throws MailboxException {
+    private void forceLogout(ImapSession imapSession) {
         final MailboxSession session = ImapSessionUtils.getMailboxSession(imapSession);
         if (session == null) {
             LOGGER.trace("No mailbox session so no force logout needed");
         } else {
             session.close();
-            mailboxManager.logout(session, true);
+            mailboxManager.logout(session);
         }
     }
 
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
index 3f49929..18b3458 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
@@ -97,11 +97,7 @@ public class MailboxProbeImpl implements GuiceProbe, MailboxProbe {
     private void closeSession(MailboxSession session) {
         if (session != null) {
             mailboxManager.endProcessingRequest(session);
-            try {
-                mailboxManager.logout(session, true);
-            } catch (MailboxException e) {
-                throw new RuntimeException(e);
-            }
+            mailboxManager.logout(session);
         }
     }
 
diff --git a/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java b/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
index dddfa29..cbbaa73 100644
--- a/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
+++ b/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
@@ -196,11 +196,7 @@ public class MailboxManagerManagement extends StandardMBean implements MailboxMa
     private void closeSession(MailboxSession session) {
         if (session != null) {
             mailboxManager.endProcessingRequest(session);
-            try {
-                mailboxManager.logout(session, true);
-            } catch (MailboxException e) {
-                LOGGER.error("Can not log session out", e);
-            }
+            mailboxManager.logout(session);
         }
     }
 
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
index db0e89d..7719039 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppender.java
@@ -102,11 +102,7 @@ public class MailboxAppender {
     private void closeProcessing(MailboxSession session) throws MessagingException {
         session.close();
         try {
-            try {
-                mailboxManager.logout(session, true);
-            } catch (MailboxException e) {
-                throw new MessagingException("Can logout from mailbox", e);
-            }
+            mailboxManager.logout(session);
         } finally {
             mailboxManager.endProcessingRequest(session);
         }
diff --git a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
index cffb653..a1234d0 100644
--- a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
+++ b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
@@ -166,9 +166,7 @@ public class MailboxAdapter implements Mailbox {
     @Override
     public void close() throws IOException {
         try {
-            mailboxManager.logout(session, true);
-        } catch (MailboxException e) {
-            throw new IOException("Unable to close mailbox", e);
+            mailboxManager.logout(session);
         } finally {
             mailboxManager.endProcessingRequest(session);
         }


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


[james-project] 15/42: [Refactoring] Move ListMessagePropertiesAssert to JUnit 5

Posted by rc...@apache.org.
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 96d7a6a15c2e5239363ac05d35ed9f6569c0f88c
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:34:06 2019 +0700

    [Refactoring] Move ListMessagePropertiesAssert to JUnit 5
---
 .../mail/model/ListMessagePropertiesAssert.java    |  4 +-
 .../model/ListMessagePropertiesAssertTest.java     | 71 ++++++++++++----------
 2 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
index c15c6a0..9cfb9c4 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssert.java
@@ -29,13 +29,13 @@ import com.google.common.base.Objects;
 
 
 public class ListMessagePropertiesAssert {
-    private final List<InnerProperty> propertiesToInnerProperties(List<Property> properties) {
+    private List<InnerProperty> propertiesToInnerProperties(List<Property> properties) {
         return properties.stream()
             .map(propertyToInnerProperty())
             .collect(Guavate.toImmutableList());
     }
 
-    private final Function<Property, InnerProperty> propertyToInnerProperty() {
+    private Function<Property, InnerProperty> propertyToInnerProperty() {
         return property -> new InnerProperty(property.getNamespace(), property.getLocalName(), property.getValue());
     }
 
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssertTest.java
index 36bedef..beef849 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessagePropertiesAssertTest.java
@@ -20,62 +20,71 @@
 package org.apache.james.mailbox.store.mail.model;
 
 import static org.apache.james.mailbox.store.mail.model.ListMessagePropertiesAssert.assertProperties;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class ListMessagePropertiesAssertTest {
-    private static final String OTHER_VALUE = "US-ASCII";
-    private static final String OTHER_LOCAL_NAME = StandardNames.MIME_CONTENT_TYPE_PARAMETER_CHARSET_NAME;
-    private static final String OTHER_NAMESPACE = StandardNames.MIME_CONTENT_TYPE_PARAMETER_SPACE;
-    private static final String VALUE = "7bit";
-    private static final String LOCAL_NAME = StandardNames.MIME_CONTENT_TRANSFER_ENCODING_NAME;
-    private static final String NAMESPACE = StandardNames.NAMESPACE_RFC_2045;
+class ListMessagePropertiesAssertTest {
+    static final String OTHER_VALUE = "US-ASCII";
+    static final String OTHER_LOCAL_NAME = StandardNames.MIME_CONTENT_TYPE_PARAMETER_CHARSET_NAME;
+    static final String OTHER_NAMESPACE = StandardNames.MIME_CONTENT_TYPE_PARAMETER_SPACE;
+    static final String VALUE = "7bit";
+    static final String LOCAL_NAME = StandardNames.MIME_CONTENT_TRANSFER_ENCODING_NAME;
+    static final String NAMESPACE = StandardNames.NAMESPACE_RFC_2045;
 
-    private static final Property PROPERTY1 = new Property(NAMESPACE, LOCAL_NAME, VALUE);
-    private static final Property PROPERTY2 = new Property(OTHER_NAMESPACE, OTHER_LOCAL_NAME, OTHER_VALUE);
+    static final Property PROPERTY1 = new Property(NAMESPACE, LOCAL_NAME, VALUE);
+    static final Property PROPERTY2 = new Property(OTHER_NAMESPACE, OTHER_LOCAL_NAME, OTHER_VALUE);
     
-    private List<Property> actual;
+    List<Property> actual;
     
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         actual = ImmutableList.of(PROPERTY1, PROPERTY2);
     }
     
     @Test
-    public void containsOnlyShouldWork() {
+    void containsOnlyShouldWork() {
         assertProperties(actual).containsOnly(ImmutableList.of(createProperty(NAMESPACE, LOCAL_NAME, VALUE),
             createProperty(OTHER_NAMESPACE, OTHER_LOCAL_NAME, OTHER_VALUE)));
     }
     
-    @Test(expected = AssertionError.class)
-    public void containsOnlyShouldFailWhenNotEnoughElement() {
-        assertProperties(actual).containsOnly(ImmutableList.of(createProperty(NAMESPACE, LOCAL_NAME, VALUE)));
+    @Test
+    void containsOnlyShouldFailWhenNotEnoughElement() {
+        assertThatThrownBy(() -> assertProperties(actual).containsOnly(ImmutableList.of(
+                createProperty(NAMESPACE, LOCAL_NAME, VALUE))))
+            .isInstanceOf(AssertionError.class);
     }
 
-    @Test(expected = AssertionError.class)
-    public void containsOnlyShouldFailWhenNamespaceMismatch() {
-        assertProperties(actual).containsOnly(ImmutableList.of(createProperty(NAMESPACE, LOCAL_NAME, VALUE),
-            createProperty(OTHER_NAMESPACE, LOCAL_NAME, VALUE)));
+    @Test
+    void containsOnlyShouldFailWhenNamespaceMismatch() {
+        assertThatThrownBy(() -> assertProperties(actual).containsOnly(ImmutableList.of(
+                createProperty(NAMESPACE, LOCAL_NAME, VALUE),
+                createProperty(OTHER_NAMESPACE, LOCAL_NAME, VALUE))))
+            .isInstanceOf(AssertionError.class);
     }
 
-    @Test(expected = AssertionError.class)
-    public void containsOnlyShouldFailWhenNameMismatch() {
-        assertProperties(actual).containsOnly(ImmutableList.of(createProperty(NAMESPACE, LOCAL_NAME, VALUE),
-            createProperty(NAMESPACE, OTHER_LOCAL_NAME, VALUE)));
+    @Test
+    void containsOnlyShouldFailWhenNameMismatch() {
+        assertThatThrownBy(() -> assertProperties(actual).containsOnly(ImmutableList.of(
+                createProperty(NAMESPACE, LOCAL_NAME, VALUE),
+                createProperty(NAMESPACE, OTHER_LOCAL_NAME, VALUE))))
+            .isInstanceOf(AssertionError.class);
     }
 
-    @Test(expected = AssertionError.class)
-    public void containsOnlyShouldFailWhenValueMismatch() {
-        assertProperties(actual).containsOnly(ImmutableList.of(createProperty(NAMESPACE, LOCAL_NAME, VALUE),
-            createProperty(NAMESPACE, LOCAL_NAME, OTHER_VALUE)));
+    @Test
+    void containsOnlyShouldFailWhenValueMismatch() {
+        assertThatThrownBy(() -> assertProperties(actual).containsOnly(ImmutableList.of(
+                createProperty(NAMESPACE, LOCAL_NAME, VALUE),
+                createProperty(NAMESPACE, LOCAL_NAME, OTHER_VALUE))))
+            .isInstanceOf(AssertionError.class);
     }
 
-    private Property createProperty(String namespace, String name, String value) {
+    Property createProperty(String namespace, String name, String value) {
         return new Property(namespace, name, value);
     }
 }


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


[james-project] 20/42: [Refactoring] Move DefaultUserQuotaRootResolverTest to JUnit 5

Posted by rc...@apache.org.
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 07b742d7dc6b3e3c0c8897b621ca98eebee79885
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:47:27 2019 +0700

    [Refactoring] Move DefaultUserQuotaRootResolverTest to JUnit 5
---
 .../quota/DefaultUserQuotaRootResolverTest.java    | 62 ++++++++++++----------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolverTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolverTest.java
index 89f5967..320a8b0 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolverTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolverTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store.quota;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -37,56 +38,57 @@ import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.Lists;
 
-public class DefaultUserQuotaRootResolverTest {
+class DefaultUserQuotaRootResolverTest {
 
-    private static final Username BENWA = Username.of("benwa");
-    private static final MailboxPath MAILBOX_PATH = MailboxPath.inbox(BENWA);
-    public static final Mailbox MAILBOX = new Mailbox(MAILBOX_PATH, 10);
-    private static final MailboxPath PATH_LIKE = MailboxPath.forUser(BENWA, "%");
-    private static final MailboxPath MAILBOX_PATH_2 = MailboxPath.forUser(BENWA, "test");
-    private static final Mailbox MAILBOX_2 = new Mailbox(MAILBOX_PATH_2, 10);
-    private static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("#private&benwa", Optional.empty());
-    private static final MailboxId MAILBOX_ID = TestId.of(42);
-    public static final MailboxSession MAILBOX_SESSION = null;
+    static final Username BENWA = Username.of("benwa");
+    static final MailboxPath MAILBOX_PATH = MailboxPath.inbox(BENWA);
+    static final Mailbox MAILBOX = new Mailbox(MAILBOX_PATH, 10);
+    static final MailboxPath MAILBOX_PATH_2 = MailboxPath.forUser(BENWA, "test");
+    static final Mailbox MAILBOX_2 = new Mailbox(MAILBOX_PATH_2, 10);
+    static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("#private&benwa", Optional.empty());
+    static final MailboxId MAILBOX_ID = TestId.of(42);
+    static final MailboxSession MAILBOX_SESSION = null;
 
-    private DefaultUserQuotaRootResolver testee;
-    private MailboxSessionMapperFactory mockedFactory;
+    DefaultUserQuotaRootResolver testee;
+    MailboxSessionMapperFactory mockedFactory;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mockedFactory = mock(MailboxSessionMapperFactory.class);
         testee = new DefaultUserQuotaRootResolver(mock(SessionProvider.class), mockedFactory);
     }
 
     @Test
-    public void getQuotaRootShouldReturnUserRelatedQuotaRoot() {
+    void getQuotaRootShouldReturnUserRelatedQuotaRoot() {
         assertThat(testee.getQuotaRoot(MAILBOX_PATH)).isEqualTo(QUOTA_ROOT);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void getQuotaRootShouldThrowWhenNamespaceContainsSeparator() {
-        testee.getQuotaRoot(new MailboxPath("#pr&ivate", BENWA, "INBOX"));
+    @Test
+    void getQuotaRootShouldThrowWhenNamespaceContainsSeparator() {
+        assertThatThrownBy(() -> testee.getQuotaRoot(new MailboxPath("#pr&ivate", BENWA, "INBOX")))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void getQuotaRootShouldThrowWhenUserContainsSeparator() {
-        testee.getQuotaRoot(MailboxPath.forUser(Username.of("ben&wa"), "INBOX"));
+    @Test
+    void getQuotaRootShouldThrowWhenUserContainsSeparator() {
+        assertThatThrownBy(() -> testee.getQuotaRoot(MailboxPath.forUser(Username.of("ben&wa"), "INBOX")))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void getQuotaRootShouldWorkWhenUserIsNull() {
+    void getQuotaRootShouldWorkWhenUserIsNull() {
         QuotaRoot quotaRoot = testee.getQuotaRoot(new MailboxPath("#private", null, "INBOX"));
 
         assertThat(quotaRoot).isEqualTo(QuotaRoot.quotaRoot("#private", Optional.empty()));
     }
 
     @Test
-    public void retrieveAssociatedMailboxesShouldWork() throws Exception {
+    void retrieveAssociatedMailboxesShouldWork() throws Exception {
         MailboxMapper mockedMapper = mock(MailboxMapper.class);
         when(mockedFactory.getMailboxMapper(MAILBOX_SESSION)).thenReturn(mockedMapper);
         when(mockedMapper.findMailboxWithPathLike(any())).thenReturn(Lists.newArrayList(MAILBOX, MAILBOX_2));
@@ -94,13 +96,15 @@ public class DefaultUserQuotaRootResolverTest {
         assertThat(testee.retrieveAssociatedMailboxes(QUOTA_ROOT, MAILBOX_SESSION)).containsOnly(MAILBOX, MAILBOX_2);
     }
 
-    @Test(expected = MailboxException.class)
-    public void retrieveAssociatedMailboxesShouldThrowWhenQuotaRootContainsSeparator2Times() throws Exception {
-        testee.retrieveAssociatedMailboxes(QuotaRoot.quotaRoot("#private&be&nwa", Optional.empty()), MAILBOX_SESSION);
+    @Test
+    void retrieveAssociatedMailboxesShouldThrowWhenQuotaRootContainsSeparator2Times() throws Exception {
+        assertThatThrownBy(() -> testee.retrieveAssociatedMailboxes(
+                QuotaRoot.quotaRoot("#private&be&nwa", Optional.empty()), MAILBOX_SESSION))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
-    public void getQuotaRootShouldReturnUserValueWhenCalledWithMailboxId() throws Exception {
+    void getQuotaRootShouldReturnUserValueWhenCalledWithMailboxId() throws Exception {
         MailboxMapper mockedMapper = mock(MailboxMapper.class);
         when(mockedFactory.getMailboxMapper(any())).thenReturn(mockedMapper);
         when(mockedMapper.findMailboxById(MAILBOX_ID)).thenReturn(MAILBOX);


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


[james-project] 27/42: [Refactoring] Move BatchSizesTest to JUnit 5

Posted by rc...@apache.org.
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 de2ca978b838b5179f2a56f95759c046504d02b6
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:58:45 2019 +0700

    [Refactoring] Move BatchSizesTest to JUnit 5
---
 .../apache/james/mailbox/store/BatchSizesTest.java | 148 +++++++++------------
 1 file changed, 66 insertions(+), 82 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java
index 2495da0..c535781 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/BatchSizesTest.java
@@ -19,25 +19,21 @@
 package org.apache.james.mailbox.store;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;
 
-public class BatchSizesTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class BatchSizesTest {
 
     @Test
-    public void shouldRespectJavaBeanContract() {
+    void shouldRespectJavaBeanContract() {
         EqualsVerifier.forClass(BatchSizes.class).verify();
     }
 
     @Test
-    public void defaultValuesShouldReturnDefaultForEachParameters() {
+    void defaultValuesShouldReturnDefaultForEachParameters() {
         BatchSizes batchSizes = BatchSizes.defaultValues();
         assertThat(batchSizes.getFetchMetadata()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
         assertThat(batchSizes.getFetchHeaders()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
@@ -48,7 +44,7 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void uniqueBatchSizeShouldSetTheSameValueToAllAttributes() {
+    void uniqueBatchSizeShouldSetTheSameValueToAllAttributes() {
         int batchSize = 10;
         BatchSizes batchSizes = BatchSizes.uniqueBatchSize(batchSize);
         assertThat(batchSizes.getFetchMetadata()).isEqualTo(batchSize);
@@ -60,110 +56,98 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void fetchMetadataShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchMetadata(-1);
+    void fetchMetadataShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchMetadata(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchMetadataShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchMetadata(0);
+    void fetchMetadataShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchMetadata(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchHeadersShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchHeaders(-1);
+    void fetchHeadersShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchHeaders(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchHeadersShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchHeaders(0);
+    void fetchHeadersShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchHeaders(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchBodyShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchBody(-1);
+    void fetchBodyShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchBody(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchBodyShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchBody(0);
+    void fetchBodyShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchBody(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchFullShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchFull(-1);
+    void fetchFullShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchFull(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void fetchFullShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .fetchFull(0);
+    void fetchFullShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .fetchFull(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void copyBatchSizeShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .copyBatchSize(-1);
+    void copyBatchSizeShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .copyBatchSize(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void copyBatchSizeShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .copyBatchSize(0);
+    void copyBatchSizeShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .copyBatchSize(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void moveBatchSizeShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .moveBatchSize(-1);
+    void moveBatchSizeShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .moveBatchSize(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void moveBatchSizeShouldThrowWhenZero() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        BatchSizes.builder()
-            .moveBatchSize(0);
+    void moveBatchSizeShouldThrowWhenZero() {
+        assertThatThrownBy(() -> BatchSizes.builder()
+                .moveBatchSize(0))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void buildShouldSetDefaultValueToFetchMetadataWhenNotGiven() {
+    void buildShouldSetDefaultValueToFetchMetadataWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getFetchMetadata()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
     }
 
     @Test
-    public void buildShouldSetValueToFetchMetadataWhenGiven() {
+    void buildShouldSetValueToFetchMetadataWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .fetchMetadata(expected)
@@ -172,14 +156,14 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void buildShouldSetDefaultValueToFetchHeadersWhenNotGiven() {
+    void buildShouldSetDefaultValueToFetchHeadersWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getFetchHeaders()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
     }
 
     @Test
-    public void buildShouldSetValueToFetchHeadersWhenGiven() {
+    void buildShouldSetValueToFetchHeadersWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .fetchHeaders(expected)
@@ -188,14 +172,14 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void buildShouldSetDefaultValueToFetchBodyWhenNotGiven() {
+    void buildShouldSetDefaultValueToFetchBodyWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getFetchBody()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
     }
 
     @Test
-    public void buildShouldSetValueToFetchBodyWhenGiven() {
+    void buildShouldSetValueToFetchBodyWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .fetchBody(expected)
@@ -204,14 +188,14 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void buildShouldSetDefaultValueToFetchFullWhenNotGiven() {
+    void buildShouldSetDefaultValueToFetchFullWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getFetchFull()).isEqualTo(BatchSizes.DEFAULT_BATCH_SIZE);
     }
 
     @Test
-    public void buildShouldSetValueToFetchFullWhenGiven() {
+    void buildShouldSetValueToFetchFullWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .fetchFull(expected)
@@ -220,14 +204,14 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void buildShouldSetDefaultValueToCopyBatchSizeWhenNotGiven() {
+    void buildShouldSetDefaultValueToCopyBatchSizeWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getCopyBatchSize()).isEmpty();
     }
 
     @Test
-    public void buildShouldSetValueToCopyBatchSizeWhenGiven() {
+    void buildShouldSetValueToCopyBatchSizeWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .copyBatchSize(expected)
@@ -236,14 +220,14 @@ public class BatchSizesTest {
     }
 
     @Test
-    public void buildShouldSetDefaultValueToMoveBatchSizeWhenNotGiven() {
+    void buildShouldSetDefaultValueToMoveBatchSizeWhenNotGiven() {
         BatchSizes batchSizes = BatchSizes.builder()
                 .build();
         assertThat(batchSizes.getMoveBatchSize()).isEmpty();
     }
 
     @Test
-    public void buildShouldSetValueToMoveBatchSizeWhenGiven() {
+    void buildShouldSetValueToMoveBatchSizeWhenGiven() {
         int expected = 123;
         BatchSizes batchSizes = BatchSizes.builder()
                 .moveBatchSize(expected)


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


[james-project] 10/42: [Refactoring] Move DelegatingMailboxMessageTest to JUnit 5

Posted by rc...@apache.org.
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 b4f70be9a549cfa4d87917ebaccf247df779edf6
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:16:55 2019 +0700

    [Refactoring] Move DelegatingMailboxMessageTest to JUnit 5
---
 .../mailbox/store/mail/model/DelegatingMailboxMessageTest.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessageTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessageTest.java
index 567c4e3..56e6c53 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessageTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessageTest.java
@@ -23,12 +23,12 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.store.MessageBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class DelegatingMailboxMessageTest {
+class DelegatingMailboxMessageTest {
     
     @Test
-    public void testShouldReturnPositiveWhenFirstGreaterThanSecond()
+    void testShouldReturnPositiveWhenFirstGreaterThanSecond()
             throws Exception {
         MailboxMessage one = buildMessage(100);
         MailboxMessage two = buildMessage(99);
@@ -42,7 +42,7 @@ public class DelegatingMailboxMessageTest {
     }
 
     @Test
-    public void testShouldReturnNegativeWhenFirstLessThanSecond()
+    void testShouldReturnNegativeWhenFirstLessThanSecond()
             throws Exception {
         MailboxMessage one = buildMessage(98);
         MailboxMessage two = buildMessage(99);
@@ -50,7 +50,7 @@ public class DelegatingMailboxMessageTest {
     }
 
     @Test
-    public void testShouldReturnZeroWhenFirstEqualsSecond() throws Exception {
+    void testShouldReturnZeroWhenFirstEqualsSecond() throws Exception {
         MailboxMessage one = buildMessage(90);
         MailboxMessage two = buildMessage(90);
         assertThat(one.compareTo(two)).isEqualTo(0);


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


[james-project] 37/42: [Refactoring] Move StoreBlobManagerTest to JUnit 5

Posted by rc...@apache.org.
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 73a9151d3f815f9b5bec0c846c45876b8179ee88
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:10:38 2019 +0700

    [Refactoring] Move StoreBlobManagerTest to JUnit 5
---
 .../james/mailbox/store/StoreBlobManagerTest.java  | 60 +++++++++++-----------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreBlobManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreBlobManagerTest.java
index 26bfd1d..91b6661 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreBlobManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreBlobManagerTest.java
@@ -45,27 +45,27 @@ import org.apache.james.mailbox.model.Content;
 import org.apache.james.mailbox.model.FetchGroup;
 import org.apache.james.mailbox.model.MessageResult;
 import org.apache.james.mailbox.model.TestMessageId;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class StoreBlobManagerTest {
-    public static final String ID = "abc";
-    public static final AttachmentId ATTACHMENT_ID = AttachmentId.from(ID);
-    public static final String CONTENT_TYPE = "text/plain";
-    public static final byte[] BYTES = "abc".getBytes(StandardCharsets.UTF_8);
-    public static final TestMessageId MESSAGE_ID = TestMessageId.of(125);
-    public static final BlobId BLOB_ID_ATTACHMENT = BlobId.fromString(ID);
-    public static final BlobId BLOB_ID_MESSAGE = BlobId.fromString(MESSAGE_ID.serialize());
-    private StoreBlobManager blobManager;
-
-    private AttachmentManager attachmentManager;
-    private MessageIdManager messageIdManager;
-    private MailboxSession session;
-
-    @Before
-    public void setUp() {
+class StoreBlobManagerTest {
+    static final String ID = "abc";
+    static final AttachmentId ATTACHMENT_ID = AttachmentId.from(ID);
+    static final String CONTENT_TYPE = "text/plain";
+    static final byte[] BYTES = "abc".getBytes(StandardCharsets.UTF_8);
+    static final TestMessageId MESSAGE_ID = TestMessageId.of(125);
+    static final BlobId BLOB_ID_ATTACHMENT = BlobId.fromString(ID);
+    static final BlobId BLOB_ID_MESSAGE = BlobId.fromString(MESSAGE_ID.serialize());
+    StoreBlobManager blobManager;
+
+    AttachmentManager attachmentManager;
+    MessageIdManager messageIdManager;
+    MailboxSession session;
+
+    @BeforeEach
+    void setUp() {
         attachmentManager = mock(AttachmentManager.class);
         messageIdManager = mock(MessageIdManager.class);
         session = MailboxSessionUtil.create(Username.of("user"));
@@ -74,7 +74,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldReturnBlobWhenAttachment() throws Exception {
+    void retrieveShouldReturnBlobWhenAttachment() throws Exception {
         when(attachmentManager.getAttachment(ATTACHMENT_ID, session))
             .thenReturn(Attachment.builder()
                 .attachmentId(ATTACHMENT_ID)
@@ -91,7 +91,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowWhenNotFound() throws Exception {
+    void retrieveShouldThrowWhenNotFound() throws Exception {
         when(attachmentManager.getAttachment(ATTACHMENT_ID, session))
             .thenThrow(new AttachmentNotFoundException(ID));
         when(messageIdManager.getMessages(ImmutableList.of(MESSAGE_ID), FetchGroup.FULL_CONTENT, session))
@@ -102,7 +102,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldReturnBlobWhenMessage() throws Exception {
+    void retrieveShouldReturnBlobWhenMessage() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -122,7 +122,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnMailboxExceptionWhenRetrievingAttachment() throws Exception {
+    void retrieveShouldThrowOnMailboxExceptionWhenRetrievingAttachment() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new MailboxException());
 
@@ -131,7 +131,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingAttachment() throws Exception {
+    void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingAttachment() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new RuntimeException());
 
@@ -140,7 +140,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessage() throws Exception {
+    void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessage() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -152,7 +152,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnMailboxExceptionWhenRetrievingMessage() throws Exception {
+    void retrieveShouldThrowOnMailboxExceptionWhenRetrievingMessage() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -164,7 +164,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnMailboxExceptionWhenRetrievingMessageContent() throws Exception {
+    void retrieveShouldThrowOnMailboxExceptionWhenRetrievingMessageContent() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -178,7 +178,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessageContent() throws Exception {
+    void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessageContent() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -192,7 +192,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnIOExceptionWhenRetrievingMessageContentInputStream() throws Exception {
+    void retrieveShouldThrowOnIOExceptionWhenRetrievingMessageContentInputStream() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -208,7 +208,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessageContentInputStream() throws Exception {
+    void retrieveShouldThrowOnRuntimeExceptionWhenRetrievingMessageContentInputStream() throws Exception {
         when(attachmentManager.getAttachment(any(), any()))
             .thenThrow(new AttachmentNotFoundException(ID));
 
@@ -224,7 +224,7 @@ public class StoreBlobManagerTest {
     }
 
     @Test
-    public void toBlobIdShouldReturnBlobIdCorrespondingToAMessageId() {
+    void toBlobIdShouldReturnBlobIdCorrespondingToAMessageId() {
         assertThat(blobManager.toBlobId(MESSAGE_ID))
             .isEqualTo(BlobId.fromString("125"));
     }


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


[james-project] 04/42: [Refactoring] Move JsoupTextExtractorTest to JUnit 5

Posted by rc...@apache.org.
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 cb4bcdd094fce525ff0b80ef02276bc7f008da45
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:50:50 2019 +0700

    [Refactoring] Move JsoupTextExtractorTest to JUnit 5
---
 .../store/extractor/JsoupTextExtractorTest.java    | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/JsoupTextExtractorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/JsoupTextExtractorTest.java
index ae7e281..64bd9b9 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/JsoupTextExtractorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/JsoupTextExtractorTest.java
@@ -27,19 +27,19 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.james.mailbox.extractor.ParsedContent;
 import org.apache.james.mailbox.extractor.TextExtractor;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class JsoupTextExtractorTest {
-    private TextExtractor textExtractor;
+class JsoupTextExtractorTest {
+    TextExtractor textExtractor;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         textExtractor = new JsoupTextExtractor();
     }
 
     @Test
-    public void extractedTextFromHtmlShouldNotContainTheContentOfTitleTag() throws Exception {
+    void extractedTextFromHtmlShouldNotContainTheContentOfTitleTag() throws Exception {
         InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/html.txt");
 
         assertThat(textExtractor.extractContent(inputStream, "text/html").getTextualContent().get())
@@ -47,7 +47,7 @@ public class JsoupTextExtractorTest {
     }
 
     @Test
-    public void extractContentShouldHandlePlainText() throws Exception {
+    void extractContentShouldHandlePlainText() throws Exception {
         InputStream inputStream = new ByteArrayInputStream("myText".getBytes(StandardCharsets.UTF_8));
 
         assertThat(textExtractor.extractContent(inputStream, "text/plain").getTextualContent())
@@ -55,7 +55,7 @@ public class JsoupTextExtractorTest {
     }
 
     @Test
-    public void extractContentShouldHandleArbitraryTextMediaType() throws Exception {
+    void extractContentShouldHandleArbitraryTextMediaType() throws Exception {
         InputStream inputStream = new ByteArrayInputStream("myText".getBytes(StandardCharsets.UTF_8));
 
         assertThat(textExtractor.extractContent(inputStream, "text/arbitrary").getTextualContent())
@@ -63,13 +63,13 @@ public class JsoupTextExtractorTest {
     }
 
     @Test
-    public void extractContentShouldReturnEmptyWhenNullData() throws Exception {
+    void extractContentShouldReturnEmptyWhenNullData() throws Exception {
         assertThat(textExtractor.extractContent(null, "text/html"))
             .isEqualTo(ParsedContent.empty());
     }
 
     @Test
-    public void extractContentShouldReturnEmptyWhenNullContentType() throws Exception {
+    void extractContentShouldReturnEmptyWhenNullContentType() throws Exception {
         InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/html.txt");
 
         assertThat(textExtractor.extractContent(inputStream, null))


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


[james-project] 34/42: [Refactoring] Move SearchUtilsRFC822Test to JUnit 5

Posted by rc...@apache.org.
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 d3621caf93e46f884ea74a23b0bb5f9b78a68eba
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:07:39 2019 +0700

    [Refactoring] Move SearchUtilsRFC822Test to JUnit 5
---
 .../james/mailbox/store/SearchUtilsRFC822Test.java | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsRFC822Test.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsRFC822Test.java
index f819980..f983904 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsRFC822Test.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsRFC822Test.java
@@ -32,20 +32,20 @@ import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.MessageSearches;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SearchUtilsRFC822Test {
+class SearchUtilsRFC822Test {
 
-    private static final String FROM_ADDRESS = "Harry <harry@example.org";
+    static final String FROM_ADDRESS = "Harry <harry@example.org";
 
-    private static final String SUBJECT_PART = "Mixed";
+    static final String SUBJECT_PART = "Mixed";
 
-    private static final String CUSTARD = "CUSTARD";
+    static final String CUSTARD = "CUSTARD";
 
-    private static final String RHUBARD = "Rhubard";
+    static final String RHUBARD = "Rhubard";
 
-    private static final String BODY = "This is a simple email\r\n "
+    static final String BODY = "This is a simple email\r\n "
             + "It has " + RHUBARD + ".\r\n" + "It has " + CUSTARD + ".\r\n"
             + "It needs naught else.\r\n";
 
@@ -53,10 +53,10 @@ public class SearchUtilsRFC822Test {
 
     Collection<MessageUid> recent;
 
-    private MessageSearches messageSearches;
+    MessageSearches messageSearches;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         recent = new ArrayList<>();
         MessageBuilder builder = new MessageBuilder();
         builder.header("From", "Alex <alex@example.org");
@@ -74,7 +74,7 @@ public class SearchUtilsRFC822Test {
 
 
     @Test
-    public void testBodyShouldMatchPhraseInBody() throws Exception {
+    void testBodyShouldMatchPhraseInBody() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(CUSTARD), row,
                 recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery
@@ -82,7 +82,7 @@ public class SearchUtilsRFC822Test {
     }
 
     @Test
-    public void testBodyMatchShouldBeCaseInsensitive() throws Exception {
+    void testBodyMatchShouldBeCaseInsensitive() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(RHUBARD), row,
                 recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(RHUBARD
@@ -92,7 +92,7 @@ public class SearchUtilsRFC822Test {
     }
 
     @Test
-    public void testBodyShouldNotMatchPhraseOnlyInHeader() throws Exception {
+    void testBodyShouldNotMatchPhraseOnlyInHeader() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(FROM_ADDRESS),
                 row, recent)).isFalse();
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(SUBJECT_PART),
@@ -100,7 +100,7 @@ public class SearchUtilsRFC822Test {
     }
 
     @Test
-    public void testTextShouldMatchPhraseInBody() throws Exception {
+    void testTextShouldMatchPhraseInBody() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(CUSTARD), row,
                 recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery
@@ -108,7 +108,7 @@ public class SearchUtilsRFC822Test {
     }
 
     @Test
-    public void testTextMatchShouldBeCaseInsensitive() throws Exception {
+    void testTextMatchShouldBeCaseInsensitive() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(RHUBARD), row,
                 recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(RHUBARD
@@ -118,7 +118,7 @@ public class SearchUtilsRFC822Test {
     }
 
     @Test
-    public void testBodyShouldMatchPhraseOnlyInHeader() throws Exception {
+    void testBodyShouldMatchPhraseOnlyInHeader() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(FROM_ADDRESS),
                 row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(SUBJECT_PART),


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


[james-project] 41/42: [Refactoring] Move StoreRightManagerTest to JUnit 5

Posted by rc...@apache.org.
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 bddcd4c16cbfbe2d1ad3a0892e9eea2872ecc839
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:21:27 2019 +0700

    [Refactoring] Move StoreRightManagerTest to JUnit 5
---
 .../james/mailbox/store/StoreRightManagerTest.java | 70 +++++++++++-----------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
index 5de12a3..3dc1564 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
@@ -50,20 +50,20 @@ import org.apache.james.mailbox.model.MailboxACL.Right;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class StoreRightManagerTest {
+class StoreRightManagerTest {
 
-    private static final long UID_VALIDITY = 3421L;
-    private StoreRightManager storeRightManager;
-    private MailboxSession aliceSession;
-    private MailboxACLResolver mailboxAclResolver;
-    private GroupMembershipResolver groupMembershipResolver;
-    private MailboxMapper mockedMailboxMapper;
+    static final long UID_VALIDITY = 3421L;
+    StoreRightManager storeRightManager;
+    MailboxSession aliceSession;
+    MailboxACLResolver mailboxAclResolver;
+    GroupMembershipResolver groupMembershipResolver;
+    MailboxMapper mockedMailboxMapper;
 
-    @Before
-    public void setup() throws MailboxException {
+    @BeforeEach
+    void setup() throws MailboxException {
         aliceSession = MailboxSessionUtil.create(MailboxFixture.ALICE);
         MailboxSessionMapperFactory mockedMapperFactory = mock(MailboxSessionMapperFactory.class);
         mockedMailboxMapper = mock(MailboxMapper.class);
@@ -77,7 +77,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void hasRightShouldThrowMailboxNotFoundExceptionWhenMailboxDoesNotExist() throws MailboxException {
+    void hasRightShouldThrowMailboxNotFoundExceptionWhenMailboxDoesNotExist() throws MailboxException {
         MailboxPath mailboxPath = MailboxPath.forUser(MailboxFixture.ALICE, "unexisting mailbox");
         when(mockedMailboxMapper.findMailboxByPath(mailboxPath))
             .thenThrow(new MailboxNotFoundException(""));
@@ -88,7 +88,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void hasRightShouldReturnTrueWhenTheUserOwnTheMailbox() throws MailboxException {
+    void hasRightShouldReturnTrueWhenTheUserOwnTheMailbox() throws MailboxException {
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(ALICE, MailboxConstants.INBOX), UID_VALIDITY);
 
         assertThat(storeRightManager.hasRight(mailbox, Right.Write, aliceSession))
@@ -96,7 +96,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void hasRightShouldReturnTrueWhenTheUserDoesNotOwnTheMailboxButHaveTheCorrectRightOnIt() throws MailboxException {
+    void hasRightShouldReturnTrueWhenTheUserDoesNotOwnTheMailboxButHaveTheCorrectRightOnIt() throws MailboxException {
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.Write)));
 
@@ -105,7 +105,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void hasRightShouldReturnTrueWhenTheUserDoesNotOwnTheMailboxButHasAtLeastTheCorrectRightOnIt() throws MailboxException {
+    void hasRightShouldReturnTrueWhenTheUserDoesNotOwnTheMailboxButHasAtLeastTheCorrectRightOnIt() throws MailboxException {
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.Write, Right.Lookup)));
 
@@ -114,7 +114,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void hasRightShouldReturnFalseWhenTheUserDoesNotOwnTheMailboxAndHasNoRightOnIt() throws MailboxException {
+    void hasRightShouldReturnFalseWhenTheUserDoesNotOwnTheMailboxAndHasNoRightOnIt() throws MailboxException {
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
 
         assertThat(storeRightManager.hasRight(mailbox, Right.Write, aliceSession))
@@ -122,7 +122,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnTrueWhenUserHasInsertRightOnMailbox() throws Exception {
+    void isReadWriteShouldReturnTrueWhenUserHasInsertRightOnMailbox() throws Exception {
         Flags flags = new Flags();
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.Insert)));
@@ -132,7 +132,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnTrueWhenUserHasPerformExpungeRightOnMailbox() throws Exception {
+    void isReadWriteShouldReturnTrueWhenUserHasPerformExpungeRightOnMailbox() throws Exception {
         Flags flags = new Flags();
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.PerformExpunge)));
@@ -142,7 +142,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnTrueWhenUserHasDeleteMessagesRightOnMailboxAndFlagsContainDeletedFlag() throws Exception {
+    void isReadWriteShouldReturnTrueWhenUserHasDeleteMessagesRightOnMailboxAndFlagsContainDeletedFlag() throws Exception {
         Flags flags = new Flags(Flags.Flag.DELETED);
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.DeleteMessages)));
@@ -152,7 +152,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnFalseWhenUserHasDeleteMessagesRightOnMailboxButFlagsDoesNotContainDeletedFlag() throws Exception {
+    void isReadWriteShouldReturnFalseWhenUserHasDeleteMessagesRightOnMailboxButFlagsDoesNotContainDeletedFlag() throws Exception {
         Flags flags = new Flags();
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.DeleteMessages)));
@@ -162,7 +162,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnTrueWhenUserHasWriteSeenFlagRightOnMailboxAndFlagsContainSeenFlag() throws Exception {
+    void isReadWriteShouldReturnTrueWhenUserHasWriteSeenFlagRightOnMailboxAndFlagsContainSeenFlag() throws Exception {
         Flags flags = new Flags(Flags.Flag.SEEN);
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.WriteSeenFlag)));
@@ -172,7 +172,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnFalseWhenUserHasWriteSeenFlagRightOnMailboxAndFlagsDoesNotContainSeenFlag() throws Exception {
+    void isReadWriteShouldReturnFalseWhenUserHasWriteSeenFlagRightOnMailboxAndFlagsDoesNotContainSeenFlag() throws Exception {
         Flags flags = new Flags();
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.WriteSeenFlag)));
@@ -182,7 +182,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnTrueWhenUserHasWriteRightOnMailboxAndFlagsContainAnsweredFlag() throws Exception {
+    void isReadWriteShouldReturnTrueWhenUserHasWriteRightOnMailboxAndFlagsContainAnsweredFlag() throws Exception {
         Flags flags = new Flags(Flags.Flag.ANSWERED);
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.Write)));
@@ -192,7 +192,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void isReadWriteShouldReturnFalseWhenUserDoesNotHaveInsertOrPerformExpungeRightOnMailboxAndNullFlag() throws Exception {
+    void isReadWriteShouldReturnFalseWhenUserDoesNotHaveInsertOrPerformExpungeRightOnMailboxAndNullFlag() throws Exception {
         Mailbox mailbox = new Mailbox(MailboxPath.forUser(BOB, MailboxConstants.INBOX), UID_VALIDITY);
         mailbox.setACL(new MailboxACL(new MailboxACL.Entry(MailboxFixture.ALICE.asString(), Right.Administer)));
 
@@ -201,7 +201,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void filteredForSessionShouldBeIdentityWhenOwner() throws UnsupportedRightException {
+    void filteredForSessionShouldBeIdentityWhenOwner() throws UnsupportedRightException {
         MailboxACL acl = new MailboxACL()
             .apply(MailboxACL.command().rights(Right.Read, Right.Write).forUser(BOB).asAddition())
             .apply(MailboxACL.command().rights(Right.Read, Right.Write, Right.Administer).forUser(CEDRIC).asAddition());
@@ -211,7 +211,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void filteredForSessionShouldBeIdentityWhenAdmin() throws UnsupportedRightException {
+    void filteredForSessionShouldBeIdentityWhenAdmin() throws UnsupportedRightException {
         MailboxACL acl = new MailboxACL()
             .apply(MailboxACL.command().rights(Right.Read, Right.Write).forUser(BOB).asAddition())
             .apply(MailboxACL.command().rights(Right.Read, Right.Write, Right.Administer).forUser(CEDRIC).asAddition());
@@ -221,7 +221,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void filteredForSessionShouldContainOnlyLoggedUserWhenReadWriteAccess() throws UnsupportedRightException {
+    void filteredForSessionShouldContainOnlyLoggedUserWhenReadWriteAccess() throws UnsupportedRightException {
         MailboxACL acl = new MailboxACL()
             .apply(MailboxACL.command().rights(Right.Read, Right.Write).forUser(BOB).asAddition())
             .apply(MailboxACL.command().rights(Right.Read, Right.Write, Right.Administer).forUser(CEDRIC).asAddition());
@@ -231,32 +231,32 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void areDomainsDifferentShouldReturnTrueWhenOneHasDomainNotTheOther() {
+    void areDomainsDifferentShouldReturnTrueWhenOneHasDomainNotTheOther() {
         assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser"))).isTrue();
     }
 
     @Test
-    public void areDomainsDifferentShouldReturnTrueWhenOtherHasDomainNotTheOne() {
+    void areDomainsDifferentShouldReturnTrueWhenOtherHasDomainNotTheOne() {
         assertThat(storeRightManager.areDomainsDifferent("user", Username.of("otherUser@domain.org"))).isTrue();
     }
 
     @Test
-    public void areDomainsDifferentShouldReturnFalseWhenNoDomain() {
+    void areDomainsDifferentShouldReturnFalseWhenNoDomain() {
         assertThat(storeRightManager.areDomainsDifferent("user", Username.of("otherUser"))).isFalse();
     }
 
     @Test
-    public void areDomainsDifferentShouldReturnTrueWhenDomainsAreDifferent() {
+    void areDomainsDifferentShouldReturnTrueWhenDomainsAreDifferent() {
         assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser@otherdomain.org"))).isTrue();
     }
 
     @Test
-    public void areDomainsDifferentShouldReturnFalseWhenDomainsAreIdentical() {
+    void areDomainsDifferentShouldReturnFalseWhenDomainsAreIdentical() {
         assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser@domain.org"))).isFalse();
     }
 
     @Test
-    public void assertSharesBelongsToUserDomainShouldThrowWhenOneDomainIsDifferent() throws Exception  {
+    void assertSharesBelongsToUserDomainShouldThrowWhenOneDomainIsDifferent() throws Exception  {
         MailboxACL mailboxACL = new MailboxACL(new MailboxACL.Entry("a@domain.org", Right.Write), 
                 new MailboxACL.Entry("b@otherdomain.org", Right.Write), 
                 new MailboxACL.Entry("c@domain.org", Right.Write));
@@ -266,7 +266,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void assertSharesBelongsToUserDomainShouldNotThrowWhenDomainsAreIdentical() throws Exception  {
+    void assertSharesBelongsToUserDomainShouldNotThrowWhenDomainsAreIdentical() throws Exception  {
         MailboxACL mailboxACL = new MailboxACL(new MailboxACL.Entry("a@domain.org", Right.Write), 
                 new MailboxACL.Entry("b@domain.org", Right.Write), 
                 new MailboxACL.Entry("c@domain.org", Right.Write));
@@ -275,7 +275,7 @@ public class StoreRightManagerTest {
     }
 
     @Test
-    public void applyRightsCommandShouldThrowWhenDomainsAreDifferent() {
+    void applyRightsCommandShouldThrowWhenDomainsAreDifferent() {
         MailboxPath mailboxPath = MailboxPath.forUser(Username.of("user@domain.org"), "mailbox");
         ACLCommand aclCommand = MailboxACL.command()
             .forUser(Username.of("otherUser@otherdomain.org"))


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


[james-project] 35/42: [Refactoring] Move SearchUtilsTest to JUnit 5

Posted by rc...@apache.org.
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 86903bc9e1af6e348e588025fbec13122ebc5e08
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:08:44 2019 +0700

    [Refactoring] Move SearchUtilsTest to JUnit 5
---
 .../james/mailbox/store/SearchUtilsTest.java       | 124 ++++++++++-----------
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
index ffb7784..f71d8df 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
@@ -38,45 +38,45 @@ import org.apache.james.mailbox.model.SearchQuery.AddressType;
 import org.apache.james.mailbox.model.SearchQuery.DateResolution;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.MessageSearches;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SearchUtilsTest {
+class SearchUtilsTest {
 
-    private static final String RHUBARD = "Rhubard";
+    static final String RHUBARD = "Rhubard";
 
-    private static final String CUSTARD = "Custard";
+    static final String CUSTARD = "Custard";
 
-    private static final Date SUN_SEP_9TH_2001 = new Date(1000000000000L);
+    static final Date SUN_SEP_9TH_2001 = new Date(1000000000000L);
 
-    private static final int SIZE = 1729;
+    static final int SIZE = 1729;
 
-    private static final String DATE_FIELD = "Date";
+    static final String DATE_FIELD = "Date";
 
-    private static final String SUBJECT_FIELD = "Subject";
+    static final String SUBJECT_FIELD = "Subject";
 
-    private static final String RFC822_SUN_SEP_9TH_2001 = "Sun, 9 Sep 2001 09:10:48 +0000 (GMT)";
+    static final String RFC822_SUN_SEP_9TH_2001 = "Sun, 9 Sep 2001 09:10:48 +0000 (GMT)";
 
-    private static final String TEXT = RHUBARD + RHUBARD + RHUBARD;
+    static final String TEXT = RHUBARD + RHUBARD + RHUBARD;
 
     MessageBuilder builder;
 
     Collection<MessageUid> recent;
 
-    private MessageSearches messageSearches;
+    MessageSearches messageSearches;
     
-    private Calendar getGMT() {
+    Calendar getGMT() {
         return Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.UK);
     }
     
-    private Date getDate(int day, int month, int year) {
+    Date getDate(int day, int month, int year) {
         Calendar cal = getGMT();
         cal.set(year, month - 1, day);
         return cal.getTime();
     }
     
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         recent = new ArrayList<>();
         builder = new MessageBuilder()
             .uid(MessageUid.of(1009));
@@ -88,7 +88,7 @@ public class SearchUtilsTest {
     }
     
     @Test
-    public void testMatchSizeLessThan() throws Exception {
+    void testMatchSizeLessThan() throws Exception {
         builder.size(SIZE);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.sizeLessThan(SIZE - 1), row,
@@ -102,7 +102,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchSizeMoreThan() throws Exception {
+    void testMatchSizeMoreThan() throws Exception {
         builder.size(SIZE);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.sizeGreaterThan(SIZE - 1), row,
@@ -116,7 +116,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchSizeEquals() throws Exception {
+    void testMatchSizeEquals() throws Exception {
         builder.size(SIZE);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.sizeEquals(SIZE - 1), row,
@@ -129,7 +129,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchInternalDateEquals() throws Exception {
+    void testMatchInternalDateEquals() throws Exception {
         builder.internalDate(SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.internalDateOn(getDate(9, 9, 2000), DateResolution.Day),
@@ -146,7 +146,7 @@ public class SearchUtilsTest {
 
     
     @Test
-    public void testMatchInternalDateBefore() throws Exception {
+    void testMatchInternalDateBefore() throws Exception {
         builder.internalDate(SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(
@@ -162,7 +162,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchInternalDateAfter() throws Exception {
+    void testMatchInternalDateAfter() throws Exception {
         builder.internalDate(SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.internalDateAfter(getDate(9, 9, 2000), DateResolution.Day),
@@ -178,7 +178,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderDateAfter() throws Exception {
+    void testMatchHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
@@ -196,7 +196,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchCapsHeaderDateAfter() throws Exception {
+    void testShouldMatchCapsHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD.toUpperCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
@@ -214,7 +214,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchLowersHeaderDateAfter() throws Exception {
+    void testShouldMatchLowersHeaderDateAfter() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(9,
@@ -232,7 +232,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderDateOn() throws Exception {
+    void testMatchHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD, RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
@@ -250,7 +250,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchCapsHeaderDateOn() throws Exception {
+    void testShouldMatchCapsHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD.toUpperCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
@@ -268,7 +268,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchLowersHeaderDateOn() throws Exception {
+    void testShouldMatchLowersHeaderDateOn() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(9, 9,
@@ -286,7 +286,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderDateBefore() throws Exception {
+    void testMatchHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
@@ -304,7 +304,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchCapsHeaderDateBefore() throws Exception {
+    void testShouldMatchCapsHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
@@ -322,7 +322,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchLowersHeaderDateBefore() throws Exception {
+    void testShouldMatchLowersHeaderDateBefore() throws Exception {
         builder.header(DATE_FIELD.toLowerCase(Locale.US), RFC822_SUN_SEP_9TH_2001);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD,
@@ -340,7 +340,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderContainsCaps() throws Exception {
+    void testMatchHeaderContainsCaps() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
@@ -356,7 +356,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderContainsLowers() throws Exception {
+    void testMatchHeaderContainsLowers() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
@@ -372,7 +372,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderContains() throws Exception {
+    void testMatchHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT.toUpperCase(Locale.US));
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
@@ -388,7 +388,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchLowerHeaderContains() throws Exception {
+    void testShouldMatchLowerHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
@@ -404,7 +404,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchCapsHeaderContains() throws Exception {
+    void testShouldMatchCapsHeaderContains() throws Exception {
         builder.header(SUBJECT_FIELD.toUpperCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerContains(DATE_FIELD,
@@ -420,7 +420,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testMatchHeaderExists() throws Exception {
+    void testMatchHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD, TEXT);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
@@ -430,7 +430,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchLowersHeaderExists() throws Exception {
+    void testShouldMatchLowersHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
@@ -440,7 +440,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchUppersHeaderExists() throws Exception {
+    void testShouldMatchUppersHeaderExists() throws Exception {
         builder.header(SUBJECT_FIELD.toLowerCase(Locale.US), TEXT);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerExists(DATE_FIELD), row,
@@ -450,7 +450,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchUidRange() throws Exception {
+    void testShouldMatchUidRange() throws Exception {
         builder.setKey(1, MessageUid.of(1729));
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.uid(range(MessageUid.of(1), MessageUid.of(1))), row, recent)).isFalse();
@@ -481,7 +481,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchSeenFlagSet() throws Exception {
+    void testShouldMatchSeenFlagSet() throws Exception {
         builder.setFlags(true, false, false, false, false, false);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
@@ -499,7 +499,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchAnsweredFlagSet() throws Exception {
+    void testShouldMatchAnsweredFlagSet() throws Exception {
         builder.setFlags(false, false, true, false, false, false);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
@@ -517,7 +517,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchFlaggedFlagSet() throws Exception {
+    void testShouldMatchFlaggedFlagSet() throws Exception {
         builder.setFlags(false, true, false, false, false, false);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
@@ -535,7 +535,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchDraftFlagSet() throws Exception {
+    void testShouldMatchDraftFlagSet() throws Exception {
         builder.setFlags(false, false, false, true, false, false);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
@@ -554,7 +554,7 @@ public class SearchUtilsTest {
 
     
     @Test
-    public void testShouldMatchDeletedFlagSet() throws Exception {
+    void testShouldMatchDeletedFlagSet() throws Exception {
         builder.setFlags(false, false, false, false, true, false);
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.flagIsSet(Flags.Flag.SEEN),
@@ -572,7 +572,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchSeenRecentSet() throws Exception {
+    void testShouldMatchSeenRecentSet() throws Exception {
         builder.setFlags(false, false, false, false, false, false);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -591,7 +591,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchSeenFlagUnSet() throws Exception {
+    void testShouldMatchSeenFlagUnSet() throws Exception {
         builder.setFlags(false, true, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -610,7 +610,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchAnsweredFlagUnSet() throws Exception {
+    void testShouldMatchAnsweredFlagUnSet() throws Exception {
         builder.setFlags(true, true, false, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -629,7 +629,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchFlaggedFlagUnSet() throws Exception {
+    void testShouldMatchFlaggedFlagUnSet() throws Exception {
         builder.setFlags(true, false, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -648,7 +648,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchDraftFlagUnSet() throws Exception {
+    void testShouldMatchDraftFlagUnSet() throws Exception {
         builder.setFlags(true, true, true, false, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -667,7 +667,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchDeletedFlagUnSet() throws Exception {
+    void testShouldMatchDeletedFlagUnSet() throws Exception {
         builder.setFlags(true, true, true, true, false, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid());
@@ -686,7 +686,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchSeenRecentUnSet() throws Exception {
+    void testShouldMatchSeenRecentUnSet() throws Exception {
         builder.setFlags(true, true, true, true, true, true);
         MailboxMessage row = builder.build();
         recent.add(row.getUid().next());
@@ -705,13 +705,13 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchAll() throws Exception {
+    void testShouldMatchAll() throws Exception {
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.all(), row, recent)).isTrue();
     }
 
     @Test
-    public void testShouldMatchNot() throws Exception {
+    void testShouldMatchNot() throws Exception {
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.not(SearchQuery.all()), row,
                 recent)).isFalse();
@@ -720,7 +720,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchOr() throws Exception {
+    void testShouldMatchOr() throws Exception {
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.or(SearchQuery.all(),
                 SearchQuery.headerExists(DATE_FIELD)), row, recent)).isTrue();
@@ -734,7 +734,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchAnd() throws Exception {
+    void testShouldMatchAnd() throws Exception {
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.and(SearchQuery.all(),
                 SearchQuery.headerExists(DATE_FIELD)), row, recent)).isFalse();
@@ -747,11 +747,11 @@ public class SearchUtilsTest {
                 SearchQuery.all()), row, recent)).isTrue();
     }
     
-    private SearchQuery.UidRange[] range(MessageUid low, MessageUid high) {
+    SearchQuery.UidRange[] range(MessageUid low, MessageUid high) {
         return new SearchQuery.UidRange[]{ new SearchQuery.UidRange(low, high) };
     }
 
-    private SearchQuery.UidRange[] range(MessageUid lowOne, MessageUid highOne,
+    SearchQuery.UidRange[] range(MessageUid lowOne, MessageUid highOne,
             MessageUid lowTwo, MessageUid highTwo) {
         return new SearchQuery.UidRange[]{
                 new SearchQuery.UidRange(lowOne, highOne),
@@ -760,7 +760,7 @@ public class SearchUtilsTest {
     
     
     @Test
-    public void testMatchHeaderDateOnWithOffset() throws Exception {
+    void testMatchHeaderDateOnWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateOn(DATE_FIELD, getDate(26, 3,
@@ -774,7 +774,7 @@ public class SearchUtilsTest {
     
 
     @Test
-    public void testShouldMatchHeaderDateBeforeWithOffset() throws Exception {
+    void testShouldMatchHeaderDateBeforeWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateBefore(DATE_FIELD, getDate(26, 3,
@@ -787,7 +787,7 @@ public class SearchUtilsTest {
     }
 
     @Test
-    public void testShouldMatchHeaderDateAfterWithOffset() throws Exception {
+    void testShouldMatchHeaderDateAfterWithOffset() throws Exception {
         builder.header(DATE_FIELD, "Mon, 26 Mar 2007 00:00:00 +0300");
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.headerDateAfter(DATE_FIELD, getDate(26, 3,
@@ -800,7 +800,7 @@ public class SearchUtilsTest {
     }
     
     @Test
-    public void testShouldMatchAddressHeaderWithComments() throws Exception {
+    void testShouldMatchAddressHeaderWithComments() throws Exception {
         builder.header("To", "<user-from (comment)@ (comment) domain.org>");
         MailboxMessage row = builder.build();
         assertThat(messageSearches.isMatch(SearchQuery.address(AddressType.To, "user-from@domain.org"), row, recent)).isTrue();


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


[james-project] 12/42: [Refactoring] Move FlagsFilterTest to JUnit 5

Posted by rc...@apache.org.
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 deec3a01fee1c30b31fb9ce01ab696d554bd7962
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:18:26 2019 +0700

    [Refactoring] Move FlagsFilterTest to JUnit 5
---
 .../mailbox/store/mail/model/FlagsFilterTest.java      | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFilterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFilterTest.java
index d9feb62..963984c 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFilterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFilterTest.java
@@ -24,29 +24,29 @@ import java.util.List;
 
 import javax.mail.Flags;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class FlagsFilterTest {
+class FlagsFilterTest {
 
-    private List<Flags.Flag> listOfFlags = ImmutableList.of(Flags.Flag.SEEN, Flags.Flag.RECENT, Flags.Flag.FLAGGED);
-    private List<String> listOfUserFlags = ImmutableList.of("VeryImportant", "Bof");
+    List<Flags.Flag> listOfFlags = ImmutableList.of(Flags.Flag.SEEN, Flags.Flag.RECENT, Flags.Flag.FLAGGED);
+    List<String> listOfUserFlags = ImmutableList.of("VeryImportant", "Bof");
 
     @Test
-    public void buildShouldNotRequireAnyProperty() {
+    void buildShouldNotRequireAnyProperty() {
         assertThat(FlagsFilter.builder().build()).isNotNull();
     }
 
     @Test
-    public void buildWithoutPropertyShouldReturnNoFilter() {
+    void buildWithoutPropertyShouldReturnNoFilter() {
         FlagsFilter filter = FlagsFilter.builder().build();
         assertThat(listOfFlags.stream().filter(filter.getSystemFlagFilter())).isEqualTo(listOfFlags);
         assertThat(listOfUserFlags.stream().filter(filter.getUserFlagFilter())).isEqualTo(listOfUserFlags);
     }
 
     @Test
-    public void buildWithSystemFlagFilterShouldNotFilterUserFlags() {
+    void buildWithSystemFlagFilterShouldNotFilterUserFlags() {
         FlagsFilter filter = FlagsFilter.builder()
             .systemFlagFilter(flag -> false)
             .build();
@@ -54,7 +54,7 @@ public class FlagsFilterTest {
     }
 
     @Test
-    public void buildWithUSerFlagFilterShouldNotFilterSystemFlags() {
+    void buildWithUSerFlagFilterShouldNotFilterSystemFlags() {
         FlagsFilter filter = FlagsFilter.builder()
             .userFlagFilter(flag -> false)
             .build();
@@ -63,7 +63,7 @@ public class FlagsFilterTest {
 
 
     @Test
-    public void buildWithBothFiltersShouldApplyFilterOnBothFlagTypes() {
+    void buildWithBothFiltersShouldApplyFilterOnBothFlagTypes() {
         FlagsFilter filter = FlagsFilter.builder()
             .userFlagFilter(flag -> false)
             .systemFlagFilter(flag -> false)


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


[james-project] 21/42: [Refactoring] Move ListeningCurrentQuotaUpdaterTest to JUnit 5

Posted by rc...@apache.org.
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 90fd15454d028a59f15b9b798e36b1fca7967167
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:48:52 2019 +0700

    [Refactoring] Move ListeningCurrentQuotaUpdaterTest to JUnit 5
---
 .../quota/ListeningCurrentQuotaUpdaterTest.java    | 40 +++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
index 3dff2d7..ccfcc9d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
@@ -50,27 +50,27 @@ import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.Lists;
 
 import reactor.core.publisher.Mono;
 
-public class ListeningCurrentQuotaUpdaterTest {
+class ListeningCurrentQuotaUpdaterTest {
 
-    private static final int SIZE = 45;
-    private static final MailboxId MAILBOX_ID = TestId.of(42);
-    private static final String BENWA = "benwa";
-    private static final Username USERNAME_BENWA = Username.of(BENWA);
-    private static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot(BENWA, Optional.empty());
+    static final int SIZE = 45;
+    static final MailboxId MAILBOX_ID = TestId.of(42);
+    static final String BENWA = "benwa";
+    static final Username USERNAME_BENWA = Username.of(BENWA);
+    static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot(BENWA, Optional.empty());
 
-    private StoreCurrentQuotaManager mockedCurrentQuotaManager;
-    private QuotaRootResolver mockedQuotaRootResolver;
-    private ListeningCurrentQuotaUpdater testee;
+    StoreCurrentQuotaManager mockedCurrentQuotaManager;
+    QuotaRootResolver mockedQuotaRootResolver;
+    ListeningCurrentQuotaUpdater testee;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         mockedQuotaRootResolver = mock(QuotaRootResolver.class);
         mockedCurrentQuotaManager = mock(StoreCurrentQuotaManager.class);
         EventBus eventBus = mock(EventBus.class);
@@ -80,13 +80,13 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
 
     @Test
-    public void deserializeListeningCurrentQuotaUpdaterGroup() throws Exception {
+    void deserializeListeningCurrentQuotaUpdaterGroup() throws Exception {
         assertThat(Group.deserialize("org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater$ListeningCurrentQuotaUpdaterGroup"))
             .isEqualTo(new ListeningCurrentQuotaUpdater.ListeningCurrentQuotaUpdaterGroup());
     }
 
     @Test
-    public void addedEventShouldIncreaseCurrentQuotaValues() throws Exception {
+    void addedEventShouldIncreaseCurrentQuotaValues() throws Exception {
         MailboxListener.Added added = mock(MailboxListener.Added.class);
         when(added.getMailboxId()).thenReturn(MAILBOX_ID);
         when(added.getMetaData(MessageUid.of(36))).thenReturn(new MessageMetaData(MessageUid.of(36), ModSeq.first(),new Flags(), SIZE, new Date(), new DefaultMessageId()));
@@ -101,7 +101,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
 
     @Test
-    public void expungedEventShouldDecreaseCurrentQuotaValues() throws Exception {
+    void expungedEventShouldDecreaseCurrentQuotaValues() throws Exception {
         MailboxListener.Expunged expunged = mock(MailboxListener.Expunged.class);
         when(expunged.getMetaData(MessageUid.of(36))).thenReturn(new MessageMetaData(MessageUid.of(36), ModSeq.first(), new Flags(), SIZE, new Date(), new DefaultMessageId()));
         when(expunged.getMetaData(MessageUid.of(38))).thenReturn(new MessageMetaData(MessageUid.of(38), ModSeq.first(), new Flags(), SIZE, new Date(), new DefaultMessageId()));
@@ -116,7 +116,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
     
     @Test
-    public void emptyExpungedEventShouldNotTriggerDecrease() throws Exception {
+    void emptyExpungedEventShouldNotTriggerDecrease() throws Exception {
         MailboxListener.Expunged expunged = mock(MailboxListener.Expunged.class);
         when(expunged.getUids()).thenReturn(Lists.<MessageUid>newArrayList());
         when(expunged.getMailboxId()).thenReturn(MAILBOX_ID);
@@ -129,7 +129,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
 
     @Test
-    public void emptyAddedEventShouldNotTriggerDecrease() throws Exception {
+    void emptyAddedEventShouldNotTriggerDecrease() throws Exception {
         MailboxListener.Added added = mock(MailboxListener.Added.class);
         when(added.getUids()).thenReturn(Lists.<MessageUid>newArrayList());
         when(added.getMailboxId()).thenReturn(MAILBOX_ID);
@@ -142,7 +142,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
 
     @Test
-    public void mailboxDeletionEventShouldDecreaseCurrentQuotaValues() throws Exception {
+    void mailboxDeletionEventShouldDecreaseCurrentQuotaValues() throws Exception {
         MailboxListener.MailboxDeletion deletion = mock(MailboxListener.MailboxDeletion.class);
         when(deletion.getQuotaRoot()).thenReturn(QUOTA_ROOT);
         when(deletion.getDeletedMessageCount()).thenReturn(QuotaCountUsage.count(10));
@@ -157,7 +157,7 @@ public class ListeningCurrentQuotaUpdaterTest {
     }
 
     @Test
-    public void mailboxDeletionEventShouldDoNothingWhenEmptyMailbox() throws Exception {
+    void mailboxDeletionEventShouldDoNothingWhenEmptyMailbox() throws Exception {
         MailboxListener.MailboxDeletion deletion = mock(MailboxListener.MailboxDeletion.class);
         when(deletion.getQuotaRoot()).thenReturn(QUOTA_ROOT);
         when(deletion.getDeletedMessageCount()).thenReturn(QuotaCountUsage.count(0));


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


[james-project] 25/42: [Refactoring] Move CombinedComparatorTest to JUnit 5

Posted by rc...@apache.org.
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 93216f21499cccff7671ad495704b9648e4c82b3
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:54:03 2019 +0700

    [Refactoring] Move CombinedComparatorTest to JUnit 5
---
 .../store/search/CombinedComparatorTest.java       | 48 ++++++++++------------
 1 file changed, 21 insertions(+), 27 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
index 2fecfbb..07f511f 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store.search;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -37,99 +38,92 @@ import org.apache.james.mailbox.store.search.comparator.HeaderDisplayComparator;
 import org.apache.james.mailbox.store.search.comparator.HeaderMailboxComparator;
 import org.apache.james.mailbox.store.search.comparator.MessageComparators;
 import org.apache.james.mailbox.store.search.comparator.SentDateComparator;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class CombinedComparatorTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+class CombinedComparatorTest {
 
     @Test
-    public void createShouldThrowOnNullListOfSort() {
-        expectedException.expect(NullPointerException.class);
-
-        CombinedComparator.create(null);
+    void createShouldThrowOnNullListOfSort() {
+        assertThatThrownBy(() -> CombinedComparator.create(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void createShouldThrowOnEmptySort() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        CombinedComparator.create(ImmutableList.<SearchQuery.Sort>of());
+    void createShouldThrowOnEmptySort() {
+        assertThatThrownBy(() -> CombinedComparator.create(ImmutableList.<SearchQuery.Sort>of()))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void createShouldConvertInternalDate() {
+    void createShouldConvertInternalDate() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.Arrival))).getComparators())
             .containsOnly(MessageComparators.INTERNAL_DATE_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertCc() {
+    void createShouldConvertCc() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.MailboxCc))).getComparators())
             .containsOnly(HeaderMailboxComparator.CC_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertFrom() {
+    void createShouldConvertFrom() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.MailboxFrom))).getComparators())
             .containsOnly(HeaderMailboxComparator.FROM_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertTo() {
+    void createShouldConvertTo() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.MailboxTo))).getComparators())
             .containsOnly(HeaderMailboxComparator.TO_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertSize() {
+    void createShouldConvertSize() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.Size))).getComparators())
             .containsOnly(MessageComparators.SIZE_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertBaseSubject() {
+    void createShouldConvertBaseSubject() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.BaseSubject))).getComparators())
             .containsOnly(BaseSubjectComparator.BASESUBJECT);
     }
 
     @Test
-    public void createShouldConvertUid() {
+    void createShouldConvertUid() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.Uid))).getComparators())
             .containsOnly(MessageComparators.UID_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertSentDate() {
+    void createShouldConvertSentDate() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.SentDate))).getComparators())
             .containsOnly(SentDateComparator.SENTDATE);
     }
 
     @Test
-    public void createShouldConvertDisplayTo() {
+    void createShouldConvertDisplayTo() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.DisplayTo))).getComparators())
             .containsOnly(HeaderDisplayComparator.TO_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertDisplayFrom() {
+    void createShouldConvertDisplayFrom() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.DisplayFrom))).getComparators())
             .containsOnly(HeaderDisplayComparator.FROM_COMPARATOR);
     }
 
     @Test
-    public void createShouldConvertId() {
+    void createShouldConvertId() {
         assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.Id))).getComparators())
             .containsOnly(MessageComparators.MESSAGE_ID_COMPARATOR);
     }
 
     @Test
-    public void createShouldReverse() {
+    void createShouldReverse() {
         MailboxMessage message1 = mock(MailboxMessage.class);
         when(message1.getUid()).thenReturn(MessageUid.of(1));
         MailboxMessage message2 = mock(MailboxMessage.class);


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


[james-project] 40/42: [Refactoring] Move StoreMailboxMessageResultIteratorTest to JUnit 5

Posted by rc...@apache.org.
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 9e5dc61c01421e96f2c4a8bee82472ebbe365d2d
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:20:07 2019 +0700

    [Refactoring] Move StoreMailboxMessageResultIteratorTest to JUnit 5
---
 .../StoreMailboxMessageResultIteratorTest.java      | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
index cadaf56..f5b1635 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxMessageResultIteratorTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -47,11 +48,11 @@ import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.Iterables;
 
-public class StoreMailboxMessageResultIteratorTest {
+class StoreMailboxMessageResultIteratorTest {
 
     private final class TestMessageMapper implements MessageMapper {
         private final MessageRange messageRange;
@@ -186,7 +187,7 @@ public class StoreMailboxMessageResultIteratorTest {
     }
 
     @Test
-    public void testBatching() {
+    void testBatching() {
         MessageRange range = MessageRange.range(MessageUid.of(1), MessageUid.of(10));
         BatchSizes batchSize = BatchSizes.uniqueBatchSize(3);
         StoreMessageResultIterator it = new StoreMessageResultIterator(new TestMessageMapper(MessageRange.all()), null, range, batchSize, FetchGroup.MINIMAL);
@@ -197,28 +198,32 @@ public class StoreMailboxMessageResultIteratorTest {
     }
 
     @Test
-    public void nextShouldReturnFirstElement() {
+    void nextShouldReturnFirstElement() {
         MessageRange range = MessageUid.of(1).toRange();
         BatchSizes batchSize = BatchSizes.uniqueBatchSize(42);
         StoreMessageResultIterator iterator = new StoreMessageResultIterator(new TestMessageMapper(range), null, range, batchSize, FetchGroup.MINIMAL);
+
         assertThat(iterator.next()).isNotNull();
     }
     
-    @Test(expected = NoSuchElementException.class)
-    public void nextShouldThrowWhenNoElement() {
+    @Test
+    void nextShouldThrowWhenNoElement() {
         MessageRange messages = MessageUid.of(1).toRange();
         MessageRange findRange = MessageUid.of(2).toRange();
         BatchSizes batchSize = BatchSizes.uniqueBatchSize(42);
         StoreMessageResultIterator iterator = new StoreMessageResultIterator(new TestMessageMapper(messages), null, findRange, batchSize, FetchGroup.MINIMAL);
-        iterator.next();
+
+        assertThatThrownBy(() -> iterator.next())
+            .isInstanceOf(NoSuchElementException.class);
     }
     
     @Test
-    public void hasNextShouldReturnFalseWhenNoElement() {
+    void hasNextShouldReturnFalseWhenNoElement() {
         MessageRange messages = MessageUid.of(1).toRange();
         MessageRange findRange = MessageUid.of(2).toRange();
         BatchSizes batchSize = BatchSizes.uniqueBatchSize(42);
         StoreMessageResultIterator iterator = new StoreMessageResultIterator(new TestMessageMapper(messages), null, findRange, batchSize, FetchGroup.MINIMAL);
+
         assertThat(iterator.hasNext()).isFalse();
     }
 }


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


[james-project] 38/42: [Refactoring] Move StoreMailboxManagerAnnotationTest to JUnit 5

Posted by rc...@apache.org.
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 013deb590ddd5e708870400a2be2ffdd8f498175
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:13:14 2019 +0700

    [Refactoring] Move StoreMailboxManagerAnnotationTest to JUnit 5
---
 .../store/StoreMailboxManagerAnnotationTest.java   | 78 ++++++++++++----------
 1 file changed, 42 insertions(+), 36 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
index 2753748..85e3670 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doThrow;
@@ -45,40 +46,39 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.transaction.Mapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 
-public class StoreMailboxManagerAnnotationTest {
-    private static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment");
-    private static final MailboxAnnotationKey SHARED_KEY = new MailboxAnnotationKey("/shared/comment");
+class StoreMailboxManagerAnnotationTest {
+    static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment");
+    static final MailboxAnnotationKey SHARED_KEY = new MailboxAnnotationKey("/shared/comment");
 
-    private static final MailboxAnnotation PRIVATE_ANNOTATION = MailboxAnnotation.newInstance(PRIVATE_KEY, "My private comment");
-    private static final MailboxAnnotation SHARED_ANNOTATION =  MailboxAnnotation.newInstance(SHARED_KEY, "My shared comment");
-    private static final Set<MailboxAnnotationKey> KEYS = ImmutableSet.of(PRIVATE_KEY);
+    static final MailboxAnnotation PRIVATE_ANNOTATION = MailboxAnnotation.newInstance(PRIVATE_KEY, "My comment");
+    static final MailboxAnnotation SHARED_ANNOTATION =  MailboxAnnotation.newInstance(SHARED_KEY, "My shared comment");
+    static final Set<MailboxAnnotationKey> KEYS = ImmutableSet.of(PRIVATE_KEY);
 
-    private static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
-    private static final List<MailboxAnnotation> ANNOTATIONS_WITH_NIL_ENTRY = ImmutableList.of(PRIVATE_ANNOTATION, MailboxAnnotation.nil(SHARED_KEY));
+    static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
+    static final List<MailboxAnnotation> ANNOTATIONS_WITH_NIL_ENTRY = ImmutableList.of(PRIVATE_ANNOTATION, MailboxAnnotation.nil(SHARED_KEY));
 
-    @Mock private MailboxSessionMapperFactory mailboxSessionMapperFactory;
-    @Mock private StoreRightManager storeRightManager;
-    @Mock private MailboxMapper mailboxMapper;
-    @Mock private AnnotationMapper annotationMapper;
-    @Mock private MailboxPath mailboxPath;
-    @Mock private Mailbox mailbox;
-    @Mock private MailboxId mailboxId;
-    private MailboxSession session;
-
-    private StoreMailboxAnnotationManager annotationManager;
+    @Mock MailboxSessionMapperFactory mailboxSessionMapperFactory;
+    @Mock StoreRightManager storeRightManager;
+    @Mock MailboxMapper mailboxMapper;
+    @Mock AnnotationMapper annotationMapper;
+    @Mock MailboxPath mailboxPath;
+    @Mock Mailbox mailbox;
+    @Mock MailboxId mailboxId;
+    MailboxSession session;
 
+    StoreMailboxAnnotationManager annotationManager;
 
     @SuppressWarnings("unchecked")
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
 
         session = MailboxSessionUtil.create(Username.of("userName"));
@@ -99,14 +99,16 @@ public class StoreMailboxManagerAnnotationTest {
             storeRightManager));
     }
 
-    @Test(expected = MailboxException.class)
-    public void updateAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
+    @Test
+    void updateAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
         doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
-        annotationManager.updateAnnotations(mailboxPath, session, ImmutableList.of(PRIVATE_ANNOTATION));
+
+        assertThatThrownBy(() -> annotationManager.updateAnnotations(mailboxPath, session, ImmutableList.of(PRIVATE_ANNOTATION)))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
-    public void updateAnnotationsShouldCallAnnotationMapperToInsertAnnotation() throws Exception {
+    void updateAnnotationsShouldCallAnnotationMapperToInsertAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         annotationManager.updateAnnotations(mailboxPath, session, ANNOTATIONS);
 
@@ -114,7 +116,7 @@ public class StoreMailboxManagerAnnotationTest {
     }
 
     @Test
-    public void updateAnnotationsShouldCallAnnotationMapperToDeleteAnnotation() throws Exception {
+    void updateAnnotationsShouldCallAnnotationMapperToDeleteAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         annotationManager.updateAnnotations(mailboxPath, session, ANNOTATIONS_WITH_NIL_ENTRY);
 
@@ -122,14 +124,16 @@ public class StoreMailboxManagerAnnotationTest {
         verify(annotationMapper, times(1)).deleteAnnotation(eq(mailboxId), eq(SHARED_KEY));
     }
 
-    @Test(expected = MailboxException.class)
-    public void getAllAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
+    @Test
+    void getAllAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
         doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
-        annotationManager.getAllAnnotations(mailboxPath, session);
+
+        assertThatThrownBy(() -> annotationManager.getAllAnnotations(mailboxPath, session))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
-    public void getAllAnnotationsShouldReturnEmptyForNonStoredAnnotation() throws Exception {
+    void getAllAnnotationsShouldReturnEmptyForNonStoredAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(Collections.<MailboxAnnotation>emptyList());
 
@@ -137,21 +141,23 @@ public class StoreMailboxManagerAnnotationTest {
     }
 
     @Test
-    public void getAllAnnotationsShouldReturnStoredAnnotation() throws Exception {
+    void getAllAnnotationsShouldReturnStoredAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(ANNOTATIONS);
 
         assertThat(annotationManager.getAllAnnotations(mailboxPath, session)).isEqualTo(ANNOTATIONS);
     }
 
-    @Test(expected = MailboxException.class)
-    public void getAnnotationsByKeysShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
+    @Test
+    void getAnnotationsByKeysShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
         doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
-        annotationManager.getAnnotationsByKeys(mailboxPath, session, KEYS);
+
+        assertThatThrownBy(() -> annotationManager.getAnnotationsByKeys(mailboxPath, session, KEYS))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
-    public void getAnnotationsByKeysShouldRetrieveStoreAnnotationsByKey() throws Exception {
+    void getAnnotationsByKeysShouldRetrieveStoreAnnotationsByKey() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         when(annotationMapper.getAnnotationsByKeys(eq(mailboxId), eq(KEYS))).thenReturn(ANNOTATIONS);
 


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


[james-project] 24/42: [Refactoring] Move SentDateComparatorTest to JUnit 5

Posted by rc...@apache.org.
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 23cc15ece4de69f4b9b04f93423ab4b1d85bd2d0
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:51:40 2019 +0700

    [Refactoring] Move SentDateComparatorTest to JUnit 5
---
 .../search/comparator/SentDateComparatorTest.java  | 34 +++++++++-------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/comparator/SentDateComparatorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/comparator/SentDateComparatorTest.java
index ddd5a63..1d7ec98 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/comparator/SentDateComparatorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/comparator/SentDateComparatorTest.java
@@ -21,48 +21,42 @@ package org.apache.james.mailbox.store.search.comparator;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class SentDateComparatorTest {
+class SentDateComparatorTest {
     @Test
-    public void sanitizeDateStringHeaderValueShouldRemoveCESTPart() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200 (CEST)"))
+    void sanitizeDateStringHeaderValueShouldRemoveCESTPart() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200 (CEST)"))
             .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200");
     }
 
     @Test
-    public void sanitizeDateStringHeaderValueShouldRemoveUTCPart() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200  (UTC)  "))
+    void sanitizeDateStringHeaderValueShouldRemoveUTCPart() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200  (UTC)  "))
             .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200");
     }
 
     @Test
-    public void sanitizeDateStringHeaderValueShouldNotChangeAcceptableString() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200"))
+    void sanitizeDateStringHeaderValueShouldNotChangeAcceptableString() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue("Thu, 18 Jun 2015 04:09:35 +0200"))
             .isEqualTo("Thu, 18 Jun 2015 04:09:35 +0200");
     }
 
     @Test
-    public void sanitizeDateStringHeaderValueShouldRemoveBrackets() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe)"))
+    void sanitizeDateStringHeaderValueShouldRemoveBrackets() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe)"))
             .isEqualTo("invalid");
     }
 
     @Test
-    public void sanitizeDateStringHeaderValueShouldKeepUnclosedBrackets() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe"))
+    void sanitizeDateStringHeaderValueShouldKeepUnclosedBrackets() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue("invalid (removeMe"))
             .isEqualTo("invalid (removeMe");
     }
 
     @Test
-    public void sanitizeDateStringHeaderValueShouldNotChangeEmptyString() {
-        assertThat(
-            SentDateComparator.sanitizeDateStringHeaderValue(""))
+    void sanitizeDateStringHeaderValueShouldNotChangeEmptyString() {
+        assertThat(SentDateComparator.sanitizeDateStringHeaderValue(""))
             .isEqualTo("");
     }
 }


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


[james-project] 36/42: [Refactoring] Move StoreAttachmentManagerTest to JUnit 5

Posted by rc...@apache.org.
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 723fac3b2041f239f09db7d2ed25d6c9950d31d8
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:09:28 2019 +0700

    [Refactoring] Move StoreAttachmentManagerTest to JUnit 5
---
 .../mailbox/store/StoreAttachmentManagerTest.java  | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreAttachmentManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreAttachmentManagerTest.java
index 2d910ae..9e129a1 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreAttachmentManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreAttachmentManagerTest.java
@@ -35,28 +35,28 @@ import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 
-public class StoreAttachmentManagerTest {
-    private static final TestMessageId MESSAGE_ID = TestMessageId.of(1L);
-    private static final ImmutableList<MessageId> MESSAGE_IDS = ImmutableList.of(MESSAGE_ID);
-    private static final AttachmentId ATTACHMENT_ID = AttachmentId.from("1");
-    private static final Attachment ATTACHMENT = Attachment.builder()
+class StoreAttachmentManagerTest {
+    static final TestMessageId MESSAGE_ID = TestMessageId.of(1L);
+    static final ImmutableList<MessageId> MESSAGE_IDS = ImmutableList.of(MESSAGE_ID);
+    static final AttachmentId ATTACHMENT_ID = AttachmentId.from("1");
+    static final Attachment ATTACHMENT = Attachment.builder()
         .attachmentId(ATTACHMENT_ID)
         .type("type")
         .bytes("Any".getBytes(StandardCharsets.UTF_8))
         .build();
 
-    private StoreAttachmentManager testee;
-    private AttachmentMapper attachmentMapper;
-    private MessageIdManager messageIdManager;
+    StoreAttachmentManager testee;
+    AttachmentMapper attachmentMapper;
+    MessageIdManager messageIdManager;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() throws Exception {
         attachmentMapper = mock(AttachmentMapper.class);
         AttachmentMapperFactory attachmentMapperFactory = mock(AttachmentMapperFactory.class);
         when(attachmentMapperFactory.getAttachmentMapper(any(MailboxSession.class)))
@@ -67,7 +67,7 @@ public class StoreAttachmentManagerTest {
     }
 
     @Test
-    public void getAttachmentShouldThrowWhenAttachmentDoesNotBelongToUser() throws Exception {
+    void getAttachmentShouldThrowWhenAttachmentDoesNotBelongToUser() throws Exception {
         MailboxSession mailboxSession = mock(MailboxSession.class);
         when(attachmentMapper.getAttachment(ATTACHMENT_ID)).thenReturn(ATTACHMENT);
         when(attachmentMapper.getRelatedMessageIds(ATTACHMENT_ID)).thenReturn(MESSAGE_IDS);


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


[james-project] 03/42: [Refactoring] Move DefaultTextExtractorTest to JUnit 5

Posted by rc...@apache.org.
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 b7dbec9673021eae63e802329ec474c15505882e
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:49:46 2019 +0700

    [Refactoring] Move DefaultTextExtractorTest to JUnit 5
---
 .../store/extractor/DefaultTextExtractorTest.java        | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/DefaultTextExtractorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/DefaultTextExtractorTest.java
index a5c5c0c..49ae39e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/DefaultTextExtractorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/extractor/DefaultTextExtractorTest.java
@@ -24,19 +24,19 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.io.InputStream;
 
 import org.apache.james.mailbox.extractor.TextExtractor;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class DefaultTextExtractorTest {
-    private TextExtractor textExtractor;
+class DefaultTextExtractorTest {
+    TextExtractor textExtractor;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         textExtractor = new DefaultTextExtractor();
     }
 
     @Test
-    public void textTest() throws Exception {
+    void textTest() throws Exception {
         InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/Text.txt");
         assertThat(inputStream).isNotNull();
         assertThat(textExtractor.extractContent(inputStream, "text/plain")
@@ -45,7 +45,7 @@ public class DefaultTextExtractorTest {
     }
 
     @Test
-    public void textMicrosoftWorldTest() throws Exception {
+    void textMicrosoftWorldTest() throws Exception {
         InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/writter.docx");
         assertThat(inputStream).isNotNull();
         assertThat(textExtractor.extractContent(


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


[james-project] 02/42: [Refactoring] Move MailboxAnnotationListenerTest to JUnit 5

Posted by rc...@apache.org.
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 4800262eec4411b6127b91588e06da13bfc6523d
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:48:11 2019 +0700

    [Refactoring] Move MailboxAnnotationListenerTest to JUnit 5
---
 .../store/event/MailboxAnnotationListenerTest.java | 51 +++++++++++-----------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
index 3aad5ba..fbc85a3 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
@@ -47,38 +47,37 @@ import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
 import com.google.common.collect.ImmutableList;
 
-public class MailboxAnnotationListenerTest {
-    private static final Username USER = Username.of("user");
-    private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", USER, "name");
+class MailboxAnnotationListenerTest {
+    static final Username USER = Username.of("user");
+    static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", USER, "name");
 
-    private static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment");
-    private static final MailboxAnnotationKey SHARED_KEY = new MailboxAnnotationKey("/shared/comment");
+    static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment");
+    static final MailboxAnnotationKey SHARED_KEY = new MailboxAnnotationKey("/shared/comment");
 
-    private static final MailboxAnnotation PRIVATE_ANNOTATION = MailboxAnnotation.newInstance(PRIVATE_KEY, "My private comment");
-    private static final MailboxAnnotation SHARED_ANNOTATION =  MailboxAnnotation.newInstance(SHARED_KEY, "My shared comment");
+    static final MailboxAnnotation PRIVATE_ANNOTATION = MailboxAnnotation.newInstance(PRIVATE_KEY, "My private comment");
+    static final MailboxAnnotation SHARED_ANNOTATION =  MailboxAnnotation.newInstance(SHARED_KEY, "My shared comment");
 
-    private static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
-    public static final int UID_VALIDITY = 145;
-    public static final TestId MAILBOX_ID = TestId.of(45);
+    static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
+    static final TestId MAILBOX_ID = TestId.of(45);
 
-    @Mock private SessionProvider sessionProvider;
-    @Mock private MailboxSessionMapperFactory mailboxSessionMapperFactory;
-    @Mock private AnnotationMapper annotationMapper;
-    @Mock private MailboxId mailboxId;
+    @Mock SessionProvider sessionProvider;
+    @Mock MailboxSessionMapperFactory mailboxSessionMapperFactory;
+    @Mock AnnotationMapper annotationMapper;
+    @Mock MailboxId mailboxId;
 
-    private MailboxAnnotationListener listener;
-    private MailboxListener.MailboxEvent deleteEvent;
-    private MailboxSession mailboxSession;
+    MailboxAnnotationListener listener;
+    MailboxListener.MailboxEvent deleteEvent;
+    MailboxSession mailboxSession;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
         mailboxSession = MailboxSessionUtil.create(Username.of("test"));
         listener = new MailboxAnnotationListener(mailboxSessionMapperFactory, sessionProvider);
@@ -99,13 +98,13 @@ public class MailboxAnnotationListenerTest {
     }
 
     @Test
-    public void deserializeMailboxAnnotationListenerGroup() throws Exception {
+    void deserializeMailboxAnnotationListenerGroup() throws Exception {
         assertThat(Group.deserialize("org.apache.james.mailbox.store.event.MailboxAnnotationListener$MailboxAnnotationListenerGroup"))
             .isEqualTo(new MailboxAnnotationListener.MailboxAnnotationListenerGroup());
     }
 
     @Test
-    public void eventShouldDoNothingIfDoNotHaveMailboxDeletionEvent() throws Exception {
+    void eventShouldDoNothingIfDoNotHaveMailboxDeletionEvent() throws Exception {
         MailboxListener.MailboxEvent event = new MailboxListener.MailboxAdded(null, null, MAILBOX_PATH, MAILBOX_ID, Event.EventId.random());
         listener.event(event);
 
@@ -114,7 +113,7 @@ public class MailboxAnnotationListenerTest {
     }
 
     @Test
-    public void eventShoudlDoNothingIfMailboxDoesNotHaveAnyAnnotation() throws Exception {
+    void eventShoudlDoNothingIfMailboxDoesNotHaveAnyAnnotation() throws Exception {
         when(annotationMapper.getAllAnnotations(any(MailboxId.class))).thenReturn(ImmutableList.<MailboxAnnotation>of());
 
         listener.event(deleteEvent);
@@ -128,7 +127,7 @@ public class MailboxAnnotationListenerTest {
     }
 
     @Test
-    public void eventShoudlDeleteAllMailboxAnnotation() throws Exception {
+    void eventShoudlDeleteAllMailboxAnnotation() throws Exception {
         when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(ANNOTATIONS);
 
         listener.event(deleteEvent);
@@ -144,7 +143,7 @@ public class MailboxAnnotationListenerTest {
     }
 
     @Test
-    public void eventShouldPropagateFailure() throws Exception {
+    void eventShouldPropagateFailure() throws Exception {
         when(annotationMapper.getAllAnnotations((eq(mailboxId)))).thenReturn(ANNOTATIONS);
         doThrow(new RuntimeException()).when(annotationMapper).deleteAnnotation(eq(mailboxId), eq(PRIVATE_KEY));
 


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


[james-project] 33/42: [Refactoring] Move SearchUtilsMultipartMixedTest to JUnit 5

Posted by rc...@apache.org.
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 e22f732a7d4c190d435a0a522b4a7b6d0b862693
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:06:53 2019 +0700

    [Refactoring] Move SearchUtilsMultipartMixedTest to JUnit 5
---
 .../store/SearchUtilsMultipartMixedTest.java       | 42 +++++++++++-----------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsMultipartMixedTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsMultipartMixedTest.java
index 60482e9..5fae690 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsMultipartMixedTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsMultipartMixedTest.java
@@ -32,26 +32,26 @@ import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.MessageSearches;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SearchUtilsMultipartMixedTest {
+class SearchUtilsMultipartMixedTest {
 
-    private static final String SAMPLE_INNER_MAIL_BODY_ONE = "far a modern quill doth come too";
+    static final String SAMPLE_INNER_MAIL_BODY_ONE = "far a modern quill doth come too";
 
-    private static final String SAMPLE_PART_ONE = "The better angel is a man right fair,\r\n";
+    static final String SAMPLE_PART_ONE = "The better angel is a man right fair,\r\n";
 
-    private static final String SAMPLE_PART_TWO = "My bonds in thee are all determinate.";
+    static final String SAMPLE_PART_TWO = "My bonds in thee are all determinate.";
 
-    private static final String SAMPLE_PART_TWO_FIELD = "948523475273457234952345";
+    static final String SAMPLE_PART_TWO_FIELD = "948523475273457234952345";
 
-    private static final String SAMPLE_INNER_MAIL_FIELD = "Inner mail sample";
+    static final String SAMPLE_INNER_MAIL_FIELD = "Inner mail sample";
 
-    private static final String SAMPLE_INNER_MAIL_MIME_FIELD = "8347673450223534587232312221";
+    static final String SAMPLE_INNER_MAIL_MIME_FIELD = "8347673450223534587232312221";
 
-    private static final String PREMABLE = "This is the premable.";
+    static final String PREMABLE = "This is the premable.";
 
-    private static final String BODY = PREMABLE + "\r\n--1729\r\n"
+    static final String BODY = PREMABLE + "\r\n--1729\r\n"
             + "Content-Type: text/plain; charset=US-ASCII\r\n\r\n"
             + "Two loves I have of comfort and despair,\r\n"
             + "Which like two spirits do suggest me still:\r\n"
@@ -111,10 +111,10 @@ public class SearchUtilsMultipartMixedTest {
 
     MailboxMessage row;
     Collection<MessageUid> recent;
-    private MessageSearches messageSearches;
+    MessageSearches messageSearches;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         final MessageBuilder builder = new MessageBuilder();
         
         builder.header("From", "Alex <alex@example.org");
@@ -134,7 +134,7 @@ public class SearchUtilsMultipartMixedTest {
     
 
     @Test
-    public void testShouldNotFindWhatIsNotThere() throws Exception {
+    void testShouldNotFindWhatIsNotThere() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains("BOGUS"), row,
                 recent)).isFalse();
         assertThat(messageSearches.isMatch(SearchQuery.mailContains("BOGUS"), row,
@@ -142,7 +142,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testBodyShouldFindTextInBody() throws Exception {
+    void testBodyShouldFindTextInBody() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(SAMPLE_PART_ONE),
@@ -152,7 +152,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testBodyShouldFindTextInBodyCaseInsensitive() throws Exception {
+    void testBodyShouldFindTextInBodyCaseInsensitive() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .bodyContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.bodyContains(SAMPLE_PART_ONE),
@@ -176,7 +176,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testBodyShouldNotFindTextInHeaders() throws Exception {
+    void testBodyShouldNotFindTextInHeaders() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .bodyContains(SAMPLE_INNER_MAIL_FIELD), row, recent)).isFalse();
         assertThat(messageSearches.isMatch(SearchQuery
@@ -184,7 +184,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testTextShouldFindTextInBody() throws Exception {
+    void testTextShouldFindTextInBody() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(SAMPLE_PART_ONE),
@@ -194,7 +194,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testTextShouldFindTextInBodyCaseInsensitive() throws Exception {
+    void testTextShouldFindTextInBodyCaseInsensitive() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .mailContains(SAMPLE_INNER_MAIL_BODY_ONE), row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery.mailContains(SAMPLE_PART_ONE),
@@ -218,7 +218,7 @@ public class SearchUtilsMultipartMixedTest {
     }
 
     @Test
-    public void testTextShouldFindTextInHeaders() throws Exception {
+    void testTextShouldFindTextInHeaders() throws Exception {
         assertThat(messageSearches.isMatch(SearchQuery
                 .mailContains(SAMPLE_INNER_MAIL_FIELD), row, recent)).isTrue();
         assertThat(messageSearches.isMatch(SearchQuery


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


[james-project] 09/42: [Refactoring] Move DefaultMessageIdTest to JUnit 5

Posted by rc...@apache.org.
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 7051bafa2a90d122cc224a357b7d4ad2381cca51
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:16:13 2019 +0700

    [Refactoring] Move DefaultMessageIdTest to JUnit 5
---
 .../james/mailbox/store/mail/model/DefaultMessageIdTest.java      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DefaultMessageIdTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DefaultMessageIdTest.java
index 85aa49f..d689863 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DefaultMessageIdTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/DefaultMessageIdTest.java
@@ -24,12 +24,12 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.TestId;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class DefaultMessageIdTest {
+class DefaultMessageIdTest {
 
     @Test
-    public void composedMessageIdToStringCallShouldNotThrowWhenUsingDefaultMessageId() {
+    void composedMessageIdToStringCallShouldNotThrowWhenUsingDefaultMessageId() {
         ComposedMessageId composedMessageId = new ComposedMessageId(
             TestId.of(52),
             new DefaultMessageId(),
@@ -39,7 +39,7 @@ public class DefaultMessageIdTest {
     }
 
     @Test
-    public void shouldNotBeSerializable() {
+    void shouldNotBeSerializable() {
         assertThat(new DefaultMessageId().isSerializable()).isFalse();
     }
 


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


[james-project] 16/42: [Refactoring] Move MailboxMessageAssertTest to JUnit 5

Posted by rc...@apache.org.
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 de884ed23524b842b8188ea76ed0edb885dded26
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:36:25 2019 +0700

    [Refactoring] Move MailboxMessageAssertTest to JUnit 5
---
 .../store/mail/model/MailboxMessageAssertTest.java | 32 +++++++++++++++-------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java
index c338fb5..703eae0 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMessageAssertTest.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mailbox.store.mail.model;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
 import java.io.IOException;
 import java.util.Date;
 
@@ -31,56 +33,66 @@ import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class MailboxMessageAssertTest {
+class MailboxMessageAssertTest {
 
-    public static final TestId MAILBOX_ID = TestId.of(42L);
-    public static final MessageUid UID = MessageUid.of(24);
-    public static final MessageId MESSAGE_ID = new DefaultMessageId();
+    static final TestId MAILBOX_ID = TestId.of(42L);
+    static final MessageUid UID = MessageUid.of(24);
+    static final MessageId MESSAGE_ID = new DefaultMessageId();
 
     @Test
-    public void messageAssertShouldSucceedWithTwoEqualsMessages() throws IOException {
+    void messageAssertShouldSucceedWithTwoEqualsMessages() throws IOException {
         String headerString = "name: headerName\n\n";
         String bodyString = "body\n.\n";
         Date date = new Date();
+
         SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message1.setUid(UID);
+
         SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message2.setUid(UID);
+
         MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Full);
     }
 
     @Test
-    public void messageAssertShouldSucceedWhenBodyMismatchInFetchHeaderMode() throws IOException {
+    void messageAssertShouldSucceedWhenBodyMismatchInFetchHeaderMode() throws IOException {
         String headerString = "name: headerName\n\n";
         String bodyString = "body\n.\n";
         Date date = new Date();
+
         SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message1.setUid(UID);
+
         bodyString = "work\n.\n";
         SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message2.setUid(UID);
+
         MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Headers);
     }
 
-    @Test(expected = AssertionError.class)
-    public void messageAssertShouldFailWhenBodyMismatchInFetchBodyMode() throws IOException {
+    @Test
+    void messageAssertShouldFailWhenBodyMismatchInFetchBodyMode() {
         String headerString = "name: headerName\n\n";
         String bodyString = "body\n.\n";
         Date date = new Date();
+
         SimpleMailboxMessage message1 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message1.setUid(UID);
+
         bodyString = "work\n.\n";
         SimpleMailboxMessage message2 = new SimpleMailboxMessage(MESSAGE_ID, date, headerString.length() + bodyString.length(),
             headerString.length(), new SharedByteArrayInputStream((headerString + bodyString).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message2.setUid(UID);
-        MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Body);
+
+        assertThatThrownBy(() -> MessageAssert.assertThat(message1).isEqualTo(message2, MessageMapper.FetchType.Body))
+            .isInstanceOf(AssertionError.class);
     }
 
 }


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


[james-project] 23/42: [Refactoring] Move StoreQuotaManagerTest to JUnit 5

Posted by rc...@apache.org.
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 dc182f0d8f2a56c59fee01e51b05862ae4b6359c
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:50:27 2019 +0700

    [Refactoring] Move StoreQuotaManagerTest to JUnit 5
---
 .../mailbox/store/quota/StoreQuotaManagerTest.java | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
index 6e735df..fbaba67 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
@@ -35,18 +35,18 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class StoreQuotaManagerTest {
+class StoreQuotaManagerTest {
 
-    private StoreQuotaManager testee;
-    private CurrentQuotaManager mockedCurrentQuotaManager;
-    private MaxQuotaManager mockedMaxQuotaManager;
-    private QuotaRoot quotaRoot;
+    StoreQuotaManager testee;
+    CurrentQuotaManager mockedCurrentQuotaManager;
+    MaxQuotaManager mockedMaxQuotaManager;
+    QuotaRoot quotaRoot;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         mockedCurrentQuotaManager = mock(CurrentQuotaManager.class);
         mockedMaxQuotaManager = mock(MaxQuotaManager.class);
         testee = new StoreQuotaManager(mockedCurrentQuotaManager, mockedMaxQuotaManager);
@@ -55,7 +55,7 @@ public class StoreQuotaManagerTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void getMessageQuotaShouldWorkWithNumericValues() throws Exception {
+    void getMessageQuotaShouldWorkWithNumericValues() throws Exception {
         when(mockedMaxQuotaManager.getMaxMessage(any(Map.class))).thenReturn(Optional.of(QuotaCountLimit.count(360L)));
         when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(QuotaCountUsage.count(36L));
         assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(
@@ -64,7 +64,7 @@ public class StoreQuotaManagerTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void getStorageQuotaShouldWorkWithNumericValues() throws Exception {
+    void getStorageQuotaShouldWorkWithNumericValues() throws Exception {
         when(mockedMaxQuotaManager.getMaxStorage(any(Map.class))).thenReturn(Optional.of(QuotaSizeLimit.size(360L)));
         when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(QuotaSizeUsage.size(36L));
         assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(
@@ -73,7 +73,7 @@ public class StoreQuotaManagerTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void getStorageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
+    void getStorageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
         when(mockedMaxQuotaManager.getMaxStorage(any(Map.class))).thenReturn(Optional.of(QuotaSizeLimit.unlimited()));
         when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(QuotaSizeUsage.size(36L));
 
@@ -83,7 +83,7 @@ public class StoreQuotaManagerTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void getMessageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
+    void getMessageQuotaShouldCalculateCurrentQuotaWhenUnlimited() throws Exception {
         when(mockedMaxQuotaManager.getMaxMessage(any(Map.class))).thenReturn(Optional.of(QuotaCountLimit.unlimited()));
         when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(QuotaCountUsage.count(36L));
 


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


[james-project] 28/42: [Refactoring] Move FlagsUpdateCalculatorTest to JUnit 5

Posted by rc...@apache.org.
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 52640e0363717f20bd06f28189c9247bdd8badd3
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:59:49 2019 +0700

    [Refactoring] Move FlagsUpdateCalculatorTest to JUnit 5
---
 .../james/mailbox/store/FlagsUpdateCalculatorTest.java     | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/FlagsUpdateCalculatorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/FlagsUpdateCalculatorTest.java
index 156ee2b..5cf7c4a 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/FlagsUpdateCalculatorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/FlagsUpdateCalculatorTest.java
@@ -25,34 +25,36 @@ import javax.mail.Flags;
 
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.store.FlagsUpdateCalculator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class FlagsUpdateCalculatorTest {
+class FlagsUpdateCalculatorTest {
 
     @Test
-    public void flagsShouldBeReplacedWhenReplaceIsTrueAndValueIsTrue() {
+    void flagsShouldBeReplacedWhenReplaceIsTrueAndValueIsTrue() {
         FlagsUpdateCalculator flagsUpdateCalculator = new FlagsUpdateCalculator(
             new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("userflag").build(),
             MessageManager.FlagsUpdateMode.REPLACE);
+
         assertThat(flagsUpdateCalculator.buildNewFlags(new FlagsBuilder().add(Flags.Flag.RECENT, Flags.Flag.FLAGGED).build()))
             .isEqualTo(new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("userflag").build());
     }
 
     @Test
-    public void flagsShouldBeAddedWhenReplaceIsFalseAndValueIsTrue() {
+    void flagsShouldBeAddedWhenReplaceIsFalseAndValueIsTrue() {
         FlagsUpdateCalculator flagsUpdateCalculator = new FlagsUpdateCalculator(
             new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("userflag").build(),
             MessageManager.FlagsUpdateMode.ADD);
+
         assertThat(flagsUpdateCalculator.buildNewFlags(new FlagsBuilder().add(Flags.Flag.RECENT, Flags.Flag.FLAGGED).build()))
             .isEqualTo(new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED, Flags.Flag.RECENT).add("userflag").build());
     }
 
     @Test
-    public void flagsShouldBeRemovedWhenReplaceIsFalseAndValueIsFalse() {
+    void flagsShouldBeRemovedWhenReplaceIsFalseAndValueIsFalse() {
         FlagsUpdateCalculator flagsUpdateCalculator = new FlagsUpdateCalculator(
             new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("userflag").build(),
             MessageManager.FlagsUpdateMode.REMOVE);
+
         assertThat(flagsUpdateCalculator.buildNewFlags(new FlagsBuilder().add(Flags.Flag.RECENT, Flags.Flag.FLAGGED).build()))
             .isEqualTo(new Flags(Flags.Flag.RECENT));
     }


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


[james-project] 18/42: [Refactoring] Move MetadataMapAssertTest to JUnit 5

Posted by rc...@apache.org.
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 533c63c4615f45755f450aac71b1dcd6678d7462
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:42:14 2019 +0700

    [Refactoring] Move MetadataMapAssertTest to JUnit 5
---
 .../store/mail/model/MetadataMapAssertTest.java    | 55 +++++++++++++---------
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssertTest.java
index 8cf829a..af057a0 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssertTest.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mailbox.store.mail.model;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -33,23 +35,23 @@ import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MetadataMapAssertTest {
+class MetadataMapAssertTest {
 
-    private static final MessageUid UID = MessageUid.of(18);
-    private static final MessageId MESSAGE_ID = new DefaultMessageId();
-    private static final ModSeq MODSEQ = ModSeq.of(24L);
-    private static final Date DATE = new Date();
-    private static final String HEADER_STRING = "name: headerName\n\n";
-    private static final String BODY_STRING = "body\\n.\\n";
-    private static final TestId MAILBOX_ID = TestId.of(12L);
+    static final MessageUid UID = MessageUid.of(18);
+    static final MessageId MESSAGE_ID = new DefaultMessageId();
+    static final ModSeq MODSEQ = ModSeq.of(24L);
+    static final Date DATE = new Date();
+    static final String HEADER_STRING = "name: headerName\n\n";
+    static final String BODY_STRING = "body\\n.\\n";
+    static final TestId MAILBOX_ID = TestId.of(12L);
 
-    private SimpleMailboxMessage message1;
+    SimpleMailboxMessage message1;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         message1 = new SimpleMailboxMessage(MESSAGE_ID, DATE, HEADER_STRING.length() + BODY_STRING.length(),
             HEADER_STRING.length(), new SharedByteArrayInputStream((HEADER_STRING + BODY_STRING).getBytes()), new Flags(), new PropertyBuilder(), MAILBOX_ID);
         message1.setUid(UID);
@@ -57,33 +59,40 @@ public class MetadataMapAssertTest {
     }
 
     @Test
-    public void metadataMapAssertShouldSucceedWhenContainingRightMetadata() {
+    void metadataMapAssertShouldSucceedWhenContainingRightMetadata() {
         Map<MessageUid, MessageMetaData> metaDataMap = new HashMap<>();
         metaDataMap.put(UID, new MessageMetaData(UID, MODSEQ, new Flags(), HEADER_STRING.length() + BODY_STRING.length(), DATE, MESSAGE_ID));
+        
         MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1);
     }
 
-    @Test(expected = AssertionError.class)
-    public void metadataMapAssertShouldFailWhenUidMismatch() {
+    @Test
+    void metadataMapAssertShouldFailWhenUidMismatch() {
         Map<MessageUid, MessageMetaData> metaDataMap = new HashMap<>();
         metaDataMap.put(UID, new MessageMetaData(UID.next(), MODSEQ, new Flags(), HEADER_STRING.length() + BODY_STRING.length(), DATE, MESSAGE_ID));
-        MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1);
+        
+        assertThatThrownBy(() -> MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1))
+            .isInstanceOf(AssertionError.class);
     }
 
-    @Test(expected = AssertionError.class)
-    public void metadataMapAssertShouldFailWhenDateMismatch() {
+    @Test
+    void metadataMapAssertShouldFailWhenDateMismatch() {
         Map<MessageUid, MessageMetaData> metaDataMap = new HashMap<>();
         Date date = new Date();
         date.setTime(DATE.getTime() + 100L);
         metaDataMap.put(UID, new MessageMetaData(UID, MODSEQ, new Flags(), HEADER_STRING.length() + BODY_STRING.length(), date, MESSAGE_ID));
-        MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1);
+
+        assertThatThrownBy(() -> MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1))
+            .isInstanceOf(AssertionError.class);
     }
 
-    @Test(expected = AssertionError.class)
-    public void metadataMapAssertShouldFailWhenSizeMismatch() {
+    @Test
+    void metadataMapAssertShouldFailWhenSizeMismatch() {
         Map<MessageUid, MessageMetaData> metaDataMap = new HashMap<>();
         metaDataMap.put(UID, new MessageMetaData(UID, MODSEQ, new Flags(), HEADER_STRING.length() + BODY_STRING.length() + 1, DATE, MESSAGE_ID));
-        MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1);
+
+        assertThatThrownBy(() -> MetadataMapAssert.assertThat(metaDataMap).containsMetadataForMessages(message1))
+            .isInstanceOf(AssertionError.class);
     }
 
 


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


[james-project] 06/42: [Refactoring] Move MessageParserTest to JUnit 5

Posted by rc...@apache.org.
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 b5a6943d8b4e0fe6af659337508f6b2d5dcc3da8
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:54:26 2019 +0700

    [Refactoring] Move MessageParserTest to JUnit 5
---
 .../store/mail/model/impl/MessageParserTest.java   | 76 +++++++++++-----------
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
index abb864f..a7cecc19 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
@@ -37,34 +37,34 @@ import org.apache.james.mdn.sending.mode.DispositionSendingMode;
 import org.apache.james.mdn.type.DispositionType;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MessageParserTest {
+class MessageParserTest {
 
-    private MessageParser testee;
+    MessageParser testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         testee = new MessageParser();
     }
 
     @Test
-    public void getAttachmentsShouldBeEmptyWhenNoAttachment() throws Exception {
+    void getAttachmentsShouldBeEmptyWhenNoAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/noAttachment.eml"));
 
         assertThat(attachments).isEmpty();
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenOneAttachment() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenOneAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentAndSomeTextInlined.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentNameWhenOne() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentNameWhenOne() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentAndSomeTextInlined.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -73,14 +73,14 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentNameWhenOneContainingNonASCIICharacters() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentNameWhenOneContainingNonASCIICharacters() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/messageWithNonASCIIFilenameAttachment.eml"));
         assertThat(attachments).hasSize(1);
         assertThat(attachments.get(0).getName()).contains("ديناصور.odt");
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveEmptyNameWhenNone() throws Exception {
+    void getAttachmentsShouldRetrieveEmptyNameWhenNone() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentWithoutName.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -88,7 +88,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldNotFailWhenContentTypeIsNotHere() throws Exception {
+    void getAttachmentsShouldNotFailWhenContentTypeIsNotHere() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentWithoutContentType.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -96,7 +96,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldNotFailWhenContentTypeIsEmpty() throws Exception {
+    void getAttachmentsShouldNotFailWhenContentTypeIsEmpty() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentWithEmptyContentType.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -104,7 +104,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveTheAttachmentContentTypeWhenOneAttachment() throws Exception {
+    void getAttachmentsShouldRetrieveTheAttachmentContentTypeWhenOneAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentAndSomeTextInlined.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -112,21 +112,21 @@ public class MessageParserTest {
     }
 
     @Test
-    public void retrieveAttachmentsShouldNotFailOnMessagesWithManyHeaders() throws Exception {
+    void retrieveAttachmentsShouldNotFailOnMessagesWithManyHeaders() throws Exception {
         List<MessageAttachment> messageAttachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/mailWithManyHeaders.eml"));
 
         assertThat(messageAttachments).hasSize(1);
     }
 
     @Test
-    public void retrieveAttachmentsShouldNotFailOnMessagesWithLongHeaders() throws Exception {
+    void retrieveAttachmentsShouldNotFailOnMessagesWithLongHeaders() throws Exception {
         List<MessageAttachment> messageAttachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/mailWithLongHeaders.eml"));
 
         assertThat(messageAttachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveTheAttachmentContentTypeWhenOneAttachmentWithSimpleContentType() throws Exception {
+    void getAttachmentsShouldRetrieveTheAttachmentContentTypeWhenOneAttachmentWithSimpleContentType() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentWithSimpleContentType.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -134,7 +134,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveTheAttachmentSizeWhenOneAttachment() throws Exception {
+    void getAttachmentsShouldRetrieveTheAttachmentSizeWhenOneAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentAndSomeTextInlined.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -142,7 +142,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldReturnTheExpectedAttachment() throws Exception {
+    void getAttachmentsShouldReturnTheExpectedAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneAttachmentAndSomeTextInlined.eml"));
 
         Attachment attachment = attachments.get(0).getAttachment();
@@ -150,14 +150,14 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenTwo() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenTwo() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"));
 
         assertThat(attachments).hasSize(2);
     }
 
     @Test
-    public void retrieveAttachmentShouldUseFilenameAsNameWhenNoName() throws Exception {
+    void retrieveAttachmentShouldUseFilenameAsNameWhenNoName() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/filenameOnly.eml"));
 
         assertThat(attachments).hasSize(1)
@@ -168,7 +168,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void retrieveAttachmentShouldUseNameWhenBothNameAndFilename() throws Exception {
+    void retrieveAttachmentShouldUseNameWhenBothNameAndFilename() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/filenameAndName.eml"));
 
         assertThat(attachments).hasSize(1)
@@ -179,21 +179,21 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveEmbeddedAttachmentsWhenSome() throws Exception {
+    void getAttachmentsShouldRetrieveEmbeddedAttachmentsWhenSome() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/embeddedAttachmentWithInline.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveInlineAttachmentsWhenSome() throws Exception {
+    void getAttachmentsShouldRetrieveInlineAttachmentsWhenSome() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/embeddedAttachmentWithAttachment.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveTheAttachmentCIDWhenOne() throws Exception {
+    void getAttachmentsShouldRetrieveTheAttachmentCIDWhenOne() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachment.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -201,7 +201,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldSetInlineWhenOneInlinedAttachment() throws Exception {
+    void getAttachmentsShouldSetInlineWhenOneInlinedAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachment.eml"));
 
         assertThat(attachments).hasSize(1);
@@ -209,63 +209,63 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachementsShouldRetrieveHtmlAttachementsWhenSome() throws Exception {
+    void getAttachementsShouldRetrieveHtmlAttachementsWhenSome() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneHtmlAttachmentAndSomeTextInlined.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachementsShouldRetrieveAttachmentsWhenSomeAreInTheMultipartAlternative() throws Exception {
+    void getAttachementsShouldRetrieveAttachmentsWhenSomeAreInTheMultipartAlternative() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/invitationEmailFromOP.eml"));
         
         assertThat(attachments).hasSize(7);
     }
 
     @Test
-    public void getAttachmentsShouldNotConsiderUnknownContentDispositionAsAttachments() throws Exception {
+    void getAttachmentsShouldNotConsiderUnknownContentDispositionAsAttachments() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/unknownDisposition.eml"));
 
         assertThat(attachments).hasSize(0);
     }
 
     @Test
-    public void getAttachmentsShouldConsiderNoContentDispositionAsAttachmentsWhenCID() throws Exception {
+    void getAttachmentsShouldConsiderNoContentDispositionAsAttachmentsWhenCID() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/noContentDispositionWithCID.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenNoCidForInlined() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenNoCidForInlined() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachmentWithNoCid.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenEmptyCidForInlined() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenEmptyCidForInlined() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachmentWithEmptyCid.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenBlankCidForInlined() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenBlankCidForInlined() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachmentWithBlankCid.eml"));
 
         assertThat(attachments).hasSize(1);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveAttachmentsWhenOneFailOnWrongContentDisposition() throws Exception {
+    void getAttachmentsShouldRetrieveAttachmentsWhenOneFailOnWrongContentDisposition() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/multiAttachmentsWithOneWrongContentDisposition.eml"));
 
         assertThat(attachments).hasSize(2);
     }
 
     @Test
-    public void getAttachmentsShouldRetrieveOneAttachmentWhenMessageWithAttachmentContentDisposition() throws Exception {
+    void getAttachmentsShouldRetrieveOneAttachmentWhenMessageWithAttachmentContentDisposition() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(
             ClassLoader.getSystemResourceAsStream("eml/emailWithOnlyAttachment.eml"));
 
@@ -273,7 +273,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void getAttachmentsShouldConsiderICSAsAttachments() throws Exception {
+    void getAttachmentsShouldConsiderICSAsAttachments() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(
             ClassLoader.getSystemResourceAsStream("eml/calendar.eml"));
 
@@ -283,7 +283,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void gpgSignatureShouldBeConsideredAsAnAttachment() throws Exception {
+    void gpgSignatureShouldBeConsideredAsAnAttachment() throws Exception {
         List<MessageAttachment> attachments = testee.retrieveAttachments(
             ClassLoader.getSystemResourceAsStream("eml/signedMessage.eml"));
 
@@ -295,7 +295,7 @@ public class MessageParserTest {
     }
 
     @Test
-    public void mdnReportShouldBeConsideredAsAttachmentWhenDispositionContentType() throws Exception {
+    void mdnReportShouldBeConsideredAsAttachmentWhenDispositionContentType() throws Exception {
         Message message = MDN.builder()
             .humanReadableText("A little test")
             .report(MDNReport.builder()


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


[james-project] 14/42: [Refactoring] Move ListMessageAssertTest to JUnit 5

Posted by rc...@apache.org.
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 b3a7434ac3ca2345fadfc20601e8357f073a62ab
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:29:20 2019 +0700

    [Refactoring] Move ListMessageAssertTest to JUnit 5
---
 .../store/mail/model/ListMessageAssert.java        |  4 +-
 .../store/mail/model/ListMessageAssertTest.java    | 57 +++++++++++++---------
 2 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
index b5b8049..1fbc05a 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssert.java
@@ -38,7 +38,7 @@ import com.google.common.collect.Lists;
 public class ListMessageAssert {
     private final List<MailboxMessage> actual;
 
-    private final List<InnerMessage> messageToInnerMessage(List<MailboxMessage> messages) {
+    private List<InnerMessage> messageToInnerMessage(List<MailboxMessage> messages) {
         return messages.stream()
             .map(message -> getInnerMessage(message))
             .collect(Guavate.toImmutableList());
@@ -61,7 +61,7 @@ public class ListMessageAssert {
         return new ListMessageAssert(actual);
     }
 
-    public void containOnly(MailboxMessage... expecteds) throws IOException {
+    public void containOnly(MailboxMessage... expecteds) {
         assertThat(messageToInnerMessage(actual)).containsOnlyElementsOf(messageToInnerMessage(Lists.newArrayList(expecteds)));
     }
 
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
index 23eb451..51e9487 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMessageAssertTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store.mail.model;
 
 import static org.apache.james.mailbox.store.mail.model.ListMessageAssert.assertMessages;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -39,28 +40,28 @@ import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class ListMessageAssertTest {
-    private static final String BODY_CONTENT2 = "Subject: Test2 \n\nBody2\n.\n";
-    private static final String BODY_CONTENT1 = "Subject: Test1 \n\nBody1\n.\n";
-    private static final int BODY_START = 16;
-    private static final int UID_VALIDITY = 42;
-    private static final MailboxId MAILBOX_ID = TestId.of(1);
-    private static final MessageUid MESSAGE_UID = MessageUid.of(2);
-    private static final MessageId MESSAGE_ID = new DefaultMessageId();
-    private static final Date INTERNAL_DATE = new Date();
+class ListMessageAssertTest {
+    static final String BODY_CONTENT2 = "Subject: Test2 \n\nBody2\n.\n";
+    static final String BODY_CONTENT1 = "Subject: Test1 \n\nBody1\n.\n";
+    static final int BODY_START = 16;
+    static final int UID_VALIDITY = 42;
+    static final MailboxId MAILBOX_ID = TestId.of(1);
+    static final MessageUid MESSAGE_UID = MessageUid.of(2);
+    static final MessageId MESSAGE_ID = new DefaultMessageId();
+    static final Date INTERNAL_DATE = new Date();
 
-    private Mailbox benwaInboxMailbox;
+    Mailbox benwaInboxMailbox;
 
-    private MailboxMessage message1;
-    private MailboxMessage message2;
+    MailboxMessage message1;
+    MailboxMessage message2;
     
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         benwaInboxMailbox = createMailbox(MailboxPath.inbox(Username.of("user")));
 
         message1 = createMessage(benwaInboxMailbox, MESSAGE_ID, BODY_CONTENT1, BODY_START, new PropertyBuilder());
@@ -68,22 +69,28 @@ public class ListMessageAssertTest {
     }
 
     @Test
-    public void containsOnlyShouldWork() throws IOException {
+    void containsOnlyShouldWork() throws IOException {
         List<MailboxMessage> actual = ImmutableList.of(message1, message2);
-        assertMessages(actual).containOnly(createMailboxMessage(MAILBOX_ID, MESSAGE_ID, MESSAGE_UID, INTERNAL_DATE, BODY_CONTENT1, BODY_START, new PropertyBuilder()),
+
+        assertMessages(actual).containOnly(
+                createMailboxMessage(MAILBOX_ID, MESSAGE_ID, MESSAGE_UID, INTERNAL_DATE, BODY_CONTENT1, BODY_START, new PropertyBuilder()),
                 createMailboxMessage(MAILBOX_ID, MESSAGE_ID, MESSAGE_UID, INTERNAL_DATE, BODY_CONTENT2, BODY_START, new PropertyBuilder()));
     }
 
-    @Test(expected = AssertionError.class)
-    public void containsOnlyShouldThrowExceptionWhenHavingElementDoesNotBelongToList() throws IOException {
+    @Test
+    void containsOnlyShouldThrowExceptionWhenHavingElementDoesNotBelongToList() {
         List<MailboxMessage> actual = ImmutableList.of(message1);
-        assertMessages(actual).containOnly(createMailboxMessage(MAILBOX_ID, MESSAGE_ID, MESSAGE_UID, INTERNAL_DATE, BODY_CONTENT2, BODY_START, new PropertyBuilder()));
+
+        assertThatThrownBy(() -> assertMessages(actual).containOnly(
+                createMailboxMessage(MAILBOX_ID, MESSAGE_ID, MESSAGE_UID, INTERNAL_DATE, BODY_CONTENT2, BODY_START, new PropertyBuilder())))
+            .isInstanceOf(AssertionError.class);
     }
 
-    private MailboxMessage createMailboxMessage(MailboxId mailboxId, MessageId messageId, MessageUid uid,
-            Date internalDate, String content, int bodyStart, PropertyBuilder propertyBuilder) {
+    private MailboxMessage createMailboxMessage(MailboxId mailboxId, MessageId messageId, MessageUid uid, Date internalDate,
+                                                String content, int bodyStart, PropertyBuilder propertyBuilder) {
         SimpleMailboxMessage simpleMailboxMessage = new SimpleMailboxMessage(messageId, internalDate, content.length(),
             bodyStart, new SharedByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), new Flags(), propertyBuilder, mailboxId);
+
         simpleMailboxMessage.setUid(uid);
         simpleMailboxMessage.setModSeq(ModSeq.first());
         return simpleMailboxMessage;
@@ -97,7 +104,9 @@ public class ListMessageAssertTest {
     }
 
     private MailboxMessage createMessage(Mailbox mailbox, MessageId messageId, String content, int bodyStart, PropertyBuilder propertyBuilder) {
-        SimpleMailboxMessage simpleMailboxMessage = new SimpleMailboxMessage(messageId, INTERNAL_DATE, content.length(), bodyStart, new SharedByteArrayInputStream(content.getBytes()), new Flags(), propertyBuilder, mailbox.getMailboxId());
+        SimpleMailboxMessage simpleMailboxMessage = new SimpleMailboxMessage(messageId, INTERNAL_DATE, content.length(),
+            bodyStart, new SharedByteArrayInputStream(content.getBytes()), new Flags(), propertyBuilder, mailbox.getMailboxId());
+
         simpleMailboxMessage.setUid(MESSAGE_UID);
         return simpleMailboxMessage;
     }


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


[james-project] 13/42: [Refactoring] Move ListMailboxAssertTest to JUnit 5

Posted by rc...@apache.org.
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 78952e1f65839e62bb3820e9e0a50d318f97bbbd
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:24:07 2019 +0700

    [Refactoring] Move ListMailboxAssertTest to JUnit 5
---
 .../store/mail/model/ListMailboxAssert.java        |  2 +-
 .../store/mail/model/ListMailboxAssertTest.java    | 32 +++++++++++-----------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
index 39842c5..4d0d55e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
@@ -35,7 +35,7 @@ public class ListMailboxAssert {
 
     private final List<Mailbox> actual;
 
-    private final List<InnerMailbox> mailboxtoInnerMailbox(List<Mailbox> mailboxes) {
+    private List<InnerMailbox> mailboxtoInnerMailbox(List<Mailbox> mailboxes) {
         return mailboxes.stream()
             .map(mailbox ->
                 new InnerMailbox(mailbox.getMailboxId(), mailbox.getUser(), mailbox.getName(), mailbox.getNamespace()))
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
index ad4c5c0..ac87c08 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
@@ -27,36 +27,36 @@ import java.util.List;
 import org.apache.james.core.Username;
 import org.apache.james.mailbox.model.Mailbox;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class ListMailboxAssertTest {
-    private static final String OTHER_NAMESPACE = "other_namespace";
-    private static final String NAME = "name";
-    private static final Username USER = Username.of("user");
-    private static final String NAMESPACE = "namespace";
-    private static final long UID_VALIDITY = 42;
-    private static final Mailbox mailbox1 = new Mailbox(new MailboxPath(NAMESPACE, USER, NAME), UID_VALIDITY);
-    private static final Mailbox mailbox2 = new Mailbox(new MailboxPath(OTHER_NAMESPACE, USER, NAME), UID_VALIDITY);
+class ListMailboxAssertTest {
+    static final String OTHER_NAMESPACE = "other_namespace";
+    static final String NAME = "name";
+    static final Username USER = Username.of("user");
+    static final String NAMESPACE = "namespace";
+    static final long UID_VALIDITY = 42;
+    static final Mailbox mailbox1 = new Mailbox(new MailboxPath(NAMESPACE, USER, NAME), UID_VALIDITY);
+    static final Mailbox mailbox2 = new Mailbox(new MailboxPath(OTHER_NAMESPACE, USER, NAME), UID_VALIDITY);
 
-    private ListMailboxAssert listMaiboxAssert;
-    private List<Mailbox> actualMailbox;
+    ListMailboxAssert listMaiboxAssert;
+    List<Mailbox> actualMailbox;
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         actualMailbox = ImmutableList.of(mailbox1, mailbox2);
         listMaiboxAssert = ListMailboxAssert.assertMailboxes(actualMailbox);
     }
 
     @Test
-    public void initListMailboxAssertShouldWork() {
+    void initListMailboxAssertShouldWork() {
         assertThat(listMaiboxAssert).isNotNull();
     }
 
     @Test
-    public void assertListMailboxShouldWork() {
+    void assertListMailboxShouldWork() {
         assertMailboxes(actualMailbox).containOnly(new Mailbox(new MailboxPath(NAMESPACE, USER, NAME), UID_VALIDITY),
             new Mailbox(new MailboxPath(OTHER_NAMESPACE, USER, NAME), UID_VALIDITY));
     }


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


[james-project] 07/42: [Refactoring] Move PropertyBuilderTest to JUnit 5

Posted by rc...@apache.org.
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 644c75e51ce3984e16397ef0266cf7f42af4b66a
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 15:55:14 2019 +0700

    [Refactoring] Move PropertyBuilderTest to JUnit 5
---
 .../mailbox/store/mail/model/impl/PropertyBuilderTest.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
index 320faf6..1317441 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
@@ -22,17 +22,17 @@ package org.apache.james.mailbox.store.mail.model.impl;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.mailbox.store.mail.model.Property;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class PropertyBuilderTest {
+class PropertyBuilderTest {
 
     @Test
-    public void emptyPropertyBuilderShouldCreateEmptyProperties() {
+    void emptyPropertyBuilderShouldCreateEmptyProperties() {
         assertThat(new PropertyBuilder().toProperties()).isEmpty();
     }
 
     @Test
-    public void setHasAttachmentShouldAddFalseWhenCalledWithFalse() {
+    void setHasAttachmentShouldAddFalseWhenCalledWithFalse() {
         PropertyBuilder propertyBuilder = new PropertyBuilder();
         propertyBuilder.setHasAttachment(false);
         assertThat(propertyBuilder.toProperties())
@@ -40,7 +40,7 @@ public class PropertyBuilderTest {
     }
 
     @Test
-    public void setHasAttachmentShouldAddTrueWhenCalledWithTrue() {
+    void setHasAttachmentShouldAddTrueWhenCalledWithTrue() {
         PropertyBuilder propertyBuilder = new PropertyBuilder();
         propertyBuilder.setHasAttachment(true);
         assertThat(propertyBuilder.toProperties())


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


[james-project] 42/42: [Refactoring] Move SystemMailboxesProviderImplTest to JUnit 5

Posted by rc...@apache.org.
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 8ae9166e1e944d23b359dda5b81d054dd96f3af0
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:22:29 2019 +0700

    [Refactoring] Move SystemMailboxesProviderImplTest to JUnit 5
---
 .../store/SystemMailboxesProviderImplTest.java     | 27 +++++++++-------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
index c83f1b1..48b16f6 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
@@ -31,25 +31,20 @@ import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.Role;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.fixture.MailboxFixture;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class SystemMailboxesProviderImplTest {
+class SystemMailboxesProviderImplTest {
 
-    private MailboxSession mailboxSession = MailboxSessionUtil.create(MailboxFixture.ALICE);
-    private SystemMailboxesProviderImpl systemMailboxProvider;
+    MailboxSession mailboxSession = MailboxSessionUtil.create(MailboxFixture.ALICE);
+    SystemMailboxesProviderImpl systemMailboxProvider;
 
-    private MailboxManager mailboxManager;
+    MailboxManager mailboxManager;
 
-    private MessageManager inboxMessageManager;
+    MessageManager inboxMessageManager;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() {
         mailboxManager = mock(MailboxManager.class);
         inboxMessageManager = mock(MessageManager.class);
 
@@ -57,7 +52,7 @@ public class SystemMailboxesProviderImplTest {
     }
 
     @Test
-    public void getMailboxByRoleShouldReturnEmptyWhenNoMailbox() throws Exception {
+    void getMailboxByRoleShouldReturnEmptyWhenNoMailbox() throws Exception {
         when(mailboxManager.createSystemSession(MailboxFixture.ALICE)).thenReturn(mailboxSession);
         when(mailboxManager.getMailbox(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenThrow(MailboxNotFoundException.class);
 
@@ -65,7 +60,7 @@ public class SystemMailboxesProviderImplTest {
     }
 
     @Test
-    public void getMailboxByRoleShouldReturnMailboxByRole() throws Exception {
+    void getMailboxByRoleShouldReturnMailboxByRole() throws Exception {
         when(mailboxManager.createSystemSession(MailboxFixture.ALICE)).thenReturn(mailboxSession);
         when(mailboxManager.getMailbox(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenReturn(inboxMessageManager);
 


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


[james-project] 17/42: [Refactoring] Move MessageUidProviderTest to JUnit 5

Posted by rc...@apache.org.
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 7f100472883ca7de073600a80009d9d14f28196a
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:38:36 2019 +0700

    [Refactoring] Move MessageUidProviderTest to JUnit 5
---
 .../store/mail/model/MessageUidProviderTest.java       | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageUidProviderTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageUidProviderTest.java
index 870a864..8631af4 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageUidProviderTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageUidProviderTest.java
@@ -21,20 +21,20 @@ package org.apache.james.mailbox.store.mail.model;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.mailbox.MessageUid;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MessageUidProviderTest {
+class MessageUidProviderTest {
 
-    private MessageUidProvider testee;
+    MessageUidProvider testee;
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    void setup() {
         testee = new MessageUidProvider();
     }
 
     @Test
-    public void nextShouldReturn1WhenFirstCall() {
+    void nextShouldReturn1WhenFirstCall() {
         MessageUid messageUid = testee.next();
 
         MessageUid expectedMessageUid = MessageUid.of(1);
@@ -42,7 +42,7 @@ public class MessageUidProviderTest {
     }
 
     @Test
-    public void nextShouldReturn2WhenSecondCall() {
+    void nextShouldReturn2WhenSecondCall() {
         testee.next();
         MessageUid messageUid = testee.next();
 
@@ -51,7 +51,7 @@ public class MessageUidProviderTest {
     }
 
     @Test
-    public void nextShouldReturn3WhenThirdCall() {
+    void nextShouldReturn3WhenThirdCall() {
         testee.next();
         testee.next();
         MessageUid messageUid = testee.next();


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


[james-project] 29/42: [Refactoring] Move MailboxMessageResultImplTest to JUnit 5

Posted by rc...@apache.org.
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 d205631e2e01160003f1696fcbe9bdd9f1e54fc1
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 17:00:26 2019 +0700

    [Refactoring] Move MailboxMessageResultImplTest to JUnit 5
---
 .../store/MailboxMessageResultImplTest.java        | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
index a22bfe4..af19971 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxMessageResultImplTest.java
@@ -25,10 +25,10 @@ import java.util.Date;
 
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-public class MailboxMessageResultImplTest {
+class MailboxMessageResultImplTest {
     private MessageResultImpl msgResultA;
     private MessageResultImpl msgResultACopy;
     private MessageResultImpl msgResultB;
@@ -37,8 +37,8 @@ public class MailboxMessageResultImplTest {
     /**
      * Initialize name instances
      */
-    @Before
-    public void initNames() throws Exception {
+    @BeforeEach
+    void initNames() throws Exception {
         Date dateAB = new Date();
         MailboxMessage msgA = buildMessage(MessageUid.of(100), dateAB);
         MailboxMessage msgB = buildMessage(MessageUid.of(100), dateAB);
@@ -60,45 +60,45 @@ public class MailboxMessageResultImplTest {
 
 
     @Test
-    public void testEqualsNull() {
+    void testEqualsNull() {
         assertThat(msgResultA).isNotNull();
     }
 
 
     @Test
-    public void testEqualsReflexive() {
+    void testEqualsReflexive() {
         assertThat(msgResultA).isEqualTo(msgResultA);
     }
 
 
     @Test
-    public void testCompareToReflexive() {
+    void testCompareToReflexive() {
         assertThat(msgResultA.compareTo(msgResultA)).isEqualTo(0);
     }
 
 
     @Test
-    public void testHashCodeReflexive() {
+    void testHashCodeReflexive() {
         assertThat(msgResultA.hashCode()).isEqualTo(msgResultA.hashCode());
     }
 
 
     @Test
-    public void testEqualsSymmetric() {
+    void testEqualsSymmetric() {
         assertThat(msgResultACopy).isEqualTo(msgResultA);
         assertThat(msgResultA).isEqualTo(msgResultACopy);
     }
 
 
     @Test
-    public void testHashCodeSymmetric() {
+    void testHashCodeSymmetric() {
         assertThat(msgResultACopy.hashCode()).isEqualTo(msgResultA.hashCode());
         assertThat(msgResultA.hashCode()).isEqualTo(msgResultACopy.hashCode());
     }
 
 
     @Test
-    public void testEqualsTransitive() {
+    void testEqualsTransitive() {
         assertThat(msgResultACopy).isEqualTo(msgResultA);
         assertThat(msgResultB).isEqualTo(msgResultACopy);
         assertThat(msgResultB).isEqualTo(msgResultA);
@@ -106,7 +106,7 @@ public class MailboxMessageResultImplTest {
 
 
     @Test
-    public void testCompareToTransitive() {
+    void testCompareToTransitive() {
         assertThat(msgResultA.compareTo(msgResultACopy)).isEqualTo(0);
         assertThat(msgResultACopy.compareTo(msgResultB)).isEqualTo(0);
         assertThat(msgResultA.compareTo(msgResultB)).isEqualTo(0);
@@ -114,7 +114,7 @@ public class MailboxMessageResultImplTest {
 
 
     @Test
-    public void testHashCodeTransitive() {
+    void testHashCodeTransitive() {
         assertThat(msgResultACopy.hashCode()).isEqualTo(msgResultA.hashCode());
         assertThat(msgResultB.hashCode()).isEqualTo(msgResultACopy.hashCode());
         assertThat(msgResultB.hashCode()).isEqualTo(msgResultA.hashCode());
@@ -122,18 +122,18 @@ public class MailboxMessageResultImplTest {
 
 
     @Test
-    public void testNotEqualDiffValue() {
+    void testNotEqualDiffValue() {
         assertThat(msgResultA).isNotEqualTo(msgResultC);
         assertThat(msgResultC).isNotEqualTo(msgResultA);
     }
 
     @Test
-    public void testShouldReturnPositiveWhenFirstGreaterThanSecond() {
+    void testShouldReturnPositiveWhenFirstGreaterThanSecond() {
         assertThat(msgResultC.compareTo(msgResultB) > 0).isTrue();
     }
 
     @Test
-    public void testShouldReturnNegativeWhenFirstLessThanSecond() {
+    void testShouldReturnNegativeWhenFirstLessThanSecond() {
         assertThat(msgResultB.compareTo(msgResultC) < 0).isTrue();
     }
 }
\ 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


[james-project] 08/42: [Refactoring] Move SimpleMailboxMessageTest to JUnit 5

Posted by rc...@apache.org.
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 74fd6c17993c31cb06f492ece110902d657d78d4
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Dec 5 16:11:44 2019 +0700

    [Refactoring] Move SimpleMailboxMessageTest to JUnit 5
---
 .../mail/model/impl/SimpleMailboxMessageTest.java  | 289 ++++++++++-----------
 1 file changed, 138 insertions(+), 151 deletions(-)

diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
index 9baff66..4d1ff30 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessageTest.java
@@ -19,6 +19,7 @@
 package org.apache.james.mailbox.store.mail.model.impl;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -40,45 +41,38 @@ import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.assertj.core.api.JUnitSoftAssertions;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableList;
 
-public class SimpleMailboxMessageTest {
-    private static final Charset MESSAGE_CHARSET = StandardCharsets.UTF_8;
-    private static final String MESSAGE_CONTENT = "Simple message content without special characters";
-    public static final SharedByteArrayInputStream CONTENT_STREAM = new SharedByteArrayInputStream(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET));
-    private static final String MESSAGE_CONTENT_SPECIAL_CHAR = "Simple message content with special characters: \"'(§è!çà$*`";
-    public static final TestId TEST_ID = TestId.of(1L);
-    public static final int BODY_START_OCTET = 0;
-    public static final MessageId MESSAGE_ID = new TestMessageId.Factory().generate();
-    public static final int SIZE = 1000;
-    private SimpleMailboxMessage message;
-    private SimpleMailboxMessage messageSpecialChar;
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Rule
-    public final JUnitSoftAssertions soft = new JUnitSoftAssertions();
-
-    @Before
-    public void setUp() {
+class SimpleMailboxMessageTest {
+    static final Charset MESSAGE_CHARSET = StandardCharsets.UTF_8;
+    static final String MESSAGE_CONTENT = "Simple message content without special characters";
+    static final SharedByteArrayInputStream CONTENT_STREAM = new SharedByteArrayInputStream(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET));
+    static final String MESSAGE_CONTENT_SPECIAL_CHAR = "Simple message content with special characters: \"'(§è!çà$*`";
+    static final TestId TEST_ID = TestId.of(1L);
+    static final int BODY_START_OCTET = 0;
+    static final MessageId MESSAGE_ID = new TestMessageId.Factory().generate();
+    static final int SIZE = 1000;
+
+    SimpleMailboxMessage message;
+    SimpleMailboxMessage messageSpecialChar;
+
+    @BeforeEach
+    void setUp() {
         this.message = buildMessage(MESSAGE_CONTENT);
         this.messageSpecialChar = buildMessage(MESSAGE_CONTENT_SPECIAL_CHAR);
     }
 
     @Test
-    public void testSize() {
+    void testSize() {
         assertThat(message.getFullContentOctets()).isEqualTo(MESSAGE_CONTENT.length());
     }
 
     @Test
-    public void testInputStreamSize() throws IOException {
+    void testInputStreamSize() throws IOException {
         try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
             byteArrayOutputStream.write(message.getFullContent());
             assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET).length);
@@ -86,7 +80,7 @@ public class SimpleMailboxMessageTest {
     }
 
     @Test
-    public void testInputStreamSizeSpecialCharacters() throws IOException {
+    void testInputStreamSizeSpecialCharacters() throws IOException {
         try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
             byteArrayOutputStream.write(messageSpecialChar.getFullContent());
             assertThat(byteArrayOutputStream.size()).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR.getBytes(MESSAGE_CHARSET).length);
@@ -94,19 +88,19 @@ public class SimpleMailboxMessageTest {
     }
 
     @Test
-    public void testFullContent() throws IOException {
+    void testFullContent() throws IOException {
         assertThat(new String(IOUtils.toByteArray(message.getFullContent()), MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT);
         assertThat(new String(IOUtils.toByteArray(messageSpecialChar.getFullContent()), MESSAGE_CHARSET)).isEqualTo(MESSAGE_CONTENT_SPECIAL_CHAR);
     }
 
     @Test
-    public void simpleMessageShouldReturnTheSameUserFlagsThatThoseProvided() {
+    void simpleMessageShouldReturnTheSameUserFlagsThatThoseProvided() {
         message.setFlags(new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.SEEN).add("mozzarela", "parmesan", "coppa", "limonchello").build());
         assertThat(message.createUserFlags()).containsOnly("mozzarela", "parmesan", "coppa", "limonchello");
     }
 
     @Test
-    public void copyShouldReturnFieldByFieldEqualsObject() throws Exception {
+    void copyShouldReturnFieldByFieldEqualsObject() throws Exception {
         long textualLineCount = 42L;
         String text = "text";
         String plain = "plain";
@@ -144,23 +138,21 @@ public class SimpleMailboxMessageTest {
     }
 
     @Test
-    public void sizeShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        SimpleMailboxMessage.builder()
-            .size(-1);
+    void sizeShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .size(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void bodyStartOctetShouldThrowWhenNegative() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        SimpleMailboxMessage.builder()
-            .bodyStartOctet(-1);
+    void bodyStartOctetShouldThrowWhenNegative() {
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .bodyStartOctet(-1))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void buildShouldWorkWithMinimalContent() {
+    void buildShouldWorkWithMinimalContent() {
         Date internalDate = new Date();
         SimpleMailboxMessage.builder()
             .messageId(MESSAGE_ID)
@@ -177,7 +169,7 @@ public class SimpleMailboxMessageTest {
 
 
     @Test
-    public void buildShouldCreateAMessageWithAllFields() throws IOException {
+    void buildShouldCreateAMessageWithAllFields() throws IOException {
         Date internalDate = new Date();
         Flags flags = new Flags();
         PropertyBuilder propertyBuilder = new PropertyBuilder();
@@ -204,145 +196,140 @@ public class SimpleMailboxMessageTest {
             .propertyBuilder(propertyBuilder)
             .addAttachments(ImmutableList.of(messageAttachment))
             .build();
-
-        soft.assertThat(message.getMessageId()).isEqualTo(MESSAGE_ID);
-        soft.assertThat(message.getMailboxId()).isEqualTo(TEST_ID);
-        soft.assertThat(message.getInternalDate()).isEqualTo(internalDate);
-        soft.assertThat(message.getHeaderOctets()).isEqualTo(BODY_START_OCTET);
-        soft.assertThat(message.getFullContentOctets()).isEqualTo(SIZE);
-        soft.assertThat(IOUtils.toString(message.getFullContent(), StandardCharsets.UTF_8)).isEqualTo(MESSAGE_CONTENT);
-        soft.assertThat(message.createFlags()).isEqualTo(flags);
-        soft.assertThat(message.getProperties()).isEqualTo(propertyBuilder.toProperties());
-        soft.assertThat(message.getUid()).isEqualTo(uid);
-        soft.assertThat(message.getModSeq()).isEqualTo(modseq);
-        soft.assertThat(message.getAttachments()).containsOnly(messageAttachment);
+        String messageContent = IOUtils.toString(message.getFullContent(), StandardCharsets.UTF_8);
+
+        SoftAssertions.assertSoftly(soft -> {
+            soft.assertThat(message.getMessageId()).isEqualTo(MESSAGE_ID);
+            soft.assertThat(message.getMailboxId()).isEqualTo(TEST_ID);
+            soft.assertThat(message.getInternalDate()).isEqualTo(internalDate);
+            soft.assertThat(message.getHeaderOctets()).isEqualTo(BODY_START_OCTET);
+            soft.assertThat(message.getFullContentOctets()).isEqualTo(SIZE);
+            soft.assertThat(messageContent).isEqualTo(MESSAGE_CONTENT);
+            soft.assertThat(message.createFlags()).isEqualTo(flags);
+            soft.assertThat(message.getProperties()).isEqualTo(propertyBuilder.toProperties());
+            soft.assertThat(message.getUid()).isEqualTo(uid);
+            soft.assertThat(message.getModSeq()).isEqualTo(modseq);
+            soft.assertThat(message.getAttachments()).containsOnly(messageAttachment);
+        });
     }
 
     @Test
-    public void buildShouldThrowOnMissingMessageId() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingMessageId() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingMailboxId() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingMailboxId() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingInternalDate() {
-        expectedException.expect(NullPointerException.class);
-
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+    void buildShouldThrowOnMissingInternalDate() {
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingBodyStartOctets() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingBodyStartOctets() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingSize() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingSize() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingContent() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingContent() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .flags(new Flags())
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .flags(new Flags())
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingFlags() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingFlags() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .propertyBuilder(new PropertyBuilder())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .propertyBuilder(new PropertyBuilder())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void buildShouldThrowOnMissingProperties() {
-        expectedException.expect(NullPointerException.class);
-
+    void buildShouldThrowOnMissingProperties() {
         Date internalDate = new Date();
-        SimpleMailboxMessage.builder()
-            .messageId(MESSAGE_ID)
-            .mailboxId(TEST_ID)
-            .internalDate(internalDate)
-            .bodyStartOctet(BODY_START_OCTET)
-            .size(SIZE)
-            .content(CONTENT_STREAM)
-            .flags(new Flags())
-            .build();
+        assertThatThrownBy(() -> SimpleMailboxMessage.builder()
+                .messageId(MESSAGE_ID)
+                .mailboxId(TEST_ID)
+                .internalDate(internalDate)
+                .bodyStartOctet(BODY_START_OCTET)
+                .size(SIZE)
+                .content(CONTENT_STREAM)
+                .flags(new Flags())
+                .build())
+            .isInstanceOf(NullPointerException.class);
     }
 
 }


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