@Test public void test13GetUserProfile() { HttpSession hs = Mockito.mock(HttpSession.class); VXPortalUser vxPUserExp = CreateVXPortalUser(); Mockito.when(userManager.getUserProfileByLoginId()).thenReturn(vxPUserExp); Mockito.when(request.getSession()).thenReturn(hs); Mockito.when(hs.getId()).thenReturn("id"); VXPortalUser vxPUserAct = userREST.getUserProfile(request); Assert.assertNotNull(vxPUserAct); Assert.assertEquals(vxPUserExp, vxPUserAct); Assert.assertEquals(vxPUserExp.getId(), vxPUserAct.getId()); Assert.assertEquals(vxPUserExp.getFirstName(), vxPUserAct.getFirstName()); Mockito.verify(userManager).getUserProfileByLoginId(); }
@GET @Path("/profile") @Produces({ "application/xml", "application/json" }) public VXPortalUser getUserProfile(@Context HttpServletRequest request) { try { logger.debug("getUserProfile(). httpSessionId=" + request.getSession().getId()); VXPortalUser userProfile = userManager.getUserProfileByLoginId(); return userProfile; } catch (Throwable t) { logger.error( "getUserProfile() no user session. error=" + t.toString(), t); } return null; }
UserREST { @GET @Path("/profile") @Produces({ "application/xml", "application/json" }) public VXPortalUser getUserProfile(@Context HttpServletRequest request) { try { logger.debug("getUserProfile(). httpSessionId=" + request.getSession().getId()); VXPortalUser userProfile = userManager.getUserProfileByLoginId(); return userProfile; } catch (Throwable t) { logger.error( "getUserProfile() no user session. error=" + t.toString(), t); } return null; } }
UserREST { @GET @Path("/profile") @Produces({ "application/xml", "application/json" }) public VXPortalUser getUserProfile(@Context HttpServletRequest request) { try { logger.debug("getUserProfile(). httpSessionId=" + request.getSession().getId()); VXPortalUser userProfile = userManager.getUserProfileByLoginId(); return userProfile; } catch (Throwable t) { logger.error( "getUserProfile() no user session. error=" + t.toString(), t); } return null; }  }
UserREST { @GET @Path("/profile") @Produces({ "application/xml", "application/json" }) public VXPortalUser getUserProfile(@Context HttpServletRequest request) { try { logger.debug("getUserProfile(). httpSessionId=" + request.getSession().getId()); VXPortalUser userProfile = userManager.getUserProfileByLoginId(); return userProfile; } catch (Throwable t) { logger.error( "getUserProfile() no user session. error=" + t.toString(), t); } return null; }  @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 @Path("/profile") @Produces({ "application/xml", "application/json" }) public VXPortalUser getUserProfile(@Context HttpServletRequest request) { try { logger.debug("getUserProfile(). httpSessionId=" + request.getSession().getId()); VXPortalUser userProfile = userManager.getUserProfileByLoginId(); return userProfile; } catch (Throwable t) { logger.error( "getUserProfile() no user session. error=" + t.toString(), t); } return null; }  @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);  }