UserManagementServiceImpl implements UserManagementService { @GET @Override public Response getUsers(@QueryParam("filter") String filter, @HeaderParam("If-Modified-Since") String timestamp, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { if (log.isDebugEnabled()) { log.debug("Getting the list of users with all user-related information"); } RequestValidationUtil.validatePaginationParameters(offset, limit); if (limit == 0) { limit = Constants.DEFAULT_PAGE_LIMIT; } List<BasicUserInfo> userList, offsetList; String appliedFilter = ((filter == null) || filter.isEmpty() ? "*" : filter + "*"); int appliedLimit = -1; try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); String[] users = userStoreManager.listUsers(appliedFilter, appliedLimit); userList = new ArrayList<>(users.length); BasicUserInfo user; for (String username : users) { user = new BasicUserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME)); user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME)); userList.add(user); } int toIndex = offset + limit; int listSize = userList.size(); int lastIndex = listSize - 1; if (offset <= lastIndex) { if (toIndex <= listSize) { offsetList = userList.subList(offset, toIndex); } else { offsetList = userList.subList(offset, listSize); } } else { offsetList = new ArrayList<>(); } BasicUserInfoList result = new BasicUserInfoList(); result.setList(offsetList); result.setCount(users.length); return Response.status(Response.Status.OK).entity(result).build(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving the list of users."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } }  @POST @Override Response addUser(UserInfo userInfo); @GET @Path("/{username}") @Override Response getUser(@PathParam("username") String username, @QueryParam("domain") String domain,
                            @HeaderParam("If-Modified-Since") String ifModifiedSince); @PUT @Path("/{username}") @Override Response updateUser(@PathParam("username") String username, @QueryParam("domain") String domain, UserInfo userInfo); @DELETE @Path("/{username}") @Override Response removeUser(@PathParam("username") String username, @QueryParam("domain") String domain); @GET @Path("/{username}/roles") @Override Response getRolesOfUser(@PathParam("username") String username, @QueryParam("domain") String domain); @GET @Override Response getUsers(@QueryParam("filter") String filter, @HeaderParam("If-Modified-Since") String timestamp,
                             @QueryParam("offset") int offset,
                             @QueryParam("limit") int limit); @GET @Path("/count") @Override Response getUserCount(); @GET @Path("/checkUser") @Override Response isUserExists(@QueryParam("username") String userName); @GET @Path("/search/usernames") @Override Response getUserNames(@QueryParam("filter") String filter, @QueryParam("domain") String domain,
                                 @HeaderParam("If-Modified-Since") String timestamp,
                                 @QueryParam("offset") int offset, @QueryParam("limit") int limit); @PUT @Path("/credentials") @Override Response resetPassword(OldPasswordResetWrapper credentials); @POST @Path("/send-invitation") @Produces({MediaType.APPLICATION_JSON}) Response inviteExistingUsersToEnrollDevice(List<String> usernames); @POST @Path("/enrollment-invite") @Override Response inviteToEnrollDevice(EnrollmentInvitation enrollmentInvitation);  }
@Test(description = "This method tests the getUsers method of UserManagementService", dependsOnMethods = {"testGetUserNames"}) public void testGetUsers() { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getUserStoreManager")) .toReturn(userStoreManager); Response response = userManagementService.getUsers(null, "00", 0, 10); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "GetUsers request failed"); }