james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [james-project] 08/09: JAMES-2314 WebAdminServer::start should be more fluent
Date Tue, 11 Jun 2019 13:22:38 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 7f97086eb9f9b647faa93daa84e8f2f0492dd351
Author: Benoit Tellier <btellier@linagora.com>
AuthorDate: Thu Jun 6 16:49:09 2019 +0700

    JAMES-2314 WebAdminServer::start should be more fluent
---
 .../routes/CassandraMappingsRoutesTest.java        |  9 ++++----
 .../routes/CassandraMigrationRoutesTest.java       | 11 +++++----
 .../org/apache/james/webadmin/WebAdminServer.java  | 11 +++------
 .../apache/james/webadmin/WebAdminServerTest.java  |  9 ++++----
 .../james/webadmin/routes/ErrorRoutesTest.java     |  6 ++---
 .../webadmin/routes/HealthCheckRoutesTest.java     |  7 ++----
 .../james/webadmin/routes/TasksRoutesTest.java     |  7 ++----
 .../james/webadmin/routes/AliasRoutesTest.java     |  6 ++---
 .../routes/DLPConfigurationRoutesTest.java         |  7 +++---
 .../webadmin/routes/DomainMappingsRoutesTest.java  |  6 ++---
 .../james/webadmin/routes/DomainsRoutesTest.java   |  7 +++---
 .../james/webadmin/routes/ForwardRoutesTest.java   |  6 ++---
 .../james/webadmin/routes/GroupsRoutesTest.java    |  6 ++---
 .../webadmin/routes/SieveQuotaRoutesTest.java      |  6 ++---
 .../webadmin/routes/SieveScriptRoutesTest.java     |  6 ++---
 .../james/webadmin/routes/UsersRoutesTest.java     |  6 ++---
 .../routes/DeletedMessagesVaultRoutesTest.java     |  9 ++++----
 .../DomainQuotaRoutesNoVirtualHostingTest.java     |  6 ++---
 .../routes/EventDeadLettersRoutesTest.java         |  9 ++++----
 .../webadmin/routes/ReindexingRoutesTest.java      | 26 +++++++++++-----------
 .../webadmin/routes/UserMailboxesRoutesTest.java   |  6 ++---
 .../routes/WebAdminQuotaSearchTestSystem.java      | 10 ++++-----
 .../james/webadmin/routes/MailQueueRoutesTest.java | 11 +++++----
 .../routes/MailRepositoriesRoutesTest.java         |  4 ++--
 24 files changed, 81 insertions(+), 116 deletions(-)

diff --git a/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java
b/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java
index b1afff9..0a226e2 100644
--- a/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-cassandra-data/src/test/java/org/apache/james/webadmin/routes/CassandraMappingsRoutesTest.java
@@ -79,11 +79,10 @@ class CassandraMappingsRoutesTest {
         JsonTransformer jsonTransformer = new JsonTransformer();
         taskManager = new MemoryTaskManager();
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new CassandraMappingsRoutes(cassandraMappingsService, taskManager, jsonTransformer),
-            new TasksRoutes(taskManager, jsonTransformer));
-
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new CassandraMappingsRoutes(cassandraMappingsService, taskManager, jsonTransformer),
+                new TasksRoutes(taskManager, jsonTransformer))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(CassandraMappingsRoutes.ROOT_PATH)
diff --git a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
index 38e8b50..4879748 100644
--- a/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-cassandra/src/test/java/org/apache/james/webadmin/routes/CassandraMigrationRoutesTest.java
@@ -82,12 +82,11 @@ public class CassandraMigrationRoutesTest {
         taskManager = new MemoryTaskManager();
         JsonTransformer jsonTransformer = new JsonTransformer();
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new CassandraMigrationRoutes(new CassandraMigrationService(schemaVersionDAO,
allMigrationClazz, LATEST_VERSION),
-                taskManager, jsonTransformer),
-            new TasksRoutes(taskManager, jsonTransformer));
-
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new CassandraMigrationRoutes(new CassandraMigrationService(schemaVersionDAO,
allMigrationClazz, LATEST_VERSION),
+                    taskManager, jsonTransformer),
+                new TasksRoutes(taskManager, jsonTransformer))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(CassandraMigrationRoutes.VERSION_BASE)
diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
index 9474e10..5929968 100644
--- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
+++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/WebAdminServer.java
@@ -47,8 +47,6 @@ import org.apache.james.webadmin.utils.JsonExtractException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 import spark.Service;
 
 public class WebAdminServer implements Startable {
@@ -62,9 +60,7 @@ public class WebAdminServer implements Startable {
     private final Service service;
     private final AuthenticationFilter authenticationFilter;
     private final MetricFactory metricFactory;
-    private Port port;
 
-    // Spark do not allow to retrieve allocated port when using a random port. Thus we generate
the port.
     @Inject
     protected WebAdminServer(WebAdminConfiguration configuration, Set<Routes> routesList,
Set<PublicRoutes> publicRoutes, AuthenticationFilter authenticationFilter,
                            MetricFactory metricFactory) {
@@ -76,7 +72,7 @@ public class WebAdminServer implements Startable {
         this.service = Service.ignite();
     }
 
-    public void start() {
+    public WebAdminServer start() {
         if (configuration.isEnabled()) {
             service.port(configuration.getPort().get().getValue());
             configureExceptionHanding();
@@ -92,9 +88,9 @@ public class WebAdminServer implements Startable {
             });
             publicRoutes.forEach(routes -> routes.define(service));
             service.awaitInitialization();
-            port = new Port(service.port());
             LOGGER.info("Web admin server started");
         }
+        return this;
     }
 
     private void configureMDC() {
@@ -173,7 +169,6 @@ public class WebAdminServer implements Startable {
     }
 
     public Port getPort() {
-        Preconditions.checkState(port != null, "WebAdminServer should be configured.");
-        return port;
+        return new Port(service.port());
     }
 }
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminServerTest.java
b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminServerTest.java
index 523b0bf..26ba38b 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminServerTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminServerTest.java
@@ -28,16 +28,15 @@ import org.junit.Test;
 public class WebAdminServerTest {
 
     @Test
-    public void getPortShouldThrowWhenNotConfigured() throws Exception {
+    public void getPortShouldThrowWhenNotConfigured() {
         WebAdminServer server = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory());
-        assertThatThrownBy(() -> server.getPort())
+        assertThatThrownBy(server::getPort)
             .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    public void getPortShouldReturnPortWhenConfigured() throws Exception {
-        WebAdminServer server = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory());
-        server.start();
+    public void getPortShouldReturnPortWhenConfigured() {
+        WebAdminServer server = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory()).start();
 
         Port port = server.getPort();
 
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/ErrorRoutesTest.java
b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/ErrorRoutesTest.java
index d5e8916..b0d6d16 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/ErrorRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/ErrorRoutesTest.java
@@ -48,10 +48,8 @@ public class ErrorRoutesTest {
 
     @Before
     public void setUp() throws Exception {
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-                new NoopMetricFactory(),
-                new ErrorRoutes());
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new NoopMetricFactory(), new
ErrorRoutes())
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
                 .setBasePath(ErrorRoutes.BASE_URL)
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/HealthCheckRoutesTest.java
b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/HealthCheckRoutesTest.java
index 1082494..1f6b737 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/HealthCheckRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/HealthCheckRoutesTest.java
@@ -77,11 +77,8 @@ public class HealthCheckRoutesTest {
     @Before
     public void setUp() throws Exception {
         healthChecks = new HashSet<>();
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new HealthCheckRoutes(healthChecks, new JsonTransformer()));
-
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), new
HealthCheckRoutes(healthChecks, new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(HealthCheckRoutes.HEALTHCHECK)
diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
index ac290bc..2f0ece7 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
@@ -55,11 +55,8 @@ class TasksRoutesTest {
     void setUp() {
         taskManager = new MemoryTaskManager();
 
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new TasksRoutes(taskManager, new JsonTransformer()));
-
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), new
TasksRoutes(taskManager, new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(TasksRoutes.BASE)
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
index e511fb3..a0d6d66 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
@@ -82,10 +82,8 @@ class AliasRoutesTest {
     private WebAdminServer webAdminServer;
 
     private void createServer(AliasRoutes aliasRoutes) {
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            aliasRoutes);
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), aliasRoutes)
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath("address/aliases")
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
index 2ddb946..5fb19ca 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
@@ -67,10 +67,9 @@ class DLPConfigurationRoutesTest {
     private EventSourcingDLPConfigurationStore dlpStore;
 
     private void createServer(DLPConfigurationStore dlpConfigurationStore, DomainList domainList)
{
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new DLPConfigurationRoutes(dlpConfigurationStore, domainList, new JsonTransformer()));
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(),
+                new DLPConfigurationRoutes(dlpConfigurationStore, domainList, new JsonTransformer()))
+            .start();
 
         requestSpecification = buildRequestSpecification(webAdminServer);
     }
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainMappingsRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainMappingsRoutesTest.java
index ff19744..c6ca75e 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainMappingsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainMappingsRoutesTest.java
@@ -76,10 +76,8 @@ class DomainMappingsRoutesTest {
     private DomainList domainList;
 
     private void createServer(DomainMappingsRoutes domainMappingsRoutes) {
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            domainMappingsRoutes);
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), domainMappingsRoutes)
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(DOMAIN_MAPPINGS)
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index dbb2857..b103450 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -67,10 +67,9 @@ class DomainsRoutesTest {
 
     private void createServer(DomainList domainList) {
         DomainAliasService domainAliasService = new DomainAliasService(new MemoryRecipientRewriteTable(),
domainList);
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new DomainsRoutes(domainList, domainAliasService, new JsonTransformer()));
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(),
+                new DomainsRoutes(domainList, domainAliasService, new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(DomainsRoutes.DOMAINS)
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
index 70c2ba5..0cf385e 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
@@ -81,10 +81,8 @@ class ForwardRoutesTest {
     private WebAdminServer webAdminServer;
 
     private void createServer(ForwardRoutes forwardRoutes) {
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            forwardRoutes);
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), forwardRoutes)
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath("address/forwards")
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
index 510112e..8b0d907 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
@@ -79,10 +79,8 @@ class GroupsRoutesTest {
     private WebAdminServer webAdminServer;
 
     private void createServer(GroupsRoutes groupsRoutes) {
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            groupsRoutes);
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), groupsRoutes)
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath("address/groups")
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
index 53fe916..a9d6498 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveQuotaRoutesTest.java
@@ -48,10 +48,8 @@ class SieveQuotaRoutesTest {
     @BeforeEach
     void setUp() {
         sieveRepository = new InMemorySieveQuotaRepository();
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-                new DefaultMetricFactory(),
-                new SieveQuotaRoutes(sieveRepository, new JsonTransformer()));
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), new
SieveQuotaRoutes(sieveRepository, new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .build();
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveScriptRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveScriptRoutesTest.java
index a8f396d..cd506ba 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveScriptRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveScriptRoutesTest.java
@@ -87,10 +87,8 @@ class SieveScriptRoutesTest {
         URL sieveResource = ClassLoader.getSystemResource("sieve/my_sieve");
         sieveContent = IOUtils.toString(sieveResource, StandardCharsets.UTF_8);
 
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new SieveScriptRoutes(sieveRepository, usersRepository));
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(), new
SieveScriptRoutes(sieveRepository, usersRepository))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils
             .buildRequestSpecification(webAdminServer)
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
index dbe92e9..4406772 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UsersRoutesTest.java
@@ -61,9 +61,9 @@ class UsersRoutesTest {
 
     private void createServer(UsersRepository usersRepository) {
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new UserRoutes(new UserService(usersRepository), new JsonTransformer()));
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new UserRoutes(new UserService(usersRepository), new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(UserRoutes.USERS)
diff --git a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java
b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java
index b471d34..dc335c9 100644
--- a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java
@@ -183,11 +183,10 @@ class DeletedMessagesVaultRoutesTest {
         usersRepository = createUsersRepository();
         MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new TasksRoutes(taskManager, jsonTransformer),
-            new DeletedMessagesVaultRoutes(vault, vaultRestore, exportService, jsonTransformer,
taskManager, queryTranslator, usersRepository, messageIdFactory));
-
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new TasksRoutes(taskManager, jsonTransformer),
+                new DeletedMessagesVaultRoutes(vault, vaultRestore, exportService, jsonTransformer,
taskManager, queryTranslator, usersRepository, messageIdFactory))
+            .start();
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(DeletedMessagesVaultRoutes.ROOT_PATH)
             .log(LogDetail.METHOD)
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesNoVirtualHostingTest.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesNoVirtualHostingTest.java
index 576c8fc..f3d859b 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesNoVirtualHostingTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/DomainQuotaRoutesNoVirtualHostingTest.java
@@ -60,10 +60,8 @@ class DomainQuotaRoutesNoVirtualHostingTest {
         QuotaModule quotaModule = new QuotaModule();
         MemoryUsersRepository usersRepository = MemoryUsersRepository.withoutVirtualHosting();
         DomainQuotaRoutes domainQuotaRoutes = new DomainQuotaRoutes(memoryDomainList, domainQuotaService,
usersRepository, new JsonTransformer(quotaModule), ImmutableSet.of(quotaModule));
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new NoopMetricFactory(),
-            domainQuotaRoutes);
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new NoopMetricFactory(), domainQuotaRoutes)
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .build();
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java
index 0ed07fd..28986a6 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/EventDeadLettersRoutesTest.java
@@ -122,11 +122,10 @@ class EventDeadLettersRoutesTest {
         EventDeadLettersService service = new EventDeadLettersService(redeliverService, deadLetters);
 
         taskManager = new MemoryTaskManager();
-        webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new EventDeadLettersRoutes(service, eventSerializer, taskManager, jsonTransformer),
-            new TasksRoutes(taskManager, jsonTransformer));
-        webAdminServer.start();
+        webAdminServer = WebAdminUtils.createWebAdminServer(new DefaultMetricFactory(),
+                new EventDeadLettersRoutes(service, eventSerializer, taskManager, jsonTransformer),
+                new TasksRoutes(taskManager, jsonTransformer))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer).build();
         RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
index 95faeaf..00a48fc 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
@@ -93,19 +93,19 @@ class ReindexingRoutesTest {
         JsonTransformer jsonTransformer = new JsonTransformer();
 
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new TasksRoutes(taskManager, jsonTransformer),
-            new ReindexingRoutes(
-                taskManager,
-                new PreviousReIndexingService(taskManager),
-                mailboxIdFactory,
-                reIndexer,
-                jsonTransformer),
-            new MessageIdReindexingRoutes(taskManager,
-                new InMemoryMessageId.Factory(),
-                new MessageIdReIndexerImpl(mailboxManager, mailboxManager.getMapperFactory(),
searchIndex),
-                jsonTransformer));
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new TasksRoutes(taskManager, jsonTransformer),
+                new ReindexingRoutes(
+                    taskManager,
+                    new PreviousReIndexingService(taskManager),
+                    mailboxIdFactory,
+                    reIndexer,
+                    jsonTransformer),
+                new MessageIdReindexingRoutes(taskManager,
+                    new InMemoryMessageId.Factory(),
+                    new MessageIdReIndexerImpl(mailboxManager, mailboxManager.getMapperFactory(),
searchIndex),
+                    jsonTransformer))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer).build();
         RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
index 6f93d5f..7f03a8e 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
@@ -74,9 +74,9 @@ class UserMailboxesRoutesTest {
         when(usersRepository.contains(USERNAME)).thenReturn(true);
 
         webAdminServer = WebAdminUtils.createWebAdminServer(
-            new DefaultMetricFactory(),
-            new UserMailboxesRoutes(new UserMailboxesService(mailboxManager, usersRepository),
new JsonTransformer()));
-        webAdminServer.start();
+                new DefaultMetricFactory(),
+                new UserMailboxesRoutes(new UserMailboxesService(mailboxManager, usersRepository),
new JsonTransformer()))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(USERS_BASE + SEPARATOR + USERNAME + SEPARATOR + UserMailboxesRoutes.MAILBOXES)
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
index cee2514..032f501 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
@@ -62,11 +62,11 @@ public class WebAdminQuotaSearchTestSystem {
             jsonTransformer);
 
         this.webAdminServer = WebAdminUtils.createWebAdminServer(
-            new NoopMetricFactory(),
-            userQuotaRoutes,
-            domainQuotaRoutes,
-            globalQuotaRoutes);
-        this.webAdminServer.start();
+                new NoopMetricFactory(),
+                userQuotaRoutes,
+                domainQuotaRoutes,
+                globalQuotaRoutes)
+            .start();
 
         this.requestSpecBuilder = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .build();
diff --git a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java
b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java
index da87397..e7e3800 100644
--- a/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailqueue/src/test/java/org/apache/james/webadmin/routes/MailQueueRoutesTest.java
@@ -89,12 +89,11 @@ class MailQueueRoutesTest {
         TaskManager taskManager = new MemoryTaskManager();
         JsonTransformer jsonTransformer = new JsonTransformer();
 
-        WebAdminServer server = WebAdminUtils.createWebAdminServer(
-            new NoopMetricFactory(),
-            new MailQueueRoutes(mailQueueFactory, jsonTransformer, taskManager),
-            new TasksRoutes(taskManager, jsonTransformer));
-        server.start();
-        return server;
+        return WebAdminUtils.createWebAdminServer(
+                new NoopMetricFactory(),
+                new MailQueueRoutes(mailQueueFactory, jsonTransformer, taskManager),
+                new TasksRoutes(taskManager, jsonTransformer))
+            .start();
     }
 
     RequestSpecification buildRequestSpecification(WebAdminServer server) {
diff --git a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
index 01e172c..3823453 100644
--- a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
@@ -126,8 +126,8 @@ public class MailRepositoriesRoutesTest {
                 new NoopMetricFactory(),
                 new MailRepositoriesRoutes(repositoryStoreService,
                     jsonTransformer, reprocessingService, taskManager),
-            new TasksRoutes(taskManager, jsonTransformer));
-        webAdminServer.start();
+            new TasksRoutes(taskManager, jsonTransformer))
+            .start();
 
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES)


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