UserREST { @POST @Path("/default") @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_DEFAULT_ACCOUNT_USER + "\")") public VXPortalUser createDefaultAccountUser(VXPortalUser userProfile, @Context HttpServletRequest servletRequest) { VXPortalUser vxPortalUser; vxPortalUser=userManager.createDefaultAccountUser(userProfile); if(vxPortalUser!=null) { xUserMgr.assignPermissionToUser(vxPortalUser, true); } return vxPortalUser; }  @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);  }
@Test public void test7CreateDefaultAccountUser() { VXPortalUser vxPUserExp = new VXPortalUser(); vxPUserExp = null; Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp); VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request); Assert.assertNull(VXPUserAct); Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp); }
@Test public void test8CreateDefaultAccountUser() { VXPortalUser vxPUserExp = CreateVXPortalUser(); Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp); Mockito.doNothing().when(xUserMgr).assignPermissionToUser(vxPUserExp, true); VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request); Assert.assertNotNull(VXPUserAct); Assert.assertEquals(vxPUserExp, VXPUserAct); Assert.assertEquals(vxPUserExp.getLoginId(), VXPUserAct.getLoginId()); Assert.assertEquals(vxPUserExp.getFirstName(), VXPUserAct.getFirstName()); Assert.assertEquals(vxPUserExp.getLastName(), VXPUserAct.getLastName()); Assert.assertEquals(vxPUserExp.getEmailAddress(), VXPUserAct.getEmailAddress()); Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp); Mockito.verify(xUserMgr).assignPermissionToUser(vxPUserExp, true); }