### Question:
UserHandler extends Handler { @Doc("User login. Returns the auth token.") @GET @Path("/login") @HandleErrors({ @HandleError(code = 20001, exception = InvalidatePasswordException.class, description = "invalidate password") }) public TokenResult login( @QueryParam("username") @Required String username, @QueryParam("password") @Required String password ) throws InvalidatePasswordException { QUser quser = QUser.user; User user = new JPAQuery(em).from(quser).where(quser.username.eq(username)).uniqueResult(quser); if (user == null || !user.password.equals(PasswordEncrypter.encrypt(password, user.salt))) { throw new InvalidatePasswordException(); } TokenResult result = new TokenResult(); result.token = TokenStorage.put(user.id, 60 * 60 * 24); return result; }  @Doc("Sign up a user") @GET @Path("/signup") @HandleErrors({ @HandleError(code = 20000, exception = UsernameDuplicateException.class, description = "Username duplicate") }) User signup(
        @QueryParam("username") @Required String username,
        @QueryParam("password") @Required String password,
        @QueryParam("email") String email
    ); @Doc("User login. Returns the auth token.") @GET @Path("/login") @HandleErrors({ @HandleError(code = 20001, exception = InvalidatePasswordException.class, description = "invalidate password") }) TokenResult login(
        @QueryParam("username") @Required String username,
        @QueryParam("password") @Required String password
    ); @Doc("Get the user info") @GET @Path("/info") User info(@LoginUser(required = true) String id); @DBSession public EntityManager em; }### Answer:
@Test public void testLogin() throws Exception { UserHandlerTester.signup("user3", "pass3", null, User.class); UserHandler.TokenResult result = UserHandlerTester.login("user3", "pass3", UserHandler.TokenResult.class); assertNotNull(result.token); }
@Test public void testLoginNoUsername() throws Exception { ErrorResult result = UserHandlerTester.login("user1111", "pass6", ErrorResult.class); assertEquals(20001, result.code); }