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 e3a04cb12f273bb9b4f961155b9a59ace1b1ec11
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Fri Nov 22 09:47:18 2019 +0700

    [Refactoring] MessageUtils is only used by JPA
---
 .../james/mailbox/jpa/mail/JPAMessageMapper.java      |  3 +--
 .../apache/james/mailbox/jpa}/mail/MessageUtils.java  | 19 ++++++++++++-------
 .../james/mailbox/jpa}/mail/MessageUtilsTest.java     |  4 +++-
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
index c319fe6..601a731 100644
--- 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
+++ 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
@@ -35,6 +35,7 @@ import org.apache.james.mailbox.ModSeq;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPATransactionalMapper;
+import org.apache.james.mailbox.jpa.mail.MessageUtils.MessageChangedFlags;
 import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import 
org.apache.james.mailbox.jpa.mail.model.openjpa.AbstractJPAMailboxMessage;
 import 
org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMailboxMessage;
@@ -48,8 +49,6 @@ import org.apache.james.mailbox.model.MessageRange.Type;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.FlagsUpdateCalculator;
 import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.MessageUtils;
-import org.apache.james.mailbox.store.mail.MessageUtils.MessageChangedFlags;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MessageUtils.java
 b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/MessageUtils.java
similarity index 85%
rename from 
mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MessageUtils.java
rename to 
mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/MessageUtils.java
index 55dcf8a..bd5d513 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MessageUtils.java
+++ 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/MessageUtils.java
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mailbox.store.mail;
+package org.apache.james.mailbox.jpa.mail;
 
 import java.util.Iterator;
 import java.util.List;
@@ -30,16 +30,19 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Mailbox;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.FlagsUpdateCalculator;
+import org.apache.james.mailbox.store.mail.ModSeqProvider;
+import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
-public class MessageUtils {
+class MessageUtils {
     private final UidProvider uidProvider;
     private final ModSeqProvider modSeqProvider;
 
-    public MessageUtils(UidProvider uidProvider, ModSeqProvider 
modSeqProvider) {
+    MessageUtils(UidProvider uidProvider, ModSeqProvider modSeqProvider) {
         Preconditions.checkNotNull(uidProvider);
         Preconditions.checkNotNull(modSeqProvider);
 
@@ -47,13 +50,13 @@ public class MessageUtils {
         this.modSeqProvider = modSeqProvider;
     }
 
-    public void enrichMessage(Mailbox mailbox, MailboxMessage message) throws 
MailboxException { 
+    void enrichMessage(Mailbox mailbox, MailboxMessage message) throws 
MailboxException {
         message.setUid(nextUid(mailbox));
         message.setModSeq(nextModSeq(mailbox));
     }
 
-    public MessageChangedFlags updateFlags(Mailbox mailbox, 
FlagsUpdateCalculator flagsUpdateCalculator, 
-            Iterator<MailboxMessage> messages) throws MailboxException {
+    MessageChangedFlags updateFlags(Mailbox mailbox, FlagsUpdateCalculator 
flagsUpdateCalculator,
+                                    Iterator<MailboxMessage> messages) throws 
MailboxException {
         ImmutableList.Builder<UpdatedFlags> updatedFlags = 
ImmutableList.builder();
         ImmutableList.Builder<MailboxMessage> changedFlags = 
ImmutableList.builder();
 
@@ -80,15 +83,17 @@ public class MessageUtils {
         return new MessageChangedFlags(updatedFlags.build().iterator(), 
changedFlags.build());
     }
 
+    @VisibleForTesting
     MessageUid nextUid(Mailbox mailbox) throws MailboxException {
         return uidProvider.nextUid(mailbox);
     }
 
+    @VisibleForTesting
     ModSeq nextModSeq(Mailbox mailbox) throws MailboxException {
         return modSeqProvider.nextModSeq(mailbox);
     }
     
-    public static class MessageChangedFlags {
+    static class MessageChangedFlags {
         private final Iterator<UpdatedFlags> updatedFlags;
         private final List<MailboxMessage> changedFlags;
 
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/MessageUtilsTest.java
 
b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/MessageUtilsTest.java
similarity index 96%
rename from 
mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/MessageUtilsTest.java
rename to 
mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/MessageUtilsTest.java
index fbf2a2a..368a2dc 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/MessageUtilsTest.java
+++ 
b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/MessageUtilsTest.java
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mailbox.store.mail;
+package org.apache.james.mailbox.jpa.mail;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.eq;
@@ -33,6 +33,8 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.ModSeq;
 import org.apache.james.mailbox.model.Mailbox;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.store.mail.ModSeqProvider;
+import org.apache.james.mailbox.store.mail.UidProvider;
 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;


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

Reply via email to