@Test public void test11DeactivateUser() { VXPortalUser vxPUserExp = CreateVXPortalUser(); XXPortalUser xxPUserExp = new XXPortalUser(); xxPUserExp.setLoginId(loginId); xxPUserExp.setStatus(1); vxPUserExp.setStatus(5); XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class); Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao); Mockito.when(xxPortalUserDao.getById(userId)).thenReturn(xxPUserExp); Mockito.when(userManager.deactivateUser(xxPUserExp)).thenReturn(vxPUserExp); VXPortalUser vxPUserAct = userREST.deactivateUser(userId); Assert.assertNotNull(vxPUserAct); Assert.assertEquals(xxPUserExp.getLoginId(), vxPUserAct.getLoginId()); Assert.assertEquals(vxPUserExp.getStatus(), vxPUserAct.getStatus()); Assert.assertEquals(vxPUserExp.getId(), vxPUserAct.getId()); Assert.assertEquals(vxPUserExp.getFirstName(), vxPUserAct.getFirstName()); Mockito.verify(daoManager).getXXPortalUser(); Mockito.verify(xxPortalUserDao).getById(userId); Mockito.verify(userManager).deactivateUser(xxPUserExp); }
@POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) public VXPortalUser deactivateUser(@PathParam("userId") Long userId) { XXPortalUser gjUser = daoManager.getXXPortalUser().getById(userId); if (gjUser == null) { logger.info("update(): Invalid userId provided: userId=" + userId); throw restErrorUtil.createRESTException("serverMsg.userRestUser", MessageEnums.DATA_NOT_FOUND, null, null, "" + userId); } return userManager.deactivateUser(gjUser); }
UserREST { @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) public VXPortalUser deactivateUser(@PathParam("userId") Long userId) { XXPortalUser gjUser = daoManager.getXXPortalUser().getById(userId); if (gjUser == null) { logger.info("update(): Invalid userId provided: userId=" + userId); throw restErrorUtil.createRESTException("serverMsg.userRestUser", MessageEnums.DATA_NOT_FOUND, null, null, "" + userId); } return userManager.deactivateUser(gjUser); } }
UserREST { @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) public VXPortalUser deactivateUser(@PathParam("userId") Long userId) { XXPortalUser gjUser = daoManager.getXXPortalUser().getById(userId); if (gjUser == null) { logger.info("update(): Invalid userId provided: userId=" + userId); throw restErrorUtil.createRESTException("serverMsg.userRestUser", MessageEnums.DATA_NOT_FOUND, null, null, "" + userId); } return userManager.deactivateUser(gjUser); }  }
UserREST { @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) public VXPortalUser deactivateUser(@PathParam("userId") Long userId) { XXPortalUser gjUser = daoManager.getXXPortalUser().getById(userId); if (gjUser == null) { logger.info("update(): Invalid userId provided: userId=" + userId); throw restErrorUtil.createRESTException("serverMsg.userRestUser", MessageEnums.DATA_NOT_FOUND, null, null, "" + userId); } return userManager.deactivateUser(gjUser); }  @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 { @POST @Path("{userId}/deactivate") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DEACTIVATE_USER + "\")") @RangerAnnotationClassName(class_name = VXPortalUser.class) public VXPortalUser deactivateUser(@PathParam("userId") Long userId) { XXPortalUser gjUser = daoManager.getXXPortalUser().getById(userId); if (gjUser == null) { logger.info("update(): Invalid userId provided: userId=" + userId); throw restErrorUtil.createRESTException("serverMsg.userRestUser", MessageEnums.DATA_NOT_FOUND, null, null, "" + userId); } return userManager.deactivateUser(gjUser); }  @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);  }