ResourceDAO { @RequiresSession public ResourceEntity findById(Long id) { return entityManagerProvider.get().find(ResourceEntity.class, id); }  @RequiresSession ResourceEntity findById(Long id); @RequiresSession ResourceEntity findByResourceTypeId(Integer id); @RequiresSession List<ResourceEntity> findAll(); @Transactional void create(ResourceEntity entity); @Transactional ResourceEntity merge(ResourceEntity entity); ResourceEntity findAmbariResource();  }
@Test public void testFindById() throws Exception { ResourceEntity entity = new ResourceEntity(); expect(entityManager.find(ResourceEntity.class, 99L)).andReturn(entity); replay(entityManager); ResourceDAO dao = new ResourceDAO(); dao.entityManagerProvider = entityManagerProvider; Assert.assertEquals(entity, dao.findById(99L)); }