@Test public void testGetPrefixesGeneratedReferenceBooks() { ReferenceBook book1 = ReferenceBook.builder("book1") .setAddressGroups( ImmutableList.of( new AddressGroup(ImmutableSortedSet.of("1.1.1.1/1", "2.2.2.2/2"), "ag1"), new AddressGroup(ImmutableSortedSet.of("3.3.3.3", "1.1.1.1:0.0.0.8"), "ag2"))) .build(); ReferenceBook book2 = ReferenceBook.builder("book2") .setAddressGroups( ImmutableList.of( new AddressGroup(ImmutableSortedSet.of("3.3.3.3/3", "4.4.4.4"), "ag1"))) .build(); Map<String, Configuration> configs = new HashMap<>(); Configuration config = createTestConfiguration("node", ConfigurationFormat.HOST); config.getGeneratedReferenceBooks().put(book1.getName(), book1); config.getGeneratedReferenceBooks().put(book2.getName(), book2); configs.put("node", config); assertThat( getPrefixes(configs), equalTo(ImmutableSet.of("1.1.1.1/1", "2.2.2.2/2", "3.3.3.3/3"))); }
public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> { configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllConcreteAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add)); configuration .getGeneratedReferenceBooks() .values() .forEach( book -> book.getAddressGroups() .forEach( ag -> ag.getAddresses() .forEach( a -> Prefix.tryParse(a) .ifPresent(prefix -> prefixes.add(a))))); }); return prefixes.build(); }
CompletionMetadataUtils { public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> { configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllConcreteAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add)); configuration .getGeneratedReferenceBooks() .values() .forEach( book -> book.getAddressGroups() .forEach( ag -> ag.getAddresses() .forEach( a -> Prefix.tryParse(a) .ifPresent(prefix -> prefixes.add(a))))); }); return prefixes.build(); } }
CompletionMetadataUtils { public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> { configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllConcreteAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add)); configuration .getGeneratedReferenceBooks() .values() .forEach( book -> book.getAddressGroups() .forEach( ag -> ag.getAddresses() .forEach( a -> Prefix.tryParse(a) .ifPresent(prefix -> prefixes.add(a))))); }); return prefixes.build(); } private  CompletionMetadataUtils(); }
CompletionMetadataUtils { public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> { configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllConcreteAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add)); configuration .getGeneratedReferenceBooks() .values() .forEach( book -> book.getAddressGroups() .forEach( ag -> ag.getAddresses() .forEach( a -> Prefix.tryParse(a) .ifPresent(prefix -> prefixes.add(a))))); }); return prefixes.build(); } private  CompletionMetadataUtils(); static Set<String> getFilterNames(Map<String, Configuration> configurations); static Set<NodeInterfacePair> getInterfaces(Map<String, Configuration> configurations); static Map<Ip, IpCompletionMetadata> getIps(Map<String, Configuration> configurations); static Set<String> getMlagIds(Map<String, Configuration> configurations); static Map<String, NodeCompletionMetadata> getNodes(
      Map<String, Configuration> configurations); static Set<String> getPrefixes(Map<String, Configuration> configurations); static Set<String> getRoutingPolicyNames(Map<String, Configuration> configurations); static Set<Location> getSourceLocationsWithSrcIps(
      Map<Location, LocationInfo> locationInfo); static Set<String> getStructureNames(Map<String, Configuration> configurations); static Set<String> getVrfs(Map<String, Configuration> configurations); static Set<String> getZones(Map<String, Configuration> configurations); }
CompletionMetadataUtils { public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> { configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllConcreteAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add)); configuration .getGeneratedReferenceBooks() .values() .forEach( book -> book.getAddressGroups() .forEach( ag -> ag.getAddresses() .forEach( a -> Prefix.tryParse(a) .ifPresent(prefix -> prefixes.add(a))))); }); return prefixes.build(); } private  CompletionMetadataUtils(); static Set<String> getFilterNames(Map<String, Configuration> configurations); static Set<NodeInterfacePair> getInterfaces(Map<String, Configuration> configurations); static Map<Ip, IpCompletionMetadata> getIps(Map<String, Configuration> configurations); static Set<String> getMlagIds(Map<String, Configuration> configurations); static Map<String, NodeCompletionMetadata> getNodes(
      Map<String, Configuration> configurations); static Set<String> getPrefixes(Map<String, Configuration> configurations); static Set<String> getRoutingPolicyNames(Map<String, Configuration> configurations); static Set<Location> getSourceLocationsWithSrcIps(
      Map<Location, LocationInfo> locationInfo); static Set<String> getStructureNames(Map<String, Configuration> configurations); static Set<String> getVrfs(Map<String, Configuration> configurations); static Set<String> getZones(Map<String, Configuration> configurations); static Map<Ip, String> WELL_KNOWN_IPS; }