ResourcePoolService implements IResourcePoolService { @Override public synchronized void addResourcePool(String rpName, String vcClusterName, String vcResourcePool) { boolean existed = rpDao.isRPAdded(vcClusterName, vcResourcePool); if (existed) { logger.debug("resource pool " + vcResourcePool + " in cluster " + vcClusterName + " is already existed."); throw VcProviderException .VC_RESOURCE_POOL_ALREADY_ADDED(vcResourcePool); } resService.refreshResourcePool(); if (!resService.isRPExistInVc(vcClusterName, vcResourcePool)) { throw VcProviderException.RESOURCE_POOL_NOT_FOUND(vcResourcePool); } rpDao.addResourcePoolEntity(rpName, vcClusterName, vcResourcePool); }  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 testAddResourcePool() { new Expectations() { { rpDao.isRPAdded(anyString, anyString); result = false; resService.refreshResourcePool(); resService.isRPExistInVc(anyString, anyString); result = true; } }; rpSvc.setRpDao(rpDao); rpSvc.setResService(resService); rpSvc.addResourcePool("testRP", "cluster-ws", "jarred"); new Verifications(){{ rpDao.addResourcePoolEntity("testRP", "cluster-ws", "jarred"); }}; }