ResourcePoolService implements IResourcePoolService { @Override public List<VcCluster> getVcResourcePoolByNameList(String[] names) { logger.debug("get resource pools by name list " + Arrays.toString(names)); if (names == null || names.length == 0) { return null; } Map<String, VcCluster> clusterMap = new HashMap<String, VcCluster>(); for (String name : names) { VcResourcePoolEntity rpForName = rpDao.findByName(name); if (rpForName == null) { logger.warn("Specified resource pool " + name + ", but the resource pool is removed by others. Continue to use other resource pools."); continue; } combineCluster(clusterMap, rpForName); } if (clusterMap.values().isEmpty()) { throw VcProviderException.NO_RESOURCE_POOL_FOUND(names); } List<VcCluster> result = new ArrayList<VcCluster>(); result.addAll(clusterMap.values()); return result; }  IResourcePoolDAO getRpDao(); @Autowired void setRpDao(IResourcePoolDAO rpDao); IClusterDAO getClusterDao(); @Autowired void setClusterDao(IClusterDAO clusterDao); IResourceService getResService(); @Autowired void setResService(IResourceService resSvc); @Override List<VcCluster> getAllVcResourcePool(); @Override synchronized void addResourcePool(String rpName,
         String vcClusterName, String vcResourcePool); @Override List<VcCluster> getVcResourcePoolByName(String name); @Override List<VcCluster> getVcResourcePoolByNameList(String[] names); @Override Set<String> getAllRPNames(); @Override @Transactional List<ResourcePoolRead> getAllResourcePoolForRest(); @Override @Transactional ResourcePoolRead getResourcePoolForRest(final String rpName); @Override @Transactional synchronized void deleteResourcePool(final String rpName); @Override boolean isDeployedUnderCluster(final String clusterName,
         final String vcRPName); synchronized List<String> addAutoResourcePools(
         List<VcCluster> vcClusters, boolean ignoreDuplicate); @Override synchronized void updateResourcePool(String rpName,
         String vcClusterName, String vcResourcePool);  }
@Test(groups = { "res-mgmt" }) public void testGetVcResourcePoolByNameList() { new Expectations() { { VcResourcePoolEntity rpEntity = new VcResourcePoolEntity(); rpEntity.setName("defaultRP"); rpEntity.setVcCluster("cluster-ws"); rpEntity.setVcResourcePool("jarred"); VcResourcePoolEntity rpEntity2 = new VcResourcePoolEntity(); rpEntity2.setName("defaultRP2"); rpEntity2.setVcCluster("cluster-ws2"); rpEntity2.setVcResourcePool("jarred"); rpDao.findByName(anyString); returns(rpEntity,rpEntity2); } }; rpSvc.setRpDao(rpDao); List<VcCluster> clusters = rpSvc.getVcResourcePoolByNameList(new String[]{"defaultRP","defaultRP2"}); Assert.assertNotNull(clusters); Assert.assertEquals(clusters.size(), 2); }