PrincipalTypeDAO { @RequiresSession public PrincipalTypeEntity findById(Integer id) { return entityManagerProvider.get().find(PrincipalTypeEntity.class, id); }  @RequiresSession PrincipalTypeEntity findById(Integer id); @RequiresSession PrincipalTypeEntity findByName(String name); @RequiresSession List<PrincipalTypeEntity> findAll(); @Transactional void create(PrincipalTypeEntity entity); @Transactional PrincipalTypeEntity merge(PrincipalTypeEntity entity); @Transactional void remove(PrincipalTypeEntity entity); @RequiresSession PrincipalTypeEntity ensurePrincipalTypeCreated(int principalType);  }
@Test public void testFindById() throws Exception { PrincipalTypeEntity entity = new PrincipalTypeEntity(); expect(entityManager.find(PrincipalTypeEntity.class, 99)).andReturn(entity); replay(entityManager); PrincipalTypeDAO dao = new PrincipalTypeDAO(); dao.entityManagerProvider = entityManagerProvider; Assert.assertEquals(entity, dao.findById(99)); }