### Question:
HostComponentStateDAO { @Transactional public void remove(HostComponentStateEntity hostComponentStateEntity) { entityManagerProvider.get().remove(hostComponentStateEntity); }  @RequiresSession HostComponentStateEntity findById(long id); @RequiresSession List<HostComponentStateEntity> findAll(); @RequiresSession List<HostComponentStateEntity> findByHost(String hostName); @RequiresSession List<HostComponentStateEntity> findByService(String serviceName); @RequiresSession List<HostComponentStateEntity> findByServiceAndComponent(String serviceName, String componentName); @RequiresSession HostComponentStateEntity findByServiceComponentAndHost(String serviceName, String componentName, String hostName); @RequiresSession HostComponentStateEntity findByIndex(Long clusterId, String serviceName,
      String componentName, Long hostId); @Transactional void refresh(HostComponentStateEntity hostComponentStateEntity); @Transactional void create(HostComponentStateEntity hostComponentStateEntity); @Transactional HostComponentStateEntity merge(HostComponentStateEntity hostComponentStateEntity); @Transactional void remove(HostComponentStateEntity hostComponentStateEntity); @RequiresSession List<HostComponentStateEntity> findByServiceAndComponentAndNotVersion(String serviceName,
      String componentName, String version);  }### Answer:
@Test public void testRemove() throws Exception { Provider<EntityManager> entityManagerProvider = createNiceMock(Provider.class); EntityManager entityManager = createNiceMock(EntityManager.class); HostDAO hostDAO = createNiceMock(HostDAO.class); HostEntity hostEntity = createNiceMock(HostEntity.class); HostComponentStateEntity hostComponentStateEntity = createNiceMock(HostComponentStateEntity.class); expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes(); entityManager.remove(hostComponentStateEntity); replay(entityManagerProvider, entityManager, hostDAO, hostEntity, hostComponentStateEntity); HostComponentStateDAO dao = new HostComponentStateDAO(); dao.entityManagerProvider = entityManagerProvider; dao.hostDAO = hostDAO; dao.remove(hostComponentStateEntity); verify(entityManagerProvider, entityManager, hostDAO, hostEntity, hostComponentStateEntity); }