UserService extends BasicService { @GET @Path("/user") @Produces(MediaType.APPLICATION_JSON) public User getCurrentUser() { return userUtil.getLoggedInDBUser(request); }  @GET @Path("/user") @Produces(MediaType.APPLICATION_JSON) User getCurrentUser(); @GET @Path("/users/{userId}") @Produces(MediaType.APPLICATION_JSON) User getUser(@PathParam("userId") long userId); @DELETE @Path("/users/{userId}") Response deleteUser(@PathParam("userId") long userId); @POST @Path("/users/{userId}/impersonate") Response impersonateUser(@PathParam("userId") long userId); @POST @Path("/stopimpersonation") Response stopImpersonation(); @POST @Path("/logout") Response logoutCurrentUser();  }
@Test public void testGetCurrentUser() throws Exception { User user = userService.getCurrentUser(); assertNotNull(user); assertEquals(user.getUserId(), simpleUser.getUserId()); assertNotNull(user.getImageLink()); assertFalse(user.getImageLink().contains(("%"))); }
@Test public void testUserIdChange() throws Exception { assertEquals(0, new UserDAO().getCount()); assertEquals(simpleUser.getUserId(), userService.getCurrentUser().getUserId()); assertEquals(1, new UserDAO().getCount()); requestMock = new HttpServletRequestMock(new User(simpleUser.getUserId().toUpperCase(Locale.ENGLISH), simpleUser.getEmail().toUpperCase(Locale.ENGLISH))); userService.request = requestMock; assertEquals(simpleUser.getUserId().toUpperCase(), userService.getCurrentUser().getUserId()); assertEquals(1, new UserDAO().getCount()); }