### Question:
UserDAO { @RequiresSession public UserEntity findUserByName(String userName) { TypedQuery<UserEntity> query = entityManagerProvider.get().createNamedQuery("userByName", UserEntity.class); query.setParameter("username", userName.toLowerCase()); try { return query.getSingleResult(); } catch (NoResultException e) { return null; } }  @RequiresSession UserEntity findByPK(Integer userPK); @RequiresSession List<UserEntity> findAll(); @RequiresSession UserEntity findUserByName(String userName); @RequiresSession List<UserEntity> findUsersByPrincipal(List<PrincipalEntity> principalList); @RequiresSession UserEntity findUserByPrincipal(PrincipalEntity principal); @Transactional void create(UserEntity user); @Transactional void create(Set<UserEntity> users); @Transactional UserEntity merge(UserEntity user); @Transactional void merge(Set<UserEntity> users); @Transactional void remove(UserEntity user); @Transactional void remove(Set<UserEntity> users); @Transactional void removeByPK(Integer userPK);  }### Answer:
@Test public void testUserByName() { init(user()); assertEquals(SERVICEOP_USER_NAME, userDAO.findUserByName(SERVICEOP_USER_NAME).getUserName()); }