### Question:
UserDAO extends DefaultDAOBase<Integer, User> { public User getUserByAuth(final String login, final AuthType authType) { Criteria criteria = createCriteria(); criteria.add(sameNick(login)); criteria.add(Restrictions.eq("authType", authType)); return (User) criteria.uniqueResult(); } UserDAO();  UserDAO(final EntityManager entityManager); static Criterion sameEnterprise(final Enterprise enterprise); static Criterion sameId(final Integer userId); static Criterion sameNick(final String nick); static Criterion sameRole(final Role role); Collection<User> findByRole(final Role role); Collection<User> findByEnterprise(final Enterprise enterprise); User findByEnterprise(final Integer userId, final Enterprise enterprise); Collection<User> find(final Enterprise enterprise, final String filter,
        final String orderBy, final boolean desc); Collection<User> find(final Enterprise enterprise, final Role role, final String filter,
        final String orderBy, final boolean desc, final boolean connected, final Integer offset,
        final Integer numResults); boolean existAnyUserWithNick(final String nick); boolean existAnyOtherUserWithNick(final User user, final String nick); User getAbiquoUserByLogin(final String login); User getUserByAuth(final String login, final AuthType authType); static Criterion sameAuthType(final AuthType authType); boolean existAnyUserWithNickAndAuth(final String nick, final AuthType authType); boolean existAnyUserWithRole(final Role role); @SuppressWarnings("rawtypes") boolean isUserAllowedToUseVirtualDatacenter(final String username,
        final String authtype, final String[] privileges, final Integer idVdc); @SuppressWarnings("rawtypes") boolean isUserAllowedToEnterprise(final String username, final String authtype,
        final String[] privileges, final Integer ident);  }### Answer:
@Test public void getUserByAuth() { User user1 = eg().createInstance(User.AuthType.ABIQUO); List<Object> entitiesToPersist = new ArrayList<Object>(); entitiesToPersist.add(user1.getEnterprise()); for (Privilege p : user1.getRole().getPrivileges()) { entitiesToPersist.add(p); } entitiesToPersist.add(user1.getRole()); entitiesToPersist.add(user1); ds().persistAll(entitiesToPersist.toArray()); UserDAO dao = createDaoForRollbackTransaction(); User user = dao.getUserByAuth(user1.getNick(), User.AuthType.ABIQUO); Assert.assertNotNull(user); }