ViewInstanceDAO { @Transactional public ViewInstanceDataEntity mergeData(ViewInstanceDataEntity viewInstanceDataEntity) { return entityManagerProvider.get().merge(viewInstanceDataEntity); }  @RequiresSession ViewInstanceEntity findByName(String viewName, String instanceName); @RequiresSession ViewInstanceEntity findByResourceId(long resourceId); @RequiresSession List<ViewInstanceEntity> findAll(); @RequiresSession ResourceEntity findResourceForViewInstance(String viewName,
      String instanceName); @Transactional void refresh(ViewInstanceEntity viewInstanceEntity); @Transactional void create(ViewInstanceEntity viewInstanceEntity); @Transactional ViewInstanceEntity merge(ViewInstanceEntity viewInstanceEntity); @Transactional void remove(ViewInstanceEntity viewInstanceEntity); @Transactional ViewInstanceDataEntity mergeData(ViewInstanceDataEntity viewInstanceDataEntity); @Transactional void removeData(ViewInstanceDataEntity viewInstanceDataEntity);  }
@Test public void testMergeData() throws Exception { ViewInstanceDataEntity entity = new ViewInstanceDataEntity(); ViewInstanceDataEntity entity2 = new ViewInstanceDataEntity(); expect(entityManager.merge(eq(entity))).andReturn(entity2); replay(entityManager); ViewInstanceDAO dao = new ViewInstanceDAO(); dao.entityManagerProvider = entityManagerProvider; assertSame(entity2, dao.mergeData(entity)); verify(entityManagerProvider, entityManager); }