@Test public void test1SearchUsers() { SearchCriteria searchCriteria = new SearchCriteria(); vXPUserExpList = new VXPortalUserList(); vXPUserExpList.setPageSize(pageSize); List<Integer> status = new ArrayList<Integer>(); String publicScreenName = "nrp"; List<String> roles = new ArrayList<String>(); Mockito.when(searchUtil.extractCommonCriterias(Matchers.eq(request), Matchers.anyListOf(SortField.class))).thenReturn(searchCriteria); Mockito.when(searchUtil.extractLong(request, searchCriteria, "userId", "User Id")).thenReturn(userId); Mockito.when(searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null)) .thenReturn(loginId); Mockito.when(searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null)) .thenReturn(emailId); Mockito.when(searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME)).thenReturn(firstName); Mockito.when( searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME)) .thenReturn(lastName); Mockito.when(searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX)).thenReturn(status); Mockito.when(searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME)).thenReturn(publicScreenName); Mockito.when(searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME)).thenReturn(roles); Mockito.when(userManager.searchUsers(searchCriteria)).thenReturn(vXPUserExpList); VXPortalUserList vXPUserListAct = userREST.searchUsers(request); Assert.assertNotNull(vXPUserListAct); Assert.assertEquals(vXPUserExpList, vXPUserListAct); Assert.assertEquals(vXPUserExpList.getPageSize(), vXPUserListAct.getPageSize()); Mockito.verify(searchUtil).extractCommonCriterias(Matchers.eq(request), Matchers.anyListOf(SortField.class)); Mockito.verify(searchUtil).extractLong(request, searchCriteria, "userId", "User Id"); Mockito.verify(searchUtil).extractString(request, searchCriteria, "loginId", "Login Id", null); Mockito.verify(searchUtil).extractString(request, searchCriteria, "emailAddress", "Email Address", null); Mockito.verify(searchUtil).extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); Mockito.verify(searchUtil).extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); Mockito.verify(searchUtil).extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); Mockito.verify(searchUtil).extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); Mockito.verify(searchUtil).extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); Mockito.verify(userManager).searchUsers(searchCriteria); }
@GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") public VXPortalUserList searchUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, SORT_FIELDS); searchUtil.extractLong(request, searchCriteria, "userId", "User Id"); searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); return userManager.searchUsers(searchCriteria); }
UserREST { @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") public VXPortalUserList searchUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, SORT_FIELDS); searchUtil.extractLong(request, searchCriteria, "userId", "User Id"); searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); return userManager.searchUsers(searchCriteria); } }
UserREST { @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") public VXPortalUserList searchUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, SORT_FIELDS); searchUtil.extractLong(request, searchCriteria, "userId", "User Id"); searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); return userManager.searchUsers(searchCriteria); }  }
UserREST { @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") public VXPortalUserList searchUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, SORT_FIELDS); searchUtil.extractLong(request, searchCriteria, "userId", "User Id"); searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); return userManager.searchUsers(searchCriteria); }  @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") VXPortalUserList searchUsers(@Context HttpServletRequest request); @GET @Path("{userId}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_USER_PROFILE_FOR_USER + "\")") VXPortalUser getUserProfileForUser(@PathParam("userId") Long userId); @POST @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE + "\")") VXPortalUser create(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @POST @Path("/default") @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_DEFAULT_ACCOUNT_USER + "\")") VXPortalUser createDefaultAccountUser(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @PUT @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @RangerAnnotationRestAPI(updates_classes = "VUserProfile") @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE + "\")") VXPortalUser update(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @PUT @Path("/{userId}/roles") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SET_USER_ROLES + "\")") VXResponse setUserRoles(@PathParam("userId") Long userId,
			VXStringList roleList); @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) VXPortalUser deactivateUser(@PathParam("userId") Long userId); @GET @Path("/profile") @Produces({ "application/xml", "application/json" }) VXPortalUser getUserProfile(@Context HttpServletRequest request); @GET @Path("/firstnames") @Produces({ "application/xml", "application/json" }) String suggestUserFirstName(@QueryParam("letters") String letters,
			@Context HttpServletRequest req); @POST @Path("{userId}/passwordchange") @Produces({ "application/xml", "application/json" }) VXResponse changePassword(@PathParam("userId") Long userId,
			VXPasswordChange changePassword); @POST @Path("{userId}/emailchange") @Produces({ "application/xml", "application/json" }) VXPortalUser changeEmailAddress(@PathParam("userId") Long userId,
			VXPasswordChange changeEmail); }
UserREST { @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") public VXPortalUserList searchUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, SORT_FIELDS); searchUtil.extractLong(request, searchCriteria, "userId", "User Id"); searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME); searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME); searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX); searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME); searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME); return userManager.searchUsers(searchCriteria); }  @GET @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")") VXPortalUserList searchUsers(@Context HttpServletRequest request); @GET @Path("{userId}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_USER_PROFILE_FOR_USER + "\")") VXPortalUser getUserProfileForUser(@PathParam("userId") Long userId); @POST @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE + "\")") VXPortalUser create(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @POST @Path("/default") @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_DEFAULT_ACCOUNT_USER + "\")") VXPortalUser createDefaultAccountUser(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @PUT @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @RangerAnnotationRestAPI(updates_classes = "VUserProfile") @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.UPDATE + "\")") VXPortalUser update(VXPortalUser userProfile,
			@Context HttpServletRequest servletRequest); @PUT @Path("/{userId}/roles") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SET_USER_ROLES + "\")") VXResponse setUserRoles(@PathParam("userId") Long userId,
			VXStringList roleList); @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) VXPortalUser deactivateUser(@PathParam("userId") Long userId); @GET @Path("/profile") @Produces({ "application/xml", "application/json" }) VXPortalUser getUserProfile(@Context HttpServletRequest request); @GET @Path("/firstnames") @Produces({ "application/xml", "application/json" }) String suggestUserFirstName(@QueryParam("letters") String letters,
			@Context HttpServletRequest req); @POST @Path("{userId}/passwordchange") @Produces({ "application/xml", "application/json" }) VXResponse changePassword(@PathParam("userId") Long userId,
			VXPasswordChange changePassword); @POST @Path("{userId}/emailchange") @Produces({ "application/xml", "application/json" }) VXPortalUser changeEmailAddress(@PathParam("userId") Long userId,
			VXPasswordChange changeEmail);  }