UserManagementServiceImpl implements UserManagementService { @GET @Path("/search/usernames") @Override public Response getUserNames(@QueryParam("filter") String filter, @QueryParam("domain") String domain, @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 using the filter : " + filter); } String userStoreDomain = Constants.PRIMARY_USER_STORE; if (domain != null && !domain.isEmpty()) { userStoreDomain = domain; } if (limit == 0){ limit = -1; } List<UserInfo> userList; try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); String[] users = userStoreManager.listUsers(userStoreDomain + "/" + filter + "*", limit); userList = new ArrayList<>(); UserInfo user; for (String username : users) { user = new UserInfo(); 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); } return Response.status(Response.Status.OK).entity(userList).build(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving the list of users using the filter : " + filter; 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 getUserNames method of UserManagementService", dependsOnMethods = {"testSendInvitation"}) public void testGetUserNames() throws UserStoreException { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getUserStoreManager")) .toReturn(this.userStoreManager); Mockito.doReturn(new String[] { TEST_USERNAME }).when(userStoreManager) .listUsers(Mockito.anyString(), Mockito.anyInt()); Response response = userManagementService.getUserNames(TEST_USERNAME, null, "00", 0, 0); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Getting user names is failed for a valid request"); }