james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/2] james-project git commit: JAMES-1818 Remove store imports in test classes
Date Mon, 05 Sep 2016 12:51:30 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 47cfda6cc -> 40644067f


JAMES-1818 Remove store imports in test classes


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

Branch: refs/heads/master
Commit: 40644067fcff28a223a5dccf29fae0871d36c907
Parents: c9b67ae
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Fri Sep 2 11:26:34 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Mon Sep 5 14:49:07 2016 +0200

----------------------------------------------------------------------
 server/protocols/jmap/pom.xml                   |  6 --
 .../FirstUserConnectionFilterThreadTest.java    |  4 +-
 .../jmap/methods/GetMailboxesMethodTest.java    | 24 +++-----
 .../jmap/methods/GetMessagesMethodTest.java     | 42 +++++--------
 .../SetMessagesCreationProcessorTest.java       | 15 +----
 .../james/jmap/model/MailboxFactoryTest.java    | 16 +----
 .../apache/james/jmap/send/MailFactoryTest.java | 10 ++--
 .../jmap/send/PostDequeueDecoratorTest.java     | 62 +++++++-------------
 .../james/jmap/utils/MailboxUtilsTest.java      | 12 +---
 .../utils/SortToComparatorConvertorTest.java    | 34 +++++------
 10 files changed, 76 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml
index 5f0436e..60c4c42 100644
--- a/server/protocols/jmap/pom.xml
+++ b/server/protocols/jmap/pom.xml
@@ -169,12 +169,6 @@
                     <scope>test</scope>
                     <type>test-jar</type>
                 </dependency>
-                 <dependency>
-                    <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-store</artifactId>
-                    <scope>test</scope>
-                    <type>test-jar</type>
-                </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-mailbox-tika</artifactId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
index bde96d6..f7ea5e9 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
@@ -30,6 +30,7 @@ import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
@@ -42,7 +43,6 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MailboxQuery;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
-import org.apache.james.mailbox.store.SimpleMailboxSession;
 import org.apache.james.user.lib.mock.InMemoryUsersRepository;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -63,7 +63,7 @@ public class FirstUserConnectionFilterThreadTest {
     @ThreadedBefore
     public void before() {
         usersRepository = new InMemoryUsersRepository();
-        session = new SimpleMailboxSession(0, "username", null, null, null, ':', null);
+        session = new MockMailboxSession("username");
         mailboxManager = new FakeMailboxManager(session) ;
         sut = new FirstUserConnectionFilter(usersRepository, mailboxManager);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
index be20137..b62fea3 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
@@ -42,17 +42,11 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.MockAuthenticator;
-import org.apache.james.mailbox.store.SimpleMailboxSession;
-import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.assertj.core.groups.Tuple;
 import org.junit.Before;
 import org.junit.Test;
@@ -67,21 +61,17 @@ public class GetMailboxesMethodTest {
     private static final String USERNAME = "username@domain.tld";
     private static final String USERNAME2 = "username2@domain.tld";
 
-    private StoreMailboxManager mailboxManager;
+    private MailboxManager mailboxManager;
     private GetMailboxesMethod getMailboxesMethod;
     private ClientId clientId;
-    private InMemoryMailboxSessionMapperFactory mailboxMapperFactory;
     private MailboxFactory mailboxFactory;
 
     @Before
     public void setup() throws Exception {
         clientId = ClientId.of("#0");
-        mailboxMapperFactory = new InMemoryMailboxSessionMapperFactory();
-        MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
-        GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
-        MessageParser messageParser = new MessageParser();
-        mailboxManager = new StoreMailboxManager(mailboxMapperFactory, new MockAuthenticator(),
aclResolver, groupMembershipResolver, messageParser);
-        mailboxManager.init();
+        InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
+        GroupMembershipResolver groupMembershipResolver = inMemoryIntegrationResources.createGroupMembershipResolver();
+        mailboxManager = inMemoryIntegrationResources.createMailboxManager(groupMembershipResolver);
         mailboxFactory = new MailboxFactory(mailboxManager);
 
         getMailboxesMethod = new GetMailboxesMethod(mailboxManager, mailboxFactory);
@@ -116,7 +106,7 @@ public class GetMailboxesMethodTest {
         
         GetMailboxesRequest getMailboxesRequest = GetMailboxesRequest.builder()
                 .build();
-        MailboxSession session = new SimpleMailboxSession(0, USERNAME, "", null, null, '.',
null);
+        MailboxSession session = new MockMailboxSession(USERNAME);
         
         List<JmapResponse> getMailboxesResponse = testee.process(getMailboxesRequest,
clientId, session).collect(Collectors.toList());
         

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
index 09f06e0..e9b0bbf 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
@@ -20,7 +20,9 @@ package org.apache.james.jmap.methods;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.util.Date;
@@ -42,26 +44,19 @@ import org.apache.james.jmap.model.MessageFactory;
 import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.model.MessagePreviewGenerator;
 import org.apache.james.jmap.model.MessageProperties.MessageProperty;
-import org.apache.james.jmap.utils.HtmlTextExtractor;
-import org.apache.james.jmap.utils.MailboxBasedHtmlTextExtractor;
+import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.MockAuthenticator;
-import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.assertj.core.api.Condition;
 import org.assertj.core.data.MapEntry;
 import org.assertj.core.groups.Tuple;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
@@ -73,8 +68,6 @@ import com.jayway.jsonpath.JsonPath;
 
 public class GetMessagesMethodTest {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(GetMessagesMethodTest.class);
-    
     private static class User implements org.apache.james.mailbox.MailboxSession.User {
         final String username;
         final String password;
@@ -107,7 +100,7 @@ public class GetMessagesMethodTest {
     
     private static final User ROBERT = new User("robert", "secret");
 
-    private StoreMailboxManager mailboxManager;
+    private MailboxManager mailboxManager;
     private GetMessagesMethod testee;
 
     private MailboxSession session;
@@ -115,23 +108,18 @@ public class GetMessagesMethodTest {
     private ClientId clientId;
 
     @Before
-    public void setup() throws MailboxException {
+    public void setup() throws Exception {
         clientId = ClientId.of("#0");
-        InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
-        HtmlTextExtractor htmlTextExtractor = new MailboxBasedHtmlTextExtractor(new DefaultTextExtractor());
-        MessagePreviewGenerator messagePreview = new MessagePreviewGenerator(htmlTextExtractor);
+        MessagePreviewGenerator messagePreview = mock(MessagePreviewGenerator.class);
+        when(messagePreview.forHTMLBody(any())).thenReturn("html preview");
+        when(messagePreview.forTextBody(any())).thenReturn("text preview");
         MessageContentExtractor messageContentExtractor = new MessageContentExtractor();
         MessageFactory messageFactory = new MessageFactory(messagePreview, messageContentExtractor);
-        MockAuthenticator authenticator = new MockAuthenticator();
-        authenticator.addUser(ROBERT.username, ROBERT.password);
-        UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
-        SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
-        MessageParser messageParser = new MessageParser();
-        mailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, authenticator,
aclResolver, groupMembershipResolver, messageParser);
-        mailboxManager.init();
-        
+        InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
+        GroupMembershipResolver groupMembershipResolver = inMemoryIntegrationResources.createGroupMembershipResolver();
+        mailboxManager = inMemoryIntegrationResources.createMailboxManager(groupMembershipResolver);
 
-        session = mailboxManager.login(ROBERT.username, ROBERT.password, LOGGER);
+        session = new MockMailboxSession(ROBERT.username);
         inboxPath = MailboxPath.inbox(session);
         mailboxManager.createMailbox(inboxPath, session);
         testee = new GetMessagesMethod(mailboxManager, messageFactory);

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
index e65a3c6..5a97018 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
@@ -53,8 +53,6 @@ import org.apache.james.jmap.model.mailbox.Role;
 import org.apache.james.jmap.send.MailFactory;
 import org.apache.james.jmap.send.MailMetadata;
 import org.apache.james.jmap.send.MailSpool;
-import org.apache.james.jmap.utils.HtmlTextExtractor;
-import org.apache.james.jmap.utils.MailboxBasedHtmlTextExtractor;
 import org.apache.james.jmap.utils.SystemMailboxesProvider;
 import org.apache.james.mailbox.AttachmentManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -65,9 +63,6 @@ import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.AttachmentId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
-import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.mailet.Mail;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -117,9 +112,9 @@ public class SetMessagesCreationProcessorTest {
 
     @Before
     public void setUp() throws MailboxException {
-        HtmlTextExtractor htmlTextExtractor = new MailboxBasedHtmlTextExtractor(new DefaultTextExtractor());
-        MessagePreviewGenerator messagePreview = new MessagePreviewGenerator(htmlTextExtractor);
+        MessagePreviewGenerator messagePreview = mock(MessagePreviewGenerator.class);
         MessageContentExtractor messageContentExtractor = new MessageContentExtractor();
+        when(messagePreview.forTextBody(any())).thenReturn("text preview");
         messageFactory = new MessageFactory(messagePreview, messageContentExtractor);
         mockedMailSpool = mock(MailSpool.class);
         mockedMailFactory = mock(MailFactory.class);
@@ -153,12 +148,8 @@ public class SetMessagesCreationProcessorTest {
     @Test
     public void processShouldReturnNonEmptyCreatedWhenRequestHasNonEmptyCreate() throws MailboxException
{
         // Given
-        MessageMapper stubMapper = mock(MessageMapper.class);
-        MailboxSessionMapperFactory mockSessionMapperFactory = mock(MailboxSessionMapperFactory.class);
-        when(mockSessionMapperFactory.createMessageMapper(any(MailboxSession.class)))
-                .thenReturn(stubMapper);
-
         sut = new SetMessagesCreationProcessor(mimeMessageConverter, mockedMailSpool, mockedMailFactory,
messageFactory, fakeSystemMailboxesProvider, mockedAttachmentManager);
+
         // When
         SetMessagesResponse result = sut.process(createMessageInOutbox, session);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxFactoryTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxFactoryTest.java
index e404b70..9964921 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxFactoryTest.java
@@ -27,11 +27,9 @@ import org.apache.james.jmap.utils.MailboxUtilsTest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -41,7 +39,6 @@ public class MailboxFactoryTest {
     private static final Logger LOGGER = LoggerFactory.getLogger(MailboxUtilsTest.class);
 
     private MailboxManager mailboxManager;
-    private MailboxMapperFactory mailboxMapperFactory;
     private MailboxSession mailboxSession;
     private String user;
     private MailboxFactory sut;
@@ -50,7 +47,6 @@ public class MailboxFactoryTest {
     public void setup() throws Exception {
         InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
         mailboxManager = inMemoryIntegrationResources.createMailboxManager(inMemoryIntegrationResources.createGroupMembershipResolver());
-        mailboxMapperFactory = new InMemoryMailboxSessionMapperFactory();
         user = "user@domain.org";
         mailboxSession = mailboxManager.login(user, "pass", LOGGER);
         sut = new MailboxFactory(mailboxManager);
@@ -67,9 +63,7 @@ public class MailboxFactoryTest {
     public void mailboxFromMailboxIdShouldReturnPresentWhenExists() throws Exception {
         MailboxPath mailboxPath = new MailboxPath("#private", user, "myBox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(mailboxPath)
-                .getMailboxId();
+        MailboxId mailboxId = mailboxManager.getMailbox(mailboxPath, mailboxSession).getId();
 
         Optional<Mailbox> mailbox = sut.fromMailboxId(mailboxId, mailboxSession);
         assertThat(mailbox).isPresent();
@@ -134,9 +128,7 @@ public class MailboxFactoryTest {
     public void getParentIdFromMailboxPathShouldReturnParentIdWhenChildMailbox() throws Exception
{
         MailboxPath parentMailboxPath = new MailboxPath("#private", user, "inbox");
         mailboxManager.createMailbox(parentMailboxPath, mailboxSession);
-        MailboxId parentId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(parentMailboxPath)
-                .getMailboxId();
+        MailboxId parentId = mailboxManager.getMailbox(parentMailboxPath, mailboxSession).getId();
 
         MailboxPath mailboxPath = new MailboxPath("#private", user, "inbox.mailbox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
@@ -152,9 +144,7 @@ public class MailboxFactoryTest {
 
         MailboxPath parentMailboxPath = new MailboxPath("#private", user, "inbox.children");
         mailboxManager.createMailbox(parentMailboxPath, mailboxSession);
-        MailboxId parentId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(parentMailboxPath)
-                .getMailboxId();
+        MailboxId parentId = mailboxManager.getMailbox(parentMailboxPath, mailboxSession).getId();
 
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
index e0a3099..4ee494d 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
@@ -19,6 +19,9 @@
 package org.apache.james.jmap.send;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.util.Collection;
 import java.util.Date;
@@ -32,12 +35,9 @@ import org.apache.james.jmap.model.MessageFactory;
 import org.apache.james.jmap.model.MessageFactory.MetaDataWithContent;
 import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.model.MessagePreviewGenerator;
-import org.apache.james.jmap.utils.HtmlTextExtractor;
-import org.apache.james.jmap.utils.MailboxBasedHtmlTextExtractor;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.junit.Before;
@@ -73,8 +73,8 @@ public class MailFactoryTest {
                 .mailboxId(InMemoryId.of(3))
                 .messageId(MessageId.of("test|test|2"))
                 .build();
-        HtmlTextExtractor htmlTextExtractor = new MailboxBasedHtmlTextExtractor(new DefaultTextExtractor());
-        MessagePreviewGenerator messagePreview = new MessagePreviewGenerator(htmlTextExtractor);
+        MessagePreviewGenerator messagePreview = mock(MessagePreviewGenerator.class);
+        when(messagePreview.forTextBody(any())).thenReturn("text preview");
         MessageContentExtractor messageContentExtractor = new MessageContentExtractor();
         MessageFactory messageFactory = new MessageFactory(messagePreview, messageContentExtractor);
         jmapMessage = messageFactory.fromMetaDataWithContent(message);

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
index 858b685..4fa8197 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
@@ -25,29 +25,22 @@ import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
 import java.util.Date;
-import java.util.Iterator;
 
 import javax.mail.Flags;
 
 import org.apache.james.jmap.exceptions.MailboxRoleNotFoundException;
 import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.send.exception.MailShouldBeInOutboxException;
+import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.model.FetchGroupImpl;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.store.MockAuthenticator;
-import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
+import org.apache.james.mailbox.model.MessageResultIterator;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
@@ -66,20 +59,16 @@ public class PostDequeueDecoratorTest {
     private static final MailboxPath SENT_MAILBOX_PATH = new MailboxPath(MailboxConstants.USER_NAMESPACE,
USERNAME, SENT);
     private static final String MESSAGE_ID = USERNAME + "|" + OUTBOX_MAILBOX_PATH.getName()
+ "|" + UID;
     
-    private InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory;
-    private StoreMailboxManager mailboxManager;
+    private MailboxManager mailboxManager;
     private MailQueueItem mockedMailQueueItem;
     private Mail mail;
     private PostDequeueDecorator testee;
 
     @Before
     public void init() throws Exception {
-        mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
-        MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
-        GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
-        MessageParser messageParser = new MessageParser();
-        mailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, new MockAuthenticator(),
aclResolver, groupMembershipResolver, messageParser);
-        mailboxManager.init();
+        InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
+        GroupMembershipResolver groupMembershipResolver = inMemoryIntegrationResources.createGroupMembershipResolver();
+        mailboxManager = inMemoryIntegrationResources.createMailboxManager(groupMembershipResolver);
 
         mockedMailQueueItem = mock(MailQueueItem.class);
         mail = new FakeMail();
@@ -135,9 +124,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox sentMailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(SENT_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(sentMailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager sentMailbox = mailboxManager.getMailbox(SENT_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = sentMailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
     
@@ -153,9 +141,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(0);
     }
     
@@ -171,9 +158,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(false);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
     
@@ -187,9 +173,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
     
@@ -204,9 +189,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
     
@@ -221,9 +205,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
     
@@ -239,9 +222,8 @@ public class PostDequeueDecoratorTest {
         
         testee.done(true);
         
-        Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(OUTBOX_MAILBOX_PATH);
-        MessageMapper messageMapper = mailboxSessionMapperFactory.getMessageMapper(mailboxSession);
-        Iterator<MailboxMessage> resultIterator = messageMapper.findInMailbox(mailbox,
MessageRange.one(UID), MessageMapper.FetchType.Full, 1);
+        MessageManager mailbox = mailboxManager.getMailbox(OUTBOX_MAILBOX_PATH, mailboxSession);
+        MessageResultIterator resultIterator = mailbox.getMessages(MessageRange.one(UID),
FetchGroupImpl.FULL_CONTENT, mailboxSession);
         assertThat(resultIterator).hasSize(1);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
index dc85e3e..5ea1428 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
@@ -23,11 +23,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -38,7 +36,6 @@ public class MailboxUtilsTest {
     private static final Logger LOGGER = LoggerFactory.getLogger(MailboxUtilsTest.class);
 
     private MailboxManager mailboxManager;
-    private MailboxMapperFactory mailboxMapperFactory;
     private MailboxSession mailboxSession;
     private String user;
     private MailboxUtils sut;
@@ -47,7 +44,6 @@ public class MailboxUtilsTest {
     public void setup() throws Exception {
         InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
         mailboxManager = inMemoryIntegrationResources.createMailboxManager(inMemoryIntegrationResources.createGroupMembershipResolver());
-        mailboxMapperFactory = new InMemoryMailboxSessionMapperFactory();
         user = "user@domain.org";
         mailboxSession = mailboxManager.login(user, "pass", LOGGER);
         sut = new MailboxUtils(mailboxManager);
@@ -56,9 +52,7 @@ public class MailboxUtilsTest {
     public void hasChildrenShouldReturnFalseWhenNoChild() throws Exception {
         MailboxPath mailboxPath = new MailboxPath("#private", user, "myBox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(mailboxPath)
-                .getMailboxId();
+        MailboxId mailboxId = mailboxManager.getMailbox(mailboxPath, mailboxSession).getId();
 
         assertThat(sut.hasChildren(mailboxId, mailboxSession)).isFalse();
     }
@@ -67,9 +61,7 @@ public class MailboxUtilsTest {
     public void hasChildrenShouldReturnTrueWhenHasAChild() throws Exception {
         MailboxPath parentMailboxPath = new MailboxPath("#private", user, "inbox");
         mailboxManager.createMailbox(parentMailboxPath, mailboxSession);
-        MailboxId parentId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(parentMailboxPath)
-                .getMailboxId();
+        MailboxId parentId = mailboxManager.getMailbox(parentMailboxPath, mailboxSession).getId();
 
         MailboxPath mailboxPath = new MailboxPath("#private", user, "inbox.myBox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/40644067/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
index 22a6304..5290a10 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
@@ -20,21 +20,18 @@
 package org.apache.james.jmap.utils;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.time.LocalDate;
+import java.time.ZonedDateTime;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
-import javax.mail.Flags;
-
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.store.MessageResultImpl;
-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;
 
@@ -42,6 +39,8 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
 public class SortToComparatorConvertorTest {
+    private static final Date DATE_2017 = Date.from(ZonedDateTime.parse("2017-10-09T08:07:06+07:00[Asia/Vientiane]").toInstant());
+    private static final Date DATE_2018 = Date.from(ZonedDateTime.parse("2018-10-09T08:07:06+07:00[Asia/Vientiane]").toInstant());
 
     private MailboxPath mailboxPath;
     private Entry firstMessage;
@@ -50,14 +49,14 @@ public class SortToComparatorConvertorTest {
 
     @Before
     public void setup() throws IOException {
-        LocalDate date = LocalDate.now();
-        SimpleMailboxMessage firstMailboxMessage = new SimpleMailboxMessage(new Date(date.toEpochDay()),
0, 0, null, new Flags(), new PropertyBuilder(), null);
-        mailboxPath = new MailboxPath("#private", "user", "path");
-        firstMailboxMessage.setUid(1);
-        firstMessage = new Entry(mailboxPath, new MessageResultImpl(firstMailboxMessage));
-        SimpleMailboxMessage secondMailboxMessage = new SimpleMailboxMessage(new Date(date.plusDays(1).toEpochDay()),
0, 0, null, new Flags(), new PropertyBuilder(), null);
-        secondMailboxMessage.setUid(2);
-        secondMessage = new Entry(mailboxPath, new MessageResultImpl(secondMailboxMessage));
+        MessageResult firstMessageResult = mock(MessageResult.class);
+        when(firstMessageResult.getInternalDate()).thenReturn(DATE_2017);
+        when(firstMessageResult.getUid()).thenReturn(1L);
+        firstMessage = new Entry(mailboxPath, firstMessageResult);
+        MessageResult secondMessageResult = mock(MessageResult.class);
+        when(secondMessageResult.getInternalDate()).thenReturn(DATE_2018);
+        when(secondMessageResult.getUid()).thenReturn(2L);
+        secondMessage = new Entry(mailboxPath, secondMessageResult);
         messages = Lists.newArrayList(firstMessage, secondMessage);
     }
 
@@ -91,9 +90,10 @@ public class SortToComparatorConvertorTest {
 
     @Test
     public void comparatorForShouldChainComparatorsWhenOnlyMultipleElementInList() throws
IOException {
-        SimpleMailboxMessage thirdMailboxMessage = new SimpleMailboxMessage(secondMessage.getValue().getInternalDate(),
0, 0, null, new Flags(), new PropertyBuilder(), null);
-        thirdMailboxMessage.setUid(3);
-        Entry thirdMessage = new Entry(mailboxPath, new MessageResultImpl(thirdMailboxMessage));
+        MessageResult thirdMessageResult = mock(MessageResult.class);
+        when(thirdMessageResult.getInternalDate()).thenReturn(DATE_2018);
+        when(thirdMessageResult.getUid()).thenReturn(3L);
+        Entry thirdMessage = new Entry(mailboxPath, thirdMessageResult);
         messages.add(thirdMessage);
 
         Comparator<Entry> comparator = SortToComparatorConvertor.comparatorFor(ImmutableList.of("date
asc", "id desc"));


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


Mime
View raw message