ResourcePoolService implements IResourcePoolService { @Override @Transactional public synchronized void deleteResourcePool(final String rpName) { logger.debug("delete resource pool " + rpName); VcResourcePoolEntity entity = rpDao.findByName(rpName); if (entity == null) { throw VcProviderException.RESOURCE_POOL_NOT_FOUND(rpName); } List<String> clusterNames = getClusterDao().findClustersByUsedResourcePool(rpName); if (!clusterNames.isEmpty()) { logger.error("cannot remove resource pool, since following clusters referenced it: " + clusterNames); throw VcProviderException .RESOURCE_POOL_IS_REFERENCED_BY_CLUSTER(clusterNames); } rpDao.delete(entity); logger.debug("successfully deleted resource pool " + rpName); }  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 testDeleteResourcePool() { new Expectations() { { VcResourcePoolEntity rpEntity = new VcResourcePoolEntity(); rpEntity.setName("defaultRP"); rpEntity.setVcCluster("cluster-ws"); rpEntity.setVcResourcePool("jarred"); rpDao.findByName(anyString); returns(rpEntity); clusterDao.findClustersByUsedResourcePool(anyString); result = new ArrayList<String>(); } }; rpSvc.setRpDao(rpDao); rpSvc.setClusterDao(clusterDao); rpSvc.deleteResourcePool("testRP"); }