chibenwa commented on code in PR #2474:
URL: https://github.com/apache/james-project/pull/2474#discussion_r1827149012


##########
server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UserRoutesTest.java:
##########
@@ -1063,6 +1085,82 @@ void 
verifyShouldReturnUnauthorizedWhenUserDoesNotExist() {
                 .statusCode(HttpStatus.UNAUTHORIZED_401);
         }
 
+        @Test
+        void getUsersShouldReturnUsers(UsersRepository usersRepository)
+            throws UsersRepositoryException {
+            usersRepository.addUser(ALICE, "");
+            usersRepository.addUser(BOB, "");
+
+            List<Map<String, String>> users =
+                when()
+                    .get()
+                .then()
+                    .statusCode(HttpStatus.OK_200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+
+            List<String> expected = ImmutableList.of(ALICE.asString(), 
BOB.asString());
+            assertThat(users.stream().flatMap(map -> 
map.values().stream()).toList()).hasSameSizeAs(expected);
+            assertThat(users.stream().flatMap(map -> 
map.values().stream()).toList()).hasSameElementsAs(expected);
+        }
+
+        @Test
+        void 
getUsersShouldReturnUsersWithNoMailboxWhenHasNoMailboxesParaIsSet(UsersRepository
 usersRepository, MailboxManager mailboxManager)
+            throws UsersRepositoryException, MailboxException {
+            usersRepository.addUser(ALICE, "");
+            usersRepository.addUser(BOB, "");
+            mailboxManager.createMailbox(MailboxPath.forUser(ALICE, 
DefaultMailboxes.INBOX), mailboxManager.createSystemSession(ALICE));
+
+            List<String> users =
+                given()
+                    .queryParam("hasNoMailboxes")
+                .when()
+                    .get()
+                .then()
+                    .statusCode(HttpStatus.OK_200)
+                    .contentType(ContentType.JSON)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".", Map.class)
+                    .stream()
+                    .flatMap(map -> map.values().stream())
+                    .toList();
+
+            assertThat(users).isEqualTo(ImmutableList.of(BOB.asString()));

Review Comment:
   ```suggestion
               assertThat(users).containsExactly(InAnyOrder)(BOB.asString());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to