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


##########
server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UserRoutesTest.java:
##########
@@ -431,6 +444,76 @@ default void getUsersShouldBeEmptyByDefault() {
                 assertThat(users).isEmpty();
             }
 
+            @Test
+            default void getUsersShouldReturnUsers(UsersRepository 
usersRepository)
+                throws UsersRepositoryException, MailboxException {
+                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
+            default 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<Map<String, String>> users =
+                    given()
+                        .queryParam("hasNoMailboxes")
+                    .when()
+                        .get()
+                    .then()
+                        .statusCode(HttpStatus.OK_200)
+                        .contentType(ContentType.JSON)
+                        .extract()
+                        .body()
+                        .jsonPath()
+                        .getList(".");
+
+                assertThat(users.stream().flatMap(map -> 
map.values().stream()).toList()).isEqualTo(ImmutableList.of(BOB.asString()));
+            }
+
+            @Test
+            default void 
getUsersShouldReturnUsersWithNoAccessWhenHasNotAccessAllSystemMailboxesParaIsSet(UsersRepository
 usersRepository, MailboxManager mailboxManager)
+                throws UsersRepositoryException, MailboxException {
+                usersRepository.addUser(ALICE, "");
+                usersRepository.addUser(BOB, "");
+                mailboxManager.createMailbox(MailboxPath.forUser(ALICE, 
DefaultMailboxes.INBOX), mailboxManager.createSystemSession(ALICE));
+                mailboxManager.createMailbox(MailboxPath.forUser(ALICE, 
DefaultMailboxes.SENT), mailboxManager.createSystemSession(ALICE));
+                mailboxManager.createMailbox(MailboxPath.forUser(BOB, 
DefaultMailboxes.INBOX), mailboxManager.createSystemSession(BOB));
+
+                List<Map<String, String>> users =
+                    given()
+                        .queryParam("hasNotAccessAllSystemMailboxes")
+                        .when()
+                        .get()
+                        .then()
+                        .statusCode(HttpStatus.OK_200)
+                        .contentType(ContentType.JSON)
+                        .extract()
+                        .body()
+                        .jsonPath()
+                        .getList(".");

Review Comment:
   ```suggestion
                       given()
                           .queryParam("hasNotAccessAllSystemMailboxes")
                       .when()
                           .get()
                       .then()
                           .statusCode(HttpStatus.OK_200)
                           .contentType(ContentType.JSON)
                           .extract()
                           .body()
                           .jsonPath()
                           .getList(".");
   ```



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