@Test public void testBuildResolvedPolicy() { IndexedTenant indexedTenant = new IndexedTenant(tenant1_with_eig); ConcurrentMap<TenantId, IndexedTenant> resolvedTenants = new ConcurrentHashMap<>(); resolvedTenants.put(indexedTenant.getTenant().getId(), indexedTenant); Set<IndexedTenant> indexedTenants = resolvedTenants.values().stream().filter(t -> t != null).collect(Collectors.toSet()); Table<EgKey, EgKey, Policy> policyMap = PolicyResolverUtils.resolvePolicy(indexedTenants); List<ResolvedPolicy> resolvedPolicies = PolicyInfoUtils.buildResolvedPolicy(policyMap, resolvedTenants); assertEquals(4, resolvedPolicies.size()); }
public static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap, ConcurrentMap<TenantId, IndexedTenant> resolvedTenants) { List<ResolvedPolicy> resolvedPolicies = new ArrayList<>(); for (Cell<EgKey, EgKey, Policy> policyCell : policyMap.cellSet()) { ResolvedPolicyBuilder resolvedPolicyBuilder = new ResolvedPolicyBuilder(); resolvedPolicyBuilder.setConsumerEpgId(policyCell.getRowKey().getEgId()); resolvedPolicyBuilder.setConsumerTenantId(policyCell.getRowKey().getTenantId()); resolvedPolicyBuilder.setProviderEpgId(policyCell.getColumnKey().getEgId()); resolvedPolicyBuilder.setProviderTenantId(policyCell.getColumnKey().getTenantId()); resolvedPolicyBuilder.setPolicyRuleGroupWithEndpointConstraints( buildPolicyRuleGroupWithEndpointConstraints(policyCell.getValue())); Tenant consTenant = resolvedTenants.get(policyCell.getRowKey().getTenantId()).getTenant(); Tenant provTenant = resolvedTenants.get(policyCell.getColumnKey().getTenantId()).getTenant(); if (isExternalImplicitGroup(consTenant, policyCell.getRowKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ConsumerEpg); } else if (isExternalImplicitGroup(provTenant, policyCell.getColumnKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ProviderEpg); } resolvedPolicies.add(resolvedPolicyBuilder.build()); } return resolvedPolicies; }
PolicyInfoUtils { public static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap, ConcurrentMap<TenantId, IndexedTenant> resolvedTenants) { List<ResolvedPolicy> resolvedPolicies = new ArrayList<>(); for (Cell<EgKey, EgKey, Policy> policyCell : policyMap.cellSet()) { ResolvedPolicyBuilder resolvedPolicyBuilder = new ResolvedPolicyBuilder(); resolvedPolicyBuilder.setConsumerEpgId(policyCell.getRowKey().getEgId()); resolvedPolicyBuilder.setConsumerTenantId(policyCell.getRowKey().getTenantId()); resolvedPolicyBuilder.setProviderEpgId(policyCell.getColumnKey().getEgId()); resolvedPolicyBuilder.setProviderTenantId(policyCell.getColumnKey().getTenantId()); resolvedPolicyBuilder.setPolicyRuleGroupWithEndpointConstraints( buildPolicyRuleGroupWithEndpointConstraints(policyCell.getValue())); Tenant consTenant = resolvedTenants.get(policyCell.getRowKey().getTenantId()).getTenant(); Tenant provTenant = resolvedTenants.get(policyCell.getColumnKey().getTenantId()).getTenant(); if (isExternalImplicitGroup(consTenant, policyCell.getRowKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ConsumerEpg); } else if (isExternalImplicitGroup(provTenant, policyCell.getColumnKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ProviderEpg); } resolvedPolicies.add(resolvedPolicyBuilder.build()); } return resolvedPolicies; } }
PolicyInfoUtils { public static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap, ConcurrentMap<TenantId, IndexedTenant> resolvedTenants) { List<ResolvedPolicy> resolvedPolicies = new ArrayList<>(); for (Cell<EgKey, EgKey, Policy> policyCell : policyMap.cellSet()) { ResolvedPolicyBuilder resolvedPolicyBuilder = new ResolvedPolicyBuilder(); resolvedPolicyBuilder.setConsumerEpgId(policyCell.getRowKey().getEgId()); resolvedPolicyBuilder.setConsumerTenantId(policyCell.getRowKey().getTenantId()); resolvedPolicyBuilder.setProviderEpgId(policyCell.getColumnKey().getEgId()); resolvedPolicyBuilder.setProviderTenantId(policyCell.getColumnKey().getTenantId()); resolvedPolicyBuilder.setPolicyRuleGroupWithEndpointConstraints( buildPolicyRuleGroupWithEndpointConstraints(policyCell.getValue())); Tenant consTenant = resolvedTenants.get(policyCell.getRowKey().getTenantId()).getTenant(); Tenant provTenant = resolvedTenants.get(policyCell.getColumnKey().getTenantId()).getTenant(); if (isExternalImplicitGroup(consTenant, policyCell.getRowKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ConsumerEpg); } else if (isExternalImplicitGroup(provTenant, policyCell.getColumnKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ProviderEpg); } resolvedPolicies.add(resolvedPolicyBuilder.build()); } return resolvedPolicies; } private  PolicyInfoUtils(); }
PolicyInfoUtils { public static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap, ConcurrentMap<TenantId, IndexedTenant> resolvedTenants) { List<ResolvedPolicy> resolvedPolicies = new ArrayList<>(); for (Cell<EgKey, EgKey, Policy> policyCell : policyMap.cellSet()) { ResolvedPolicyBuilder resolvedPolicyBuilder = new ResolvedPolicyBuilder(); resolvedPolicyBuilder.setConsumerEpgId(policyCell.getRowKey().getEgId()); resolvedPolicyBuilder.setConsumerTenantId(policyCell.getRowKey().getTenantId()); resolvedPolicyBuilder.setProviderEpgId(policyCell.getColumnKey().getEgId()); resolvedPolicyBuilder.setProviderTenantId(policyCell.getColumnKey().getTenantId()); resolvedPolicyBuilder.setPolicyRuleGroupWithEndpointConstraints( buildPolicyRuleGroupWithEndpointConstraints(policyCell.getValue())); Tenant consTenant = resolvedTenants.get(policyCell.getRowKey().getTenantId()).getTenant(); Tenant provTenant = resolvedTenants.get(policyCell.getColumnKey().getTenantId()).getTenant(); if (isExternalImplicitGroup(consTenant, policyCell.getRowKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ConsumerEpg); } else if (isExternalImplicitGroup(provTenant, policyCell.getColumnKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ProviderEpg); } resolvedPolicies.add(resolvedPolicyBuilder.build()); } return resolvedPolicies; } private  PolicyInfoUtils(); static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap,
            ConcurrentMap<TenantId, IndexedTenant> resolvedTenants); }
PolicyInfoUtils { public static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap, ConcurrentMap<TenantId, IndexedTenant> resolvedTenants) { List<ResolvedPolicy> resolvedPolicies = new ArrayList<>(); for (Cell<EgKey, EgKey, Policy> policyCell : policyMap.cellSet()) { ResolvedPolicyBuilder resolvedPolicyBuilder = new ResolvedPolicyBuilder(); resolvedPolicyBuilder.setConsumerEpgId(policyCell.getRowKey().getEgId()); resolvedPolicyBuilder.setConsumerTenantId(policyCell.getRowKey().getTenantId()); resolvedPolicyBuilder.setProviderEpgId(policyCell.getColumnKey().getEgId()); resolvedPolicyBuilder.setProviderTenantId(policyCell.getColumnKey().getTenantId()); resolvedPolicyBuilder.setPolicyRuleGroupWithEndpointConstraints( buildPolicyRuleGroupWithEndpointConstraints(policyCell.getValue())); Tenant consTenant = resolvedTenants.get(policyCell.getRowKey().getTenantId()).getTenant(); Tenant provTenant = resolvedTenants.get(policyCell.getColumnKey().getTenantId()).getTenant(); if (isExternalImplicitGroup(consTenant, policyCell.getRowKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ConsumerEpg); } else if (isExternalImplicitGroup(provTenant, policyCell.getColumnKey().getEgId())) { resolvedPolicyBuilder.setExternalImplicitGroup(ExternalImplicitGroup.ProviderEpg); } resolvedPolicies.add(resolvedPolicyBuilder.build()); } return resolvedPolicies; } private  PolicyInfoUtils(); static List<ResolvedPolicy> buildResolvedPolicy(Table<EgKey, EgKey, Policy> policyMap,
            ConcurrentMap<TenantId, IndexedTenant> resolvedTenants);  }