DatastoreService implements IDatastoreService { @Override @Transactional(readOnly = true) public List<DatastoreRead> getAllDatastoreReads() { logger.debug("get all datastores."); List<VcDatastoreEntity> entities = dsDao.findAllSortByName(); List<DatastoreRead> result = new ArrayList<DatastoreRead>(); if (entities.isEmpty()) { return result; } DatastoreRead read = new DatastoreRead(); read.setName(entities.get(0).getName()); read.setType(entities.get(0).getType()); read.setRegexByBoolean(entities.get(0).getRegex()); read.setDatastoreReadDetails(new ArrayList<DatastoreReadDetail>()); result.add(read); for (VcDatastoreEntity entity : entities) { if (!entity.getName().equals(read.getName())) { read = new DatastoreRead(); read.setName(entity.getName()); read.setType(entity.getType()); read.setRegexByBoolean(entity.getRegex()); read.setDatastoreReadDetails(new ArrayList<DatastoreReadDetail>()); result.add(read); } DatastoreReadDetail detail = new DatastoreReadDetail(); detail.setVcDatastoreName(entity.getVcDatastore()); read.getDatastoreReadDetails().add(detail); } logger.debug("found datastores: " + result); return result; }  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 testGetAllDatastoreReads() { new Expectations() { { dsDao.findByName(anyString); result = dss; } }; datastoreSvc.setDsDao(dsDao); DatastoreRead ds = datastoreSvc.getDatastoreRead("testDS"); Assert.assertNotNull(ds); }