DatastoreService implements IDatastoreService { @Override @Transactional public void addDatastores(DatastoreAdd datastore) { addDatastoreEntity(datastore.getType(), datastore.getSpec(), datastore.getName(), datastore.getRegex()); }  IDatastoreDAO getDsDao(); @Autowired void setDsDao(IDatastoreDAO dsDao); IClusterDAO getClusterDao(); @Autowired void setClusterDao(IClusterDAO clusterDao); IResourceService getResService(); @Autowired void setResService(IResourceService resManager); @Override @Transactional(readOnly = true) Set<String> getAllSharedDatastores(); @Override @Transactional(readOnly = true) Set<String> getSharedDatastoresByNames(List<String> nameList); @Override @Transactional(readOnly = true) Set<String> getLocalDatastoresByNames(List<String> nameList); @Override @Transactional(readOnly = true) Set<String> getAllLocalDatastores(); @Override @Transactional(readOnly = true) Set<String> getDatastoresByName(String name); @Override @Transactional(readOnly = true) Set<String> getDatastoresByNames(List<String> nameList); @Override @Transactional void addDatastores(DatastoreAdd datastore); @Override @Transactional void addDatastores(String name, DatastoreType type, List<String> spec, boolean regex); @Override @Transactional(readOnly = true) Set<String> getAllDatastoreNames(); @Override @Transactional(readOnly = true) DatastoreRead getDatastoreRead(String name); @Override @Transactional(readOnly = true) List<DatastoreRead> getAllDatastoreReads(); @Override @Transactional void deleteDatastore(String name);  }
@Test(groups = { "res-mgmt" }) public void testAddDataStores() { new NonStrictExpectations() { { dsDao.nameExisted(anyString); result = false; resService.isDatastoreExistInVC(anyString); result = true; } }; datastoreSvc.setDsDao(dsDao); datastoreSvc.setResService(resService); List<String> dsSpec = new ArrayList<String>(); dsSpec.add("datastore"); datastoreSvc.addDatastores("testDS", DatastoreType.SHARED, dsSpec, false); new Verifications() { { VcDatastoreEntity entity = new VcDatastoreEntity(); dsDao.insert(withAny(entity)); } }; }