CreateVPCOfferingCmd extends BaseAsyncCreateCmd { public Map<String, List<String>> getServiceProviders() { Map<String, List<String>> serviceProviderMap = null; if (serviceProviderList != null && !serviceProviderList.isEmpty()) { serviceProviderMap = new HashMap<String, List<String>>(); Collection<? extends Map<String, String>> servicesCollection = serviceProviderList.values(); Iterator<? extends Map<String, String>> iter = servicesCollection.iterator(); while (iter.hasNext()) { Map<String, String> obj = iter.next(); if (s_logger.isTraceEnabled()) { s_logger.trace("service provider entry specified: " + obj); } HashMap<String, String> services = (HashMap<String, String>)obj; String service = services.get("service"); String provider = services.get("provider"); List<String> providerList = null; if (serviceProviderMap.containsKey(service)) { providerList = serviceProviderMap.get(service); } else { providerList = new ArrayList<String>(); } providerList.add(provider); serviceProviderMap.put(service, providerList); } } return serviceProviderMap; }  String getVpcOfferingName(); String getDisplayText(); List<String> getSupportedServices(); Map<String, List<String>> getServiceProviders(); Map<String, List<String>> getServiceCapabilitystList(); Long getServiceOfferingId(); @Override void create(); @Override void execute(); @Override String getEventType(); @Override String getEventDescription(); @Override String getCommandName(); @Override long getEntityOwnerId(); static final Logger s_logger; }
@Test public void testServiceProviders() throws IllegalArgumentException, IllegalAccessException { CreateVPCOfferingCmd cmd = new CreateVPCOfferingCmd(); HashMap<String, Map<String, String>> providers = new HashMap<String, Map<String, String>>(); HashMap<String, String> kv = new HashMap<String, String>(); kv.put("service", "TEST-SERVICE"); kv.put("provider", "TEST-PROVIDER"); providers.put("does not matter", kv); ApiCmdTestUtil.set(cmd, ApiConstants.SERVICE_PROVIDER_LIST, providers); Map<String, List<String>> providerMap = cmd.getServiceProviders(); Assert.assertNotNull(providerMap); Assert.assertEquals(1, providerMap.size()); Assert.assertTrue(providerMap.containsKey("TEST-SERVICE")); Assert.assertTrue(providerMap.get("TEST-SERVICE").contains("TEST-PROVIDER")); }
@Test public void testServiceProvidersEmpty() throws IllegalArgumentException, IllegalAccessException { CreateVPCOfferingCmd cmd = new CreateVPCOfferingCmd(); ApiCmdTestUtil.set(cmd, ApiConstants.SERVICE_PROVIDER_LIST, new HashMap<String, Map<String, String>>()); Assert.assertNull(cmd.getServiceProviders()); }
@Test public void getDetailsNull() throws IllegalArgumentException, IllegalAccessException { CreateVPCOfferingCmd cmd = new CreateVPCOfferingCmd(); ApiCmdTestUtil.set(cmd, ApiConstants.SERVICE_PROVIDER_LIST, null); Assert.assertNull(cmd.getServiceProviders()); }