@Override
    public List<User> loadByIds(Collection<String> ids) {
        final HashSet<String> userIds = new HashSet<>(ids);
        final List<User> users = new ArrayList<>();

        // special case for the locally defined user, we don't store that in MongoDB.
        if (!configuration.isRootUserDisabled() && userIds.stream().anyMatch(UserImpl.LocalAdminUser.LOCAL_ADMIN_ID::equals)) {
            // The local admin ID is not a valid ObjectId so we have to remove it from the query
            userIds.remove(UserImpl.LocalAdminUser.LOCAL_ADMIN_ID);
            users.add(userFactory.createLocalAdminUser(roleService.getAdminRoleObjectId()));
        }

        final DBObject query = new BasicDBObject();
        query.put("_id", new BasicDBObject("$in", userIds.stream().map(ObjectId::new).collect(Collectors.toSet())));

        final List<DBObject> result = query(UserImpl.class, query);
        if (result == null || result.isEmpty()) {
            return users;
        }

        for (final DBObject dbObject : result) {
            //noinspection unchecked
            users.add(userFactory.create((ObjectId) dbObject.get("_id"), dbObject.toMap()));
        }

        return users;
    }
@Test
    @MongoDBFixtures("UserServiceImplTest.json")
    public void testLoadByUserIdsWithAdminOnly() throws Exception {
        final List<User> users = userService.loadByIds(ImmutableSet.of(
                UserImpl.LocalAdminUser.LOCAL_ADMIN_ID
        ));

        assertThat(users).hasSize(1);

        assertThat(users.get(0).getId()).isEqualTo("local:admin");
        assertThat(users.get(0).getName()).isEqualTo("admin");
        assertThat(users.get(0).getEmail()).isEmpty();
    }