VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService, VpcService { @Override public Map<Service, Set<Provider>> getVpcOffSvcProvidersMap(final long vpcOffId) { final Map<Service, Set<Provider>> serviceProviderMap = new HashMap<>(); final List<VpcOfferingServiceMapVO> map = _vpcOffSvcMapDao.listByVpcOffId(vpcOffId); for (final VpcOfferingServiceMapVO instance : map) { final Service service = Service.getService(instance.getService()); Set<Provider> providers; providers = serviceProviderMap.get(service); if (providers == null) { providers = new HashSet<>(); } providers.add(Provider.getProvider(instance.getProvider())); serviceProviderMap.put(service, providers); } return serviceProviderMap; }  @Override @DB boolean configure(final String name, final Map<String, Object> params); @Override boolean start(); @Override boolean stop(); @Override List<? extends Network> getVpcNetworks(final long vpcId); @Override VpcOffering getVpcOffering(final long vpcOffId); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating vpc offering", create = true) VpcOffering createVpcOffering(final String name, final String displayText,
                                         final List<String> supportedServices, final Map<String, List<String>> serviceProviders,
                                         final Map serviceCapabilitystList, final Long serviceOfferingId); @Override Vpc getActiveVpc(final long vpcId); @Override Map<Service, Set<Provider>> getVpcOffSvcProvidersMap(final long vpcOffId); @Override Pair<List<? extends VpcOffering>, Integer> listVpcOfferings(final Long id, final String name,
                                                                       final String displayText, final List<String> supportedServicesStr,
                                                                       final Boolean isDefault, final String keyword, final String state, final Long startIndex,
                                                                       final Long pageSizeVal); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_DELETE, eventDescription = "deleting vpc offering") boolean deleteVpcOffering(final long offId); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_UPDATE, eventDescription = "updating vpc offering") VpcOffering updateVpcOffering(final long vpcOffId, final String vpcOfferingName, final String displayText,
                                         final String state); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create = true) Vpc createVpc(final long zoneId, final long vpcOffId, final long vpcOwnerId, final String vpcName,
                         final String displayText, final String cidr, String networkDomain,
                         final Boolean displayVpc); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_DELETE, eventDescription = "deleting VPC") boolean deleteVpc(final long vpcId); @Override @DB boolean destroyVpc(final Vpc vpc, final Account caller, final Long callerUserId); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc") Vpc updateVpc(final long vpcId, final String vpcName, final String displayText, final String customId,
                         final Boolean displayVpc); @Override Pair<List<? extends Vpc>, Integer> listVpcs(final Long id, final String vpcName, final String displayText,
                                                       final List<String> supportedServicesStr, final String cidr,
                                                       final Long vpcOffId, final String state, final String accountName, Long domainId, final String keyword,
                                                       final Long startIndex, final Long pageSizeVal,
                                                       final Long zoneId, Boolean isRecursive, final Boolean listAll, final Boolean restartRequired,
                                                       final Map<String, String> tags, final Long projectId,
                                                       final Boolean display); @Override boolean startVpc(final long vpcId, final boolean destroyOnFailure); @Override boolean shutdownVpc(final long vpcId); @DB @Override void validateNtwkOffForNtwkInVpc(final Long networkId, final long newNtwkOffId, final String newCidr,
                                            final String newNetworkDomain, final Vpc vpc,
                                            final String gateway, final Account networkOwner, final Long aclId); @Override void validateNtwkOffForVpc(final NetworkOffering guestNtwkOff, final List<Service> supportedSvcs); List<VpcProvider> getVpcElements(); @Override List<? extends Vpc> getVpcsForAccount(final long accountId); boolean cleanupVpcResources(final long vpcId, final Account caller, final long callerUserId); @Override @ActionEvent(eventType = EventTypes.EVENT_VPC_RESTART, eventDescription = "restarting vpc") boolean restartVpc(final long vpcId, final boolean cleanUp, final boolean makeRedundant); @Override List<PrivateGateway> getVpcPrivateGateways(final long vpcId); @Override PrivateGateway getVpcPrivateGateway(final long id); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "creating VPC private gateway", create = true) PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNetworkId, final String broadcastUri,
                                                  final String ipAddress, final String gateway,
                                                  final String netmask, final long gatewayOwnerId, final Long networkOfferingId, final Boolean isSourceNat,
                                                  final Long aclId); @Override @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_CREATE, eventDescription = "Applying VPC private gateway", async = true) PrivateGateway applyVpcPrivateGateway(final long gatewayId, final boolean destroyOnFailure); @Override @ActionEvent(eventType = EventTypes.EVENT_PRIVATE_GATEWAY_DELETE, eventDescription = "deleting private gateway") @DB boolean deleteVpcPrivateGateway(final long gatewayId); @Override Pair<List<PrivateGateway>, Integer> listPrivateGateway(final ListPrivateGatewaysCmd cmd); @Override StaticRoute getStaticRoute(final long routeId); @Override boolean applyStaticRoutesForVpc(final long vpcId); @Override @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_DELETE, eventDescription = "deleting static route") boolean revokeStaticRoute(final long routeId); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "creating static route", create = true) StaticRoute createStaticRoute(final long vpcId, final String cidr, final String gwIpAddress); @Override Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(final ListStaticRoutesCmd cmd); @DB @Override @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "associating Ip", async = true) IpAddress associateIPToVpc(final long ipId, final long vpcId); @Override void unassignIPFromVpcNetwork(final long ipId, final long networkId); @Override boolean isIpAllocatedToVpc(final IpAddress ip); @DB @Override Network createVpcGuestNetwork(final long ntwkOffId, final String name, final String displayText,
                                         final String gateway, final String cidr, final String vlanId,
                                         String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, final long zoneId,
                                         final ACLType aclType, final Boolean subdomainAccess,
                                         final long vpcId, final Long aclId, final Account caller, final Boolean isDisplayNetworkEnabled); @Override PublicIp assignSourceNatIpAddressToVpc(final Account owner, final Vpc vpc); @Override List<HypervisorType> getSupportedVpcHypervisors(); @Inject void setVpcElements(final List<VpcProvider> vpcElements); @Override @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "Applying static route", async = true) boolean applyStaticRoute(final long routeId); static final String SERVICE; static final String CAPABILITYTYPE; static final String CAPABILITYVALUE; static final String TRUE_VALUE; static final String FALSE_VALUE; }
@Test public void getVpcOffSvcProvidersMapForEmptyServiceTest() { long vpcOffId = 1L; List<VpcOfferingServiceMapVO> list = new ArrayList<VpcOfferingServiceMapVO>(); list.add(mock(VpcOfferingServiceMapVO.class)); when(manager._vpcOffSvcMapDao.listByVpcOffId(vpcOffId)).thenReturn(list); Map<Service, Set<Provider>> map = manager.getVpcOffSvcProvidersMap(vpcOffId); assertNotNull(map); assertEquals(map.size(),1); }