james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/8] james-project git commit: JAMES-2413 Allow to use DataProbeImpl in a fluent fashion
Date Wed, 13 Jun 2018 02:49:14 GMT
JAMES-2413 Allow to use DataProbeImpl in a fluent fashion


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

Branch: refs/heads/master
Commit: be9462075d2435cea903c6c57f5c4fda933ca4d1
Parents: adfcf46
Author: benwa <btellier@linagora.com>
Authored: Thu Jun 7 10:51:10 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jun 13 09:42:35 2018 +0700

----------------------------------------------------------------------
 .../james/cli/DataCommandsIntegrationTest.java      |  8 ++++----
 .../CassandraMailRepositoryIntegrationTest.java     |  7 ++++---
 .../test/java/org/apache/james/ESReporterTest.java  |  6 +++---
 .../java/org/apache/james/utils/DataProbeImpl.java  | 15 ++++++++++++---
 .../java/org/apache/james/JPAJamesServerTest.java   |  6 +++---
 .../mailets/crypto/SMIMEDecryptIntegrationTest.java |  6 +++---
 .../transport/mailets/ContactExtractorTest.java     | 16 ++++++++--------
 .../james/transport/mailets/SpamAssassinTest.java   | 10 +++++-----
 .../apache/james/jmap/JMAPAuthenticationTest.java   |  5 +++--
 .../org/apache/james/jmap/ProvisioningTest.java     |  6 +++---
 .../integration/SetVacationResponseTest.java        |  5 +++--
 .../methods/integration/SpamAssassinContract.java   | 11 ++++++-----
 12 files changed, 57 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
index ed5a446..eeddbd0 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
@@ -109,8 +109,8 @@ public class DataCommandsIntegrationTest {
 
     @Test
     public void removeUserShouldWork() throws Exception {
-        dataProbe.addDomain(DOMAIN);
-        dataProbe.addUser(MAIL_ADDRESS, PASSWORD);
+        dataProbe.fluentAddDomain(DOMAIN)
+            .fluentAddUser(MAIL_ADDRESS, PASSWORD);
 
         ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "REMOVEUSER", MAIL_ADDRESS});
 
@@ -119,8 +119,8 @@ public class DataCommandsIntegrationTest {
 
     @Test
     public void listUsersShouldWork() throws Exception {
-        dataProbe.addDomain(DOMAIN);
-        dataProbe.addUser(MAIL_ADDRESS, PASSWORD);
+        dataProbe.fluentAddDomain(DOMAIN)
+            .fluentAddUser(MAIL_ADDRESS, PASSWORD);
 
         ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999",
"listusers"}, outputCapture.getPrintStream());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java
index 3d5db0c..836e27d 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java
@@ -59,14 +59,15 @@ public class CassandraMailRepositoryIntegrationTest {
     }
 
     @After
-    public void tearDown() throws Exception {
+    public void tearDown() {
         server.stop();
     }
 
     @Test
     public void deniedSenderMailShouldBeStoredInCassandraMailRepositoryWhenConfigured() throws
Exception {
-        server.getProbe(DataProbeImpl.class).addDomain("domain.com");
-        server.getProbe(DataProbeImpl.class).addUser("user@domain.com", "secret");
+        server.getProbe(DataProbeImpl.class)
+            .fluentAddDomain("domain.com")
+            .fluentAddUser("user@domain.com", "secret");
 
         smtpMessageSender.connect("127.0.0.1", 1025)
             .sendMessage("denied@other.com", "user@domain.com");

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
index a020a49..148c42c 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
@@ -77,9 +77,9 @@ public class ESReporterTest {
     public void setup() throws Exception {
         server = cassandraJmap.jmapServer();
         server.start();
-        DataProbeImpl serverProbe = server.getProbe(DataProbeImpl.class);
-        serverProbe.addDomain(DOMAIN);
-        serverProbe.addUser(USERNAME, PASSWORD);
+        server.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DOMAIN)
+            .fluentAddUser(USERNAME, PASSWORD);
 
         RestAssured.requestSpecification = new RequestSpecBuilder()
                 .setContentType(ContentType.JSON)

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
index c5cab72..f016129 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
@@ -58,13 +58,18 @@ public class DataProbeImpl implements GuiceProbe, DataProbe {
         usersRepository.addUser(userName, password);
     }
 
+    public DataProbeImpl fluentAddUser(String userName, String password) throws Exception
{
+        addUser(userName, password);
+        return this;
+    }
+
     @Override
     public void removeUser(String username) throws Exception {
         usersRepository.removeUser(username);
     }
 
     @Override
-    public void setPassword(String userName, String password) throws Exception {
+    public void setPassword(String userName, String password) {
         throw new NotImplementedException();
     }
 
@@ -78,6 +83,10 @@ public class DataProbeImpl implements GuiceProbe, DataProbe {
         domainList.addDomain(Domain.of(domain));
     }
 
+    public DataProbeImpl fluentAddDomain(String domain) throws Exception {
+        addDomain(domain);
+        return this;
+    }
 
     @Override
     public boolean containsDomain(String domain) throws Exception {
@@ -107,12 +116,12 @@ public class DataProbeImpl implements GuiceProbe, DataProbe {
             .collect(
                 Guavate.toImmutableMap(
                     entry -> entry.getKey().asString(),
-                    entry -> entry.getValue()));
+                    Map.Entry::getValue));
 
     }
 
     @Override
-    public Mappings listUserDomainMappings(String user, String domain) throws Exception {
+    public Mappings listUserDomainMappings(String user, String domain) {
         throw new NotImplementedException();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
index 114b060..e07727b 100644
--- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -77,9 +77,9 @@ public class JPAJamesServerTest extends AbstractJamesServerTest {
 
     @Test
     public void jpaGuiceServerShouldUpdateQuota() throws Exception {
-        DataProbeImpl dataProbe = server.getProbe(DataProbeImpl.class);
-        dataProbe.addDomain(DOMAIN);
-        dataProbe.addUser(USER, PASSWORD);
+        server.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DOMAIN)
+            .fluentAddUser(USER, PASSWORD);
         server.getProbe(QuotaProbesImpl.class).setGlobalMaxStorage(new SerializableQuotaValue<>(QuotaSize.size(50
* 1024)));
 
         // ~ 12 KB email

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
index 554e0d5..ba91794 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
@@ -84,9 +84,9 @@ public class SMIMEDecryptIntegrationTest {
             .withMailetContainer(mailetContainer)
             .build(temporaryFolder);
 
-        DataProbeImpl serverProbe = jamesServer.getProbe(DataProbeImpl.class);
-        serverProbe.addDomain(DEFAULT_DOMAIN);
-        serverProbe.addUser(FROM, PASSWORD);
+        jamesServer.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DEFAULT_DOMAIN)
+            .fluentAddUser(FROM, PASSWORD);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
index 800a5de..c29535f 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
@@ -101,14 +101,14 @@ public class ContactExtractorTest {
             .build(folder);
 
         DataProbeImpl probe = jamesServer.getProbe(DataProbeImpl.class);
-        probe.addDomain(DEFAULT_DOMAIN);
-        probe.addUser(SENDER, PASSWORD);
-        probe.addUser(TO, PASSWORD);
-        probe.addUser(TO2, PASSWORD);
-        probe.addUser(CC, PASSWORD);
-        probe.addUser(CC2, PASSWORD);
-        probe.addUser(BCC, PASSWORD);
-        probe.addUser(BCC2, PASSWORD);
+        probe.fluentAddDomain(DEFAULT_DOMAIN)
+            .fluentAddUser(SENDER, PASSWORD)
+            .fluentAddUser(TO, PASSWORD)
+            .fluentAddUser(TO2, PASSWORD)
+            .fluentAddUser(CC, PASSWORD)
+            .fluentAddUser(CC2, PASSWORD)
+            .fluentAddUser(BCC, PASSWORD)
+            .fluentAddUser(BCC2, PASSWORD);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
index 274b0e8..3c56362 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
@@ -86,11 +86,11 @@ public class SpamAssassinTest {
             .withMailetContainer(mailets)
             .build(temporaryFolder);
 
-        DataProbeImpl probe = jamesServer.getProbe(DataProbeImpl.class);
-        probe.addDomain(DEFAULT_DOMAIN);
-        probe.addUser(FROM, PASSWORD);
-        probe.addUser(RECIPIENT, PASSWORD);
-        probe.addUser(RECIPIENT2, PASSWORD);
+        jamesServer.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DEFAULT_DOMAIN)
+            .fluentAddUser(FROM, PASSWORD)
+            .fluentAddUser(RECIPIENT, PASSWORD)
+            .fluentAddUser(RECIPIENT2, PASSWORD);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
index 1631477..eae6a4c 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
@@ -72,8 +72,9 @@ public abstract class JMAPAuthenticationTest {
 
         
         String domain = "domain.tld";
-        jmapServer.getProbe(DataProbeImpl.class).addDomain(domain);
-        jmapServer.getProbe(DataProbeImpl.class).addUser(userCredentials.getUsername(), userCredentials.getPassword());
+        jmapServer.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(domain)
+            .fluentAddUser(userCredentials.getUsername(), userCredentials.getPassword());
         
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
index 0d05796..fcb02b5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
@@ -63,9 +63,9 @@ public abstract class ProvisioningTest {
             .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort())
             .build();
 
-        DataProbeImpl serverProbe = jmapServer.getProbe(DataProbeImpl.class);
-        serverProbe.addDomain(DOMAIN);
-        serverProbe.addUser(USER, PASSWORD);
+        jmapServer.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DOMAIN)
+            .fluentAddUser(USER, PASSWORD);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
index 4767e92..f86015c 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
@@ -71,8 +71,9 @@ public abstract class SetVacationResponseTest {
                 .setPort(jmapGuiceProbe.getJmapPort())
                 .build();
 
-        jmapServer.getProbe(DataProbeImpl.class).addDomain(DOMAIN);
-        jmapServer.getProbe(DataProbeImpl.class).addUser(USER, PASSWORD);
+        jmapServer.getProbe(DataProbeImpl.class)
+            .fluentAddDomain(DOMAIN)
+            .fluentAddUser(USER, PASSWORD);
         accessToken = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD);
 
         await();

http://git-wip-us.apache.org/repos/asf/james-project/blob/be946207/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
index 5326b43..358579b 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
@@ -73,11 +73,12 @@ public interface SpamAssassinContract {
                 .build();
         RestAssured.defaultParser = Parser.JSON;
 
-        james.getJmapServer().getProbe(DataProbeImpl.class).addDomain(BOBS_DOMAIN);
-        james.getJmapServer().getProbe(DataProbeImpl.class).addDomain(RECIPIENTS_DOMAIN);
-        james.getJmapServer().getProbe(DataProbeImpl.class).addUser(BOB, BOB_PASSWORD);
-        james.getJmapServer().getProbe(DataProbeImpl.class).addUser(ALICE, ALICE_PASSWORD);
-        james.getJmapServer().getProbe(DataProbeImpl.class).addUser(PAUL, PAUL_PASSWORD);
+        james.getJmapServer().getProbe(DataProbeImpl.class)
+            .fluentAddDomain(BOBS_DOMAIN)
+            .fluentAddDomain(RECIPIENTS_DOMAIN)
+            .fluentAddUser(BOB, BOB_PASSWORD)
+            .fluentAddUser(ALICE, ALICE_PASSWORD)
+            .fluentAddUser(PAUL, PAUL_PASSWORD);
     }
 
     default AccessToken accessTokenFor(GuiceJamesServer james, String user, String password)
{


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