### Question:
UserHandler extends Handler { @Doc("Sign up a user") @GET @Path("/signup") @HandleErrors({ @HandleError(code = 20000, exception = UsernameDuplicateException.class, description = "Username duplicate") }) public User signup( @QueryParam("username") @Required String username, @QueryParam("password") @Required String password, @QueryParam("email") String email ) throws UsernameDuplicateException { JPAQuery query = new JPAQuery(em); QUser quser = QUser.user; User user = query.from(quser).where(quser.username.eq(username)).uniqueResult(quser); if (user != null) { throw new UsernameDuplicateException(username); } user = new User(); user.username = username; user.email = email; String[] result = PasswordEncrypter.encrypt(password); user.password = result[0]; user.salt = result[1]; em.persist(user); return user; }  @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 testSignup() throws Exception { User user = UserHandlerTester.signup("user1", "pass1", null, User.class); assertNotNull(user.id); assertEquals("user1", user.username); assertNull(user.password); }
@Test public void testDuplicateSignup() throws Exception { UserHandlerTester.signup("user2", "pass2", null, User.class); ErrorResult error = UserHandlerTester.signup("user2", "pass3", null, ErrorResult.class); assertEquals(20000, error.code); }