chibenwa commented on code in PR #2474: URL: https://github.com/apache/james-project/pull/2474#discussion_r1822121474
########## 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())); Review Comment: Can we leverage the jsonPath in order to get a `List<String>` -- 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