You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/05/30 02:24:20 UTC

[09/14] james-project git commit: JAMES-2404 Add more tests for Quota Search REST API

JAMES-2404 Add more tests for Quota Search REST API


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

Branch: refs/heads/master
Commit: 350bc6c5a72183e4465b0563a89419ed61afccee
Parents: 110c034
Author: duc <tr...@gmail.com>
Authored: Mon May 28 17:40:14 2018 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Tue May 29 15:32:53 2018 +0200

----------------------------------------------------------------------
 .../protocols/webadmin/webadmin-mailbox/pom.xml |   5 +
 .../routes/RestQuotaSearchTestSystem.java       |  75 ---
 .../routes/ScanningQuotaSearchExtension.java    |  87 ++++
 .../ScanningRestQuotaSearchExtension.java       |  87 ----
 .../webadmin/routes/UserQuotaRoutesTest.java    | 486 ++++++++++++++-----
 .../routes/WebAdminQuotaSearchTestSystem.java   |  75 +++
 6 files changed, 528 insertions(+), 287 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/pom.xml b/server/protocols/webadmin/webadmin-mailbox/pom.xml
index ae32a95..93cfd57 100644
--- a/server/protocols/webadmin/webadmin-mailbox/pom.xml
+++ b/server/protocols/webadmin/webadmin-mailbox/pom.xml
@@ -138,6 +138,11 @@
             <artifactId>javax.inject</artifactId>
         </dependency>
         <dependency>
+            <groupId>net.javacrumbs.json-unit</groupId>
+            <artifactId>json-unit-fluent</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/RestQuotaSearchTestSystem.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/RestQuotaSearchTestSystem.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/RestQuotaSearchTestSystem.java
deleted file mode 100644
index fb6001e..0000000
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/RestQuotaSearchTestSystem.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.webadmin.routes;
-
-import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
-
-import org.apache.james.metrics.api.NoopMetricFactory;
-import org.apache.james.quota.search.QuotaSearchTestSystem;
-import org.apache.james.webadmin.WebAdminServer;
-import org.apache.james.webadmin.WebAdminUtils;
-import org.apache.james.webadmin.jackson.QuotaModule;
-import org.apache.james.webadmin.service.UserQuotaService;
-import org.apache.james.webadmin.utils.JsonTransformer;
-
-import com.google.common.collect.ImmutableSet;
-import com.jayway.restassured.specification.RequestSpecification;
-
-public class RestQuotaSearchTestSystem {
-    private final QuotaSearchTestSystem quotaSearchTestSystem;
-    private final WebAdminServer webAdminServer;
-    private final RequestSpecification requestSpecBuilder;
-
-    public RestQuotaSearchTestSystem(QuotaSearchTestSystem quotaSearchTestSystem) throws Exception {
-        this.quotaSearchTestSystem = quotaSearchTestSystem;
-
-        UserQuotaService userQuotaService = new UserQuotaService(quotaSearchTestSystem.getMaxQuotaManager(),
-            quotaSearchTestSystem.getQuotaManager(),
-            quotaSearchTestSystem.getQuotaRootResolver(),
-            quotaSearchTestSystem.getQuotaSearcher());
-
-        QuotaModule quotaModule = new QuotaModule();
-        JsonTransformer jsonTransformer = new JsonTransformer(quotaModule);
-        UserQuotaRoutes userQuotaRoutes = new UserQuotaRoutes(quotaSearchTestSystem.getUsersRepository(),
-            userQuotaService, jsonTransformer,
-            ImmutableSet.of(quotaModule));
-
-        this.webAdminServer = WebAdminUtils.createWebAdminServer(
-            new NoopMetricFactory(),
-            userQuotaRoutes);
-        this.webAdminServer.configure(NO_CONFIGURATION);
-        this.webAdminServer.await();
-
-        this.requestSpecBuilder = WebAdminUtils.buildRequestSpecification(webAdminServer)
-            .build();
-    }
-
-    public QuotaSearchTestSystem getQuotaSearchTestSystem() {
-        return quotaSearchTestSystem;
-    }
-
-    public WebAdminServer getWebAdminServer() {
-        return webAdminServer;
-    }
-
-    public RequestSpecification getRequestSpecification() {
-        return requestSpecBuilder;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningQuotaSearchExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningQuotaSearchExtension.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningQuotaSearchExtension.java
new file mode 100644
index 0000000..1907a23
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningQuotaSearchExtension.java
@@ -0,0 +1,87 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static org.mockito.Mockito.mock;
+
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.domainlist.memory.MemoryDomainList;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.quota.search.QuotaSearchTestSystem;
+import org.apache.james.quota.search.scanning.ClauseConverter;
+import org.apache.james.quota.search.scanning.ScanningQuotaSearcher;
+import org.apache.james.user.memory.MemoryUsersRepository;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class ScanningQuotaSearchExtension implements ParameterResolver, BeforeEachCallback, AfterEachCallback {
+    private static final Runnable NO_AWAIT = () -> {};
+
+    private WebAdminQuotaSearchTestSystem restQuotaSearchTestSystem;
+
+    @Override
+    public void beforeEach(ExtensionContext context) {
+        try {
+            InMemoryIntegrationResources.Resources resources = new InMemoryIntegrationResources().createResources(new SimpleGroupMembershipResolver());
+
+            MemoryUsersRepository usersRepository = MemoryUsersRepository.withVirtualHosting();
+
+            DNSService dnsService = mock(DNSService.class);
+            MemoryDomainList domainList = new MemoryDomainList(dnsService);
+            usersRepository.setDomainList(domainList);
+
+            QuotaSearchTestSystem quotaSearchTestSystem = new QuotaSearchTestSystem(
+                resources.getMaxQuotaManager(),
+                resources.getMailboxManager(),
+                resources.getQuotaManager(),
+                resources.getQuotaRootResolver(),
+                new ScanningQuotaSearcher(usersRepository,
+                    new ClauseConverter(resources.getQuotaRootResolver(), resources.getQuotaManager())),
+                usersRepository,
+                domainList,
+                resources.getCurrentQuotaManager(),
+                NO_AWAIT);
+
+            restQuotaSearchTestSystem = new WebAdminQuotaSearchTestSystem(quotaSearchTestSystem);
+        } catch (Exception e) {
+            throw new ParameterResolutionException("Error while resolving parameter", e);
+        }
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context) {
+        restQuotaSearchTestSystem.getWebAdminServer().destroy();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType() == WebAdminQuotaSearchTestSystem.class);
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+        return restQuotaSearchTestSystem;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningRestQuotaSearchExtension.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningRestQuotaSearchExtension.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningRestQuotaSearchExtension.java
deleted file mode 100644
index d7cfcaa..0000000
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ScanningRestQuotaSearchExtension.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.webadmin.routes;
-
-import static org.mockito.Mockito.mock;
-
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.domainlist.memory.MemoryDomainList;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
-import org.apache.james.quota.search.QuotaSearchTestSystem;
-import org.apache.james.quota.search.scanning.ClauseConverter;
-import org.apache.james.quota.search.scanning.ScanningQuotaSearcher;
-import org.apache.james.user.memory.MemoryUsersRepository;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-
-public class ScanningRestQuotaSearchExtension implements ParameterResolver, BeforeEachCallback, AfterEachCallback {
-    private static final Runnable NO_AWAIT = () -> {};
-
-    private RestQuotaSearchTestSystem restQuotaSearchTestSystem;
-
-    @Override
-    public void afterEach(ExtensionContext context) {
-        restQuotaSearchTestSystem.getWebAdminServer().destroy();
-    }
-
-    @Override
-    public void beforeEach(ExtensionContext context) {
-        try {
-            InMemoryIntegrationResources.Resources resources = new InMemoryIntegrationResources().createResources(new SimpleGroupMembershipResolver());
-
-            MemoryUsersRepository usersRepository = MemoryUsersRepository.withVirtualHosting();
-
-            DNSService dnsService = mock(DNSService.class);
-            MemoryDomainList domainList = new MemoryDomainList(dnsService);
-            usersRepository.setDomainList(domainList);
-
-            QuotaSearchTestSystem quotaSearchTestSystem = new QuotaSearchTestSystem(
-                resources.getMaxQuotaManager(),
-                resources.getMailboxManager(),
-                resources.getQuotaManager(),
-                resources.getQuotaRootResolver(),
-                new ScanningQuotaSearcher(usersRepository,
-                    new ClauseConverter(resources.getQuotaRootResolver(), resources.getQuotaManager())),
-                usersRepository,
-                domainList,
-                resources.getCurrentQuotaManager(),
-                NO_AWAIT);
-
-            restQuotaSearchTestSystem = new RestQuotaSearchTestSystem(quotaSearchTestSystem);
-        } catch (Exception e) {
-            throw new ParameterResolutionException("Error while resolving parameter", e);
-        }
-    }
-
-    @Override
-    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return (parameterContext.getParameter().getType() == RestQuotaSearchTestSystem.class);
-    }
-
-    @Override
-    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
-        return restQuotaSearchTestSystem;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
index b4c4595..694cea4 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
@@ -21,8 +21,13 @@ package org.apache.james.webadmin.routes;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.when;
+import static com.jayway.restassured.RestAssured.with;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
 
 import java.io.ByteArrayInputStream;
 import java.nio.charset.StandardCharsets;
@@ -31,7 +36,6 @@ import java.util.Map;
 import org.apache.james.core.Domain;
 import org.apache.james.core.User;
 import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
@@ -44,7 +48,6 @@ import org.apache.james.mailbox.quota.QuotaSize;
 import org.apache.james.mailbox.quota.UserQuotaRootResolver;
 import org.apache.james.quota.search.QuotaSearchTestSystem;
 import org.apache.james.user.api.UsersRepository;
-import org.apache.james.user.api.UsersRepositoryException;
 import org.assertj.core.api.SoftAssertions;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.jupiter.api.BeforeEach;
@@ -67,35 +70,33 @@ class UserQuotaRoutesTest {
     private static final User ESCAPED_BOB = User.fromUsername("bob%40" + PERDU_COM);
     private static final User JOE = User.fromUsername("joe@" + PERDU_COM);
     private static final User JACK = User.fromUsername("jack@" + PERDU_COM);
-    private static final User THE_GUY_WITH_STRANGE_DOMAIN = User.fromUsername("guy@" + STRANGE_ORG);
+    private static final User GUY_WITH_STRANGE_DOMAIN = User.fromUsername("guy@" + STRANGE_ORG);
     private static final String PASSWORD = "secret";
     private static final String COUNT = "count";
     private static final String SIZE = "size";
 
-    interface SetUp {
-        @BeforeEach
-        default void setUp(RestQuotaSearchTestSystem testSystem) throws Exception {
-            DomainList domainList = testSystem.getQuotaSearchTestSystem().getDomainList();
-            domainList.addDomain(Domain.of(PERDU_COM));
-            domainList.addDomain(Domain.of(STRANGE_ORG));
+    @BeforeEach
+    public void setUp(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
+        DomainList domainList = testSystem.getQuotaSearchTestSystem().getDomainList();
+        domainList.addDomain(Domain.of(PERDU_COM));
+        domainList.addDomain(Domain.of(STRANGE_ORG));
 
-            UsersRepository usersRepository = testSystem.getQuotaSearchTestSystem().getUsersRepository();
-            usersRepository.addUser(BOB.asString(), PASSWORD);
-            usersRepository.addUser(JACK.asString(), PASSWORD);
-            usersRepository.addUser(THE_GUY_WITH_STRANGE_DOMAIN.asString(), PASSWORD);
+        UsersRepository usersRepository = testSystem.getQuotaSearchTestSystem().getUsersRepository();
+        usersRepository.addUser(BOB.asString(), PASSWORD);
+        usersRepository.addUser(JACK.asString(), PASSWORD);
+        usersRepository.addUser(GUY_WITH_STRANGE_DOMAIN.asString(), PASSWORD);
 
-            RestAssured.requestSpecification = testSystem.getRequestSpecification();
-            RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
-        }
+        RestAssured.requestSpecification = testSystem.getRequestSpecification();
+        RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
     }
 
     interface GetUsersQuotaRouteContract {
 
         @Test
-        default void getUsersQuotaShouldReturnAllUsersWhenNoParameters(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldReturnAllUsersWhenNoParameters(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(50));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(50));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(50));
 
             testSystem.getQuotaSearchTestSystem().await();
 
@@ -107,19 +108,20 @@ class UserQuotaRoutesTest {
                 .body("username", containsInAnyOrder(
                     BOB.asString(),
                     JACK.asString(),
-                    THE_GUY_WITH_STRANGE_DOMAIN.asString()));
+                    GUY_WITH_STRANGE_DOMAIN.asString()));
         }
 
         @Test
-        default void getUsersQuotaShouldFilterOnDomain(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldFilterOnDomain(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(50));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(50));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(50));
 
             testSystem.getQuotaSearchTestSystem().await();
 
             given()
                 .param("domain", PERDU_COM)
+            .when()
                 .get("/quota/users")
             .then()
                 .statusCode(HttpStatus.OK_200)
@@ -130,78 +132,82 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        default void getUsersQuotaShouldLimitValues(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldLimitValues(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(50));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(50));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(50));
 
             testSystem.getQuotaSearchTestSystem().await();
 
             given()
                 .param("limit", 2)
+            .when()
                 .get("/quota/users")
             .then()
                 .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .body("username", containsInAnyOrder(
                     BOB.asString(),
-                    THE_GUY_WITH_STRANGE_DOMAIN.asString()));
+                    GUY_WITH_STRANGE_DOMAIN.asString()));
         }
 
         @Test
-        default void getUsersQuotaShouldAcceptOffset(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldAcceptOffset(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(50));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(50));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(50));
 
             testSystem.getQuotaSearchTestSystem().await();
 
             given()
                 .param("offset", 1)
+            .when()
                 .get("/quota/users")
             .then()
                 .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .body("username", containsInAnyOrder(
                     JACK.asString(),
-                    THE_GUY_WITH_STRANGE_DOMAIN.asString()));
+                    GUY_WITH_STRANGE_DOMAIN.asString()));
         }
 
         @Test
-        default void getUsersQuotaShouldFilterOnMinOccupationRatio(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldFilterOnMinOccupationRatio(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
 
             maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(100));
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(49));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(51));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(51));
 
             testSystem.getQuotaSearchTestSystem().await();
 
             given()
                 .param("minOccupationRatio", 0.5)
+            .when()
                 .get("/quota/users")
             .then()
                 .statusCode(HttpStatus.OK_200)
                 .contentType(ContentType.JSON)
                 .body("username", containsInAnyOrder(
                     JACK.asString(),
-                    THE_GUY_WITH_STRANGE_DOMAIN.asString()));
+                    GUY_WITH_STRANGE_DOMAIN.asString()));
         }
 
         @Test
-        default void getUsersQuotaShouldFilterOnMaxOccupationRatio(RestQuotaSearchTestSystem testSystem) throws Exception {
+        default void getUsersQuotaShouldFilterOnMaxOccupationRatio(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
 
             maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(100));
             appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(49));
             appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
-            appendMessage(testSystem.getQuotaSearchTestSystem(), THE_GUY_WITH_STRANGE_DOMAIN, withSize(51));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(51));
 
             testSystem.getQuotaSearchTestSystem().await();
 
             given()
                 .param("maxOccupationRatio", 0.5)
+            .when()
                 .get("/quota/users")
             .then()
                 .statusCode(HttpStatus.OK_200)
@@ -211,7 +217,223 @@ class UserQuotaRoutesTest {
                     BOB.asString()));
         }
 
-        default void appendMessage(QuotaSearchTestSystem testSystem, User user, MessageManager.AppendCommand appendCommand) throws MailboxException, UsersRepositoryException, DomainListException {
+        @Test
+        default void getUsersQuotaShouldOrderByUsername(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
+            MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
+
+            maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(100));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(51));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(50));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(49));
+
+            testSystem.getQuotaSearchTestSystem().await();
+
+            given()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.OK_200)
+                .contentType(ContentType.JSON)
+                .body("username", contains(
+                    BOB.asString(),
+                    GUY_WITH_STRANGE_DOMAIN.asString(),
+                    JACK.asString()));
+        }
+
+        @Test
+        default void minOccupationRatioShouldNotBeNegative() {
+            given()
+                .param("minOccupationRatio", -0.5)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("minOccupationRatio can not be negative"));
+        }
+
+        @Test
+        default void minOccupationRatioShouldAcceptZero() {
+            given()
+                .param("minOccupationRatio", 0)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.OK_200);
+        }
+
+        @Test
+        default void minOccupationRatioShouldNotBeString() {
+            given()
+                .param("minOccupationRatio", "invalid")
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("Can not parse minOccupationRatio"))
+                .body("details", equalTo("For input string: \"invalid\""));
+        }
+
+        @Test
+        default void maxOccupationRatioShouldNotBeNegative() {
+            given()
+                .param("maxOccupationRatio", -0.5)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("maxOccupationRatio can not be negative"));
+        }
+
+        @Test
+        default void maxOccupationRatioShouldAcceptZero() {
+            given()
+                .param("maxOccupationRatio", 0)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.OK_200);
+        }
+
+        @Test
+        default void maxOccupationRatioShouldNotBeString() {
+            given()
+                .param("maxOccupationRatio", "invalid")
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("Can not parse maxOccupationRatio"))
+                .body("details", equalTo("For input string: \"invalid\""));
+        }
+
+        @Test
+        default void limitShouldNotBeNegative() {
+            given()
+                .param("limit", -2)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("limit can not be negative"));
+        }
+
+        @Test
+        default void limitShouldNotBeZero() {
+            given()
+                .param("limit", 0)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("limit can not be equal to zero"));
+        }
+
+        @Test
+        default void limitShouldNotBeString() {
+            given()
+                .param("limit", "invalid")
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("Can not parse limit"))
+                .body("details", equalTo("For input string: \"invalid\""));
+        }
+
+        @Test
+        default void offsetShouldNotBeNegative() {
+            given()
+                .param("offset", -2)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("offset can not be negative"));
+        }
+
+        @Test
+        default void offsetShouldAcceptZero() {
+            given()
+                .param("offset", 0)
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.OK_200);
+        }
+
+        @Test
+        default void offsetShouldNotBeString() {
+            given()
+                .param("offset", "invalid")
+            .when()
+                .get("/quota/users")
+            .then()
+                .statusCode(HttpStatus.BAD_REQUEST_400)
+                .contentType(ContentType.JSON)
+                .body("message", equalTo("Can not parse offset"))
+                .body("details", equalTo("For input string: \"invalid\""));
+        }
+
+        @Test
+        default void getUsersQuotaShouldReturnUserDetails(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
+            MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
+
+            maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(100));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), BOB, withSize(10));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), JACK, withSize(11));
+            appendMessage(testSystem.getQuotaSearchTestSystem(), GUY_WITH_STRANGE_DOMAIN, withSize(50));
+
+            testSystem.getQuotaSearchTestSystem().await();
+
+            String jsonAsString =
+                with()
+                    .param("minOccupationRatio", 0.5)
+                    .get("/quota/users")
+                .then()
+                    .statusCode(HttpStatus.OK_200)
+                .extract()
+                    .body()
+                    .asString();
+
+            assertThatJson(jsonAsString)
+                .when(IGNORING_ARRAY_ORDER)
+                    .isEqualTo("[" +
+                            "    {" +
+                            "        \"detail\": {" +
+                            "            \"global\": {" +
+                            "                \"count\": null," +
+                            "                \"size\": 100" +
+                            "            }," +
+                            "            \"domain\": null," +
+                            "            \"user\": null," +
+                            "            \"computed\": {" +
+                            "                \"count\": null," +
+                            "                \"size\": 100" +
+                            "            }," +
+                            "            \"occupation\": {" +
+                            "                \"size\": 50," +
+                            "                \"count\": 1," +
+                            "                \"ratio\": {" +
+                            "                    \"size\": 0.5," +
+                            "                    \"count\": 0.0," +
+                            "                    \"max\": 0.5" +
+                            "                }" +
+                            "            }" +
+                            "        }," +
+                            "        \"username\": \"guy@strange.org\"" +
+                            "    }" +
+                            "]");
+        }
+
+
+        default void appendMessage(QuotaSearchTestSystem testSystem, User user, MessageManager.AppendCommand appendCommand) throws MailboxException {
             MailboxManager mailboxManager = testSystem.getMailboxManager();
             MailboxSession session = mailboxManager.createSystemSession(user.asString());
 
@@ -228,20 +450,20 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class ScanningGetUsersQuotaRouteTest implements GetUsersQuotaRouteContract, SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class ScanningGetUsersQuotaRouteTest implements GetUsersQuotaRouteContract {
 
     }
 
     @Nested
-    @ExtendWith(ElasticSearchRestQuotaSearchExtension.class)
-    class ElasticSearchGetUsersQuotaRouteTest implements GetUsersQuotaRouteContract, SetUp {
+    @ExtendWith(ElasticSearchQuotaSearchExtension.class)
+    class ElasticSearchGetUsersQuotaRouteTest implements GetUsersQuotaRouteContract {
 
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class GetCount implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class GetCount {
 
         @Test
         void getCountShouldReturnNotFoundWhenUserDoesntExist() {
@@ -260,7 +482,7 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void getCountShouldReturnStoredValue(RestQuotaSearchTestSystem testSystem) throws MailboxException {
+        void getCountShouldReturnStoredValue(WebAdminQuotaSearchTestSystem testSystem) throws MailboxException {
             int value = 42;
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
@@ -270,7 +492,7 @@ class UserQuotaRoutesTest {
             Long actual =
                 given()
                     .get(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
-                    .then()
+                .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
                     .extract()
@@ -281,8 +503,8 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class GetSize implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class GetSize {
         @Test
         void getSizeShouldReturnNotFoundWhenUserDoesntExist() {
             when()
@@ -300,7 +522,7 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void getSizeShouldReturnStoredValue(RestQuotaSearchTestSystem testSystem) throws MailboxException {
+        void getSizeShouldReturnStoredValue(WebAdminQuotaSearchTestSystem testSystem) throws MailboxException {
             long value = 42;
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
@@ -322,15 +544,15 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class PutCount implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class PutCount {
         @Test
         void putCountShouldReturnNotFoundWhenUserDoesntExist() {
             given()
                 .body("invalid")
             .when()
                 .put(QUOTA_USERS + "/" + JOE.asString() + "/" + COUNT)
-                .then()
+            .then()
                 .statusCode(HttpStatus.NOT_FOUND_404);
         }
 
@@ -340,13 +562,13 @@ class UserQuotaRoutesTest {
                 .body("35")
             .when()
                 .put(QUOTA_USERS + "/" + ESCAPED_BOB.asString() + "/" + COUNT)
-                .then()
+            .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
         }
 
         @Test
         void putCountShouldRejectInvalid() {
-            Map<String, Object> errors = given()
+            Map<String, Object> errors = with()
                 .body("invalid")
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
@@ -365,13 +587,12 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void putCountShouldSetToInfiniteWhenMinusOne(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putCountShouldSetToInfiniteWhenMinusOne(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("-1")
-            .when()
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
@@ -381,13 +602,13 @@ class UserQuotaRoutesTest {
 
         @Test
         void putCountShouldRejectNegativeOtherThanMinusOne() {
-            Map<String, Object> errors = given()
+            Map<String, Object> errors = with()
                 .body("-2")
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
                 .statusCode(HttpStatus.BAD_REQUEST_400)
                 .contentType(ContentType.JSON)
-                .extract()
+            .extract()
                 .body()
                 .jsonPath()
                 .getMap(".");
@@ -399,11 +620,11 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void putCountShouldAcceptValidValue(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putCountShouldAcceptValidValue(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("42")
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
@@ -414,11 +635,11 @@ class UserQuotaRoutesTest {
 
         @Test
         @Disabled("no link between quota and mailbox for now")
-        void putCountShouldRejectTooSmallValue(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putCountShouldRejectTooSmallValue(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("42")
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
@@ -429,8 +650,8 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class PutSize implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class PutSize {
         @Test
         void putSizeAcceptEscapedUsers() {
             given()
@@ -443,7 +664,7 @@ class UserQuotaRoutesTest {
 
         @Test
         void putSizeShouldRejectInvalid() {
-            Map<String, Object> errors = given()
+            Map<String, Object> errors = with()
                 .body("invalid")
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + SIZE)
             .then()
@@ -472,13 +693,12 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void putSizeShouldSetToInfiniteWhenMinusOne(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putSizeShouldSetToInfiniteWhenMinusOne(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("-1")
-            .when()
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + SIZE)
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
@@ -495,7 +715,7 @@ class UserQuotaRoutesTest {
             .then()
                 .statusCode(HttpStatus.BAD_REQUEST_400)
                 .contentType(ContentType.JSON)
-                .extract()
+            .extract()
                 .body()
                 .jsonPath()
                 .getMap(".");
@@ -507,13 +727,12 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void putSizeShouldAcceptValidValue(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putSizeShouldAcceptValidValue(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("42")
-            .when()
                 .put(QUOTA_USERS + "/" + BOB.asString() + "/" + SIZE)
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
@@ -523,8 +742,8 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class DeleteCount implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class DeleteCount {
 
         @Test
         void deleteCountShouldReturnNotFoundWhenUserDoesntExist() {
@@ -535,12 +754,12 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void deleteCountShouldSetQuotaToEmpty(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void deleteCountShouldSetQuotaToEmpty(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
             maxQuotaManager.setMaxMessage(userQuotaRootResolver.forUser(BOB), QuotaCount.count(42));
 
-            given()
+            with()
                 .delete(QUOTA_USERS + "/" + BOB.asString() + "/" + COUNT)
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
@@ -550,8 +769,8 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class DeleteSize implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class DeleteSize {
         @Test
         void deleteSizeShouldReturnNotFoundWhenUserDoesntExist() {
             when()
@@ -561,13 +780,13 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void deleteSizeShouldSetQuotaToEmpty(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void deleteSizeShouldSetQuotaToEmpty(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
             maxQuotaManager.setMaxStorage(userQuotaRootResolver.forUser(BOB), QuotaSize.size(42));
 
-            given()
+            with()
                 .delete(QUOTA_USERS + "/" + BOB.asString() + "/" + SIZE)
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
@@ -577,8 +796,8 @@ class UserQuotaRoutesTest {
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class GetQuota implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class GetQuota {
         @Test
         void getQuotaShouldReturnNotFoundWhenUserDoesntExist() {
             when()
@@ -588,7 +807,7 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        public void getQuotaShouldReturnBothWhenValueSpecified(RestQuotaSearchTestSystem testSystem) throws Exception {
+        public void getQuotaShouldReturnBothWhenValueSpecified(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
@@ -600,12 +819,12 @@ class UserQuotaRoutesTest {
             maxQuotaManager.setMaxMessage(userQuotaRootResolver.forUser(BOB), QuotaCount.count(52));
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
             SoftAssertions softly = new SoftAssertions();
@@ -617,10 +836,11 @@ class UserQuotaRoutesTest {
             softly.assertThat(jsonPath.getLong("domain." + COUNT)).isEqualTo(23);
             softly.assertThat(jsonPath.getLong("global." + SIZE)).isEqualTo(1111);
             softly.assertThat(jsonPath.getLong("global." + COUNT)).isEqualTo(22);
+            softly.assertAll();
         }
 
         @Test
-        public void getQuotaShouldReturnOccupation(RestQuotaSearchTestSystem testSystem) throws Exception {
+        public void getQuotaShouldReturnOccupation(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
             InMemoryCurrentQuotaManager currentQuotaManager = testSystem.getQuotaSearchTestSystem().getCurrentQuotaManager();
@@ -630,12 +850,12 @@ class UserQuotaRoutesTest {
             currentQuotaManager.increase(userQuotaRootResolver.forUser(BOB), 20, 40);
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
             SoftAssertions softly = new SoftAssertions();
@@ -644,10 +864,11 @@ class UserQuotaRoutesTest {
             softly.assertThat(jsonPath.getDouble("occupation.ratio.count")).isEqualTo(0.2);
             softly.assertThat(jsonPath.getDouble("occupation.ratio.size")).isEqualTo(0.5);
             softly.assertThat(jsonPath.getDouble("occupation.ratio.max")).isEqualTo(0.5);
+            softly.assertAll();
         }
 
         @Test
-        public void getQuotaShouldReturnOccupationWhenUnlimited(RestQuotaSearchTestSystem testSystem) throws Exception {
+        public void getQuotaShouldReturnOccupationWhenUnlimited(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
             InMemoryCurrentQuotaManager currentQuotaManager = testSystem.getQuotaSearchTestSystem().getCurrentQuotaManager();
@@ -657,12 +878,12 @@ class UserQuotaRoutesTest {
             currentQuotaManager.increase(userQuotaRootResolver.forUser(BOB), 20, 40);
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
             SoftAssertions softly = new SoftAssertions();
@@ -671,10 +892,11 @@ class UserQuotaRoutesTest {
             softly.assertThat(jsonPath.getDouble("occupation.ratio.count")).isEqualTo(0);
             softly.assertThat(jsonPath.getDouble("occupation.ratio.size")).isEqualTo(0);
             softly.assertThat(jsonPath.getDouble("occupation.ratio.max")).isEqualTo(0);
+            softly.assertAll();
         }
 
         @Test
-        public void getQuotaShouldReturnOnlySpecifiedValues(RestQuotaSearchTestSystem testSystem) throws Exception {
+        public void getQuotaShouldReturnOnlySpecifiedValues(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
@@ -683,39 +905,40 @@ class UserQuotaRoutesTest {
             maxQuotaManager.setDomainMaxMessage(Domain.of(PERDU_COM), QuotaCount.count(52));
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
             SoftAssertions softly = new SoftAssertions();
             softly.assertThat(jsonPath.getLong("computed." + SIZE)).isEqualTo(1111);
-            softly.assertThat(jsonPath.getLong("computed." + COUNT)).isEqualTo(52);
-            softly.assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(52);
+            softly.assertThat(jsonPath.getLong("computed." + COUNT)).isEqualTo(18);
+            softly.assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(18);
             softly.assertThat(jsonPath.getObject("user." + SIZE, Long.class)).isNull();
             softly.assertThat(jsonPath.getObject("domain." + SIZE, Long.class)).isNull();
-            softly.assertThat(jsonPath.getObject("domain." + COUNT, Long.class)).isEqualTo(18);
+            softly.assertThat(jsonPath.getObject("domain." + COUNT, Long.class)).isEqualTo(52);
             softly.assertThat(jsonPath.getLong("global." + SIZE)).isEqualTo(1111);
             softly.assertThat(jsonPath.getObject("global." + COUNT, Long.class)).isNull();
+            softly.assertAll();
         }
 
         @Test
-        public void getQuotaShouldReturnGlobalValuesWhenNoUserValuesDefined(RestQuotaSearchTestSystem testSystem) throws Exception {
+        public void getQuotaShouldReturnGlobalValuesWhenNoUserValuesDefined(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
 
             maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(1111));
             maxQuotaManager.setGlobalMaxMessage(QuotaCount.count(12));
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
             SoftAssertions softly = new SoftAssertions();
@@ -725,10 +948,11 @@ class UserQuotaRoutesTest {
             softly.assertThat(jsonPath.getObject("domain", Object.class)).isNull();
             softly.assertThat(jsonPath.getLong("global." + SIZE)).isEqualTo(1111);
             softly.assertThat(jsonPath.getLong("global." + COUNT)).isEqualTo(12);
+            softly.assertAll();
         }
 
         @Test
-        void getQuotaShouldReturnBothWhenValueSpecifiedAndEscaped(RestQuotaSearchTestSystem testSystem) throws MailboxException {
+        void getQuotaShouldReturnBothWhenValueSpecifiedAndEscaped(WebAdminQuotaSearchTestSystem testSystem) throws MailboxException {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
@@ -738,35 +962,39 @@ class UserQuotaRoutesTest {
             maxQuotaManager.setMaxMessage(userQuotaRootResolver.forUser(BOB), QuotaCount.count(maxMessage));
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + ESCAPED_BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
-            assertThat(jsonPath.getLong("user." + SIZE)).isEqualTo(maxStorage);
-            assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(maxMessage);
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(jsonPath.getLong("user." + SIZE)).isEqualTo(maxStorage);
+            softly.assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(maxMessage);
+            softly.assertAll();
         }
 
         @Test
         void getQuotaShouldReturnBothEmptyWhenDefaultValues() {
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
-            assertThat(jsonPath.getObject(SIZE, Long.class)).isNull();
-            assertThat(jsonPath.getObject(COUNT, Long.class)).isNull();
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(jsonPath.getObject(SIZE, Long.class)).isNull();
+            softly.assertThat(jsonPath.getObject(COUNT, Long.class)).isNull();
+            softly.assertAll();
         }
 
         @Test
-        void getQuotaShouldReturnSizeWhenNoCount(RestQuotaSearchTestSystem testSystem) throws MailboxException {
+        void getQuotaShouldReturnSizeWhenNoCount(WebAdminQuotaSearchTestSystem testSystem) throws MailboxException {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
@@ -774,20 +1002,22 @@ class UserQuotaRoutesTest {
             maxQuotaManager.setMaxStorage(userQuotaRootResolver.forUser(BOB), QuotaSize.size(maxStorage));
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
-            assertThat(jsonPath.getLong("user." + SIZE)).isEqualTo(maxStorage);
-            assertThat(jsonPath.getObject("user." + COUNT, Long.class)).isNull();
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(jsonPath.getLong("user." + SIZE)).isEqualTo(maxStorage);
+            softly.assertThat(jsonPath.getObject("user." + COUNT, Long.class)).isNull();
+            softly.assertAll();
         }
 
         @Test
-        void getQuotaShouldReturnBothWhenNoSize(RestQuotaSearchTestSystem testSystem) throws MailboxException {
+        void getQuotaShouldReturnBothWhenNoSize(WebAdminQuotaSearchTestSystem testSystem) throws MailboxException {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
@@ -796,22 +1026,24 @@ class UserQuotaRoutesTest {
 
 
             JsonPath jsonPath =
-                given()
+                when()
                     .get(QUOTA_USERS + "/" + BOB.asString())
                 .then()
                     .statusCode(HttpStatus.OK_200)
                     .contentType(ContentType.JSON)
-                    .extract()
+                .extract()
                     .jsonPath();
 
-            assertThat(jsonPath.getObject("user." + SIZE, Long.class)).isNull();
-            assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(maxMessage);
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(jsonPath.getObject("user." + SIZE, Long.class)).isNull();
+            softly.assertThat(jsonPath.getLong("user." + COUNT)).isEqualTo(maxMessage);
+            softly.assertAll();
         }
     }
 
     @Nested
-    @ExtendWith(ScanningRestQuotaSearchExtension.class)
-    class PutQuota implements SetUp {
+    @ExtendWith(ScanningQuotaSearchExtension.class)
+    class PutQuota {
 
         @Test
         void putQuotaShouldReturnNotFoundWhenUserDoesntExist() {
@@ -822,37 +1054,41 @@ class UserQuotaRoutesTest {
         }
 
         @Test
-        void putQuotaShouldUpdateBothQuota(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putQuotaShouldUpdateBothQuota(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("{\"count\":52,\"size\":42}")
                 .put(QUOTA_USERS + "/" + BOB.asString())
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
 
-            assertThat(maxQuotaManager.getMaxMessage(userQuotaRootResolver.forUser(BOB)))
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(maxQuotaManager.getMaxMessage(userQuotaRootResolver.forUser(BOB)))
                 .contains(QuotaCount.count(52));
-            assertThat(maxQuotaManager.getMaxStorage(userQuotaRootResolver.forUser(BOB)))
+            softly.assertThat(maxQuotaManager.getMaxStorage(userQuotaRootResolver.forUser(BOB)))
                 .contains(QuotaSize.size(42));
+            softly.assertAll();
         }
 
         @Test
-        void putQuotaShouldUpdateBothQuotaWhenEscaped(RestQuotaSearchTestSystem testSystem) throws Exception {
+        void putQuotaShouldUpdateBothQuotaWhenEscaped(WebAdminQuotaSearchTestSystem testSystem) throws Exception {
             MaxQuotaManager maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager();
             UserQuotaRootResolver userQuotaRootResolver = testSystem.getQuotaSearchTestSystem().getQuotaRootResolver();
 
-            given()
+            with()
                 .body("{\"count\":52,\"size\":42}")
                 .put(QUOTA_USERS + "/" + ESCAPED_BOB.asString())
             .then()
                 .statusCode(HttpStatus.NO_CONTENT_204);
 
-            assertThat(maxQuotaManager.getMaxMessage(userQuotaRootResolver.forUser(BOB)))
+            SoftAssertions softly = new SoftAssertions();
+            softly.assertThat(maxQuotaManager.getMaxMessage(userQuotaRootResolver.forUser(BOB)))
                 .contains(QuotaCount.count(52));
-            assertThat(maxQuotaManager.getMaxStorage(userQuotaRootResolver.forUser(BOB)))
+            softly.assertThat(maxQuotaManager.getMaxStorage(userQuotaRootResolver.forUser(BOB)))
                 .contains(QuotaSize.size(42));
+            softly.assertAll();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/350bc6c5/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..03c16f1
--- /dev/null
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/WebAdminQuotaSearchTestSystem.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.routes;
+
+import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;
+
+import org.apache.james.metrics.api.NoopMetricFactory;
+import org.apache.james.quota.search.QuotaSearchTestSystem;
+import org.apache.james.webadmin.WebAdminServer;
+import org.apache.james.webadmin.WebAdminUtils;
+import org.apache.james.webadmin.jackson.QuotaModule;
+import org.apache.james.webadmin.service.UserQuotaService;
+import org.apache.james.webadmin.utils.JsonTransformer;
+
+import com.google.common.collect.ImmutableSet;
+import com.jayway.restassured.specification.RequestSpecification;
+
+public class WebAdminQuotaSearchTestSystem {
+    private final QuotaSearchTestSystem quotaSearchTestSystem;
+    private final WebAdminServer webAdminServer;
+    private final RequestSpecification requestSpecBuilder;
+
+    public WebAdminQuotaSearchTestSystem(QuotaSearchTestSystem quotaSearchTestSystem) throws Exception {
+        this.quotaSearchTestSystem = quotaSearchTestSystem;
+
+        UserQuotaService userQuotaService = new UserQuotaService(quotaSearchTestSystem.getMaxQuotaManager(),
+            quotaSearchTestSystem.getQuotaManager(),
+            quotaSearchTestSystem.getQuotaRootResolver(),
+            quotaSearchTestSystem.getQuotaSearcher());
+
+        QuotaModule quotaModule = new QuotaModule();
+        JsonTransformer jsonTransformer = new JsonTransformer(quotaModule);
+        UserQuotaRoutes userQuotaRoutes = new UserQuotaRoutes(quotaSearchTestSystem.getUsersRepository(),
+            userQuotaService, jsonTransformer,
+            ImmutableSet.of(quotaModule));
+
+        this.webAdminServer = WebAdminUtils.createWebAdminServer(
+            new NoopMetricFactory(),
+            userQuotaRoutes);
+        this.webAdminServer.configure(NO_CONFIGURATION);
+        this.webAdminServer.await();
+
+        this.requestSpecBuilder = WebAdminUtils.buildRequestSpecification(webAdminServer)
+            .build();
+    }
+
+    public QuotaSearchTestSystem getQuotaSearchTestSystem() {
+        return quotaSearchTestSystem;
+    }
+
+    public WebAdminServer getWebAdminServer() {
+        return webAdminServer;
+    }
+
+    public RequestSpecification getRequestSpecification() {
+        return requestSpecBuilder;
+    }
+}


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