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


##########
server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/UserRoutesTest.java:
##########
@@ -1063,6 +1076,76 @@ 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<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
+        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("hasNotAccessedAllSystemMailboxes")
+                .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()));

Review Comment:
   Here I am expecting both users as neither of them has all system mailboxes



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