james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [14/21] james-project git commit: MAILBOX-342 Simplify TestCassandraMailboxSessionMapperFactory
Date Fri, 06 Jul 2018 09:27:40 GMT
MAILBOX-342 Simplify TestCassandraMailboxSessionMapperFactory


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

Branch: refs/heads/master
Commit: 25b14fc632c3471fe5faf3cb0d5a338cb10ce70e
Parents: d6de402
Author: benwa <btellier@linagora.com>
Authored: Thu Jul 5 15:43:43 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jul 6 16:25:50 2018 +0700

----------------------------------------------------------------------
 ...estCassandraMailboxSessionMapperFactory.java | 54 ++------------------
 .../cassandra/mail/utils/GuiceUtils.java        | 17 ++++--
 2 files changed, 16 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/25b14fc6/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/TestCassandraMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/TestCassandraMailboxSessionMapperFactory.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/TestCassandraMailboxSessionMapperFactory.java
index 61eb0c4..0c59550 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/TestCassandraMailboxSessionMapperFactory.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/TestCassandraMailboxSessionMapperFactory.java
@@ -21,29 +21,8 @@ package org.apache.james.mailbox.cassandra;
 
 import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
 import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration;
-import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.apache.james.blob.cassandra.CassandraBlobId;
-import org.apache.james.blob.cassandra.CassandraBlobsDAO;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
-import org.apache.james.mailbox.cassandra.mail.CassandraACLMapper;
-import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentMessageIdDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentOwnerDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraDeletedMessageDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraFirstUnseenDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMailboxCounterDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMailboxDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMailboxPathDAOImpl;
-import org.apache.james.mailbox.cassandra.mail.CassandraMailboxPathV2DAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMailboxRecentsDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMessageDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdToImapUidDAO;
-import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
-import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
-import org.apache.james.mailbox.cassandra.mail.CassandraUserMailboxRightsDAO;
+import org.apache.james.mailbox.cassandra.mail.utils.GuiceUtils;
 
 import com.datastax.driver.core.Session;
 
@@ -57,35 +36,8 @@ public class TestCassandraMailboxSessionMapperFactory {
     public static CassandraMailboxSessionMapperFactory forTests(Session session, CassandraTypesProvider
typesProvider,
                                                                 CassandraMessageId.Factory
factory, CassandraConfiguration cassandraConfiguration) {
 
-        CassandraUtils utils = new CassandraUtils(cassandraConfiguration);
-        CassandraBlobsDAO cassandraBlobsDAO = new CassandraBlobsDAO(session);
-        CassandraBlobId.Factory blobIdFactory = new CassandraBlobId.Factory();
-
-        return new CassandraMailboxSessionMapperFactory(
-            new CassandraUidProvider(session),
-            new CassandraModSeqProvider(session),
-            session,
-            new CassandraMessageDAO(session, typesProvider, cassandraBlobsDAO, blobIdFactory,
utils, factory),
-            new CassandraMessageIdDAO(session, factory),
-            new CassandraMessageIdToImapUidDAO(session, factory),
-            new CassandraMailboxCounterDAO(session),
-            new CassandraMailboxRecentsDAO(session),
-            new CassandraMailboxDAO(session, typesProvider),
-            new CassandraMailboxPathDAOImpl(session, typesProvider),
-            new CassandraMailboxPathV2DAO(session, CassandraUtils.WITH_DEFAULT_CONFIGURATION),
-            new CassandraFirstUnseenDAO(session),
-            new CassandraApplicableFlagDAO(session),
-            new CassandraAttachmentDAO(session, utils, cassandraConfiguration),
-            new CassandraAttachmentDAOV2(blobIdFactory, session),
-            new CassandraDeletedMessageDAO(session),
-            cassandraBlobsDAO, new CassandraAttachmentMessageIdDAO(session, factory, utils),
-            new CassandraAttachmentOwnerDAO(session, utils),
-            new CassandraACLMapper(session,
-                new CassandraUserMailboxRightsDAO(session, utils),
-                cassandraConfiguration),
-            new CassandraUserMailboxRightsDAO(session, utils),
-            utils,
-            cassandraConfiguration);
+        return GuiceUtils.testInjector(session, typesProvider, factory, cassandraConfiguration)
+            .getInstance(CassandraMailboxSessionMapperFactory.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/25b14fc6/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/GuiceUtils.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/GuiceUtils.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/GuiceUtils.java
index 31dc895..8a1ee7a 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/GuiceUtils.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/GuiceUtils.java
@@ -36,13 +36,22 @@ import com.google.inject.util.Modules;
 
 public class GuiceUtils {
     public static Injector testInjector(CassandraCluster cluster) {
+        Session session = cluster.getConf();
+        CassandraTypesProvider typesProvider = cluster.getTypesProvider();
+        CassandraMessageId.Factory messageIdFactory = new CassandraMessageId.Factory();
+        CassandraConfiguration configuration = CassandraConfiguration.DEFAULT_CONFIGURATION;
+
+        return testInjector(session, typesProvider, messageIdFactory, configuration);
+    }
+
+    public static Injector testInjector(Session session, CassandraTypesProvider typesProvider,
CassandraMessageId.Factory messageIdFactory, CassandraConfiguration configuration) {
         return Guice.createInjector(
             Modules.combine(
-                binder -> binder.bind(MessageId.Factory.class).toInstance(new CassandraMessageId.Factory()),
+                binder -> binder.bind(MessageId.Factory.class).toInstance(messageIdFactory),
                 binder -> binder.bind(BlobId.Factory.class).toInstance(new CassandraBlobId.Factory()),
                 binder -> binder.bind(ObjectStore.class).to(CassandraBlobsDAO.class),
-                binder -> binder.bind(Session.class).toInstance(cluster.getConf()),
-                binder -> binder.bind(CassandraTypesProvider.class).toInstance(cluster.getTypesProvider()),
-                binder -> binder.bind(CassandraConfiguration.class).toInstance(CassandraConfiguration.DEFAULT_CONFIGURATION)));
+                binder -> binder.bind(Session.class).toInstance(session),
+                binder -> binder.bind(CassandraTypesProvider.class).toInstance(typesProvider),
+                binder -> binder.bind(CassandraConfiguration.class).toInstance(configuration)));
     }
 }


---------------------------------------------------------------------
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