@Test public void testGetPrefixes() { String nodeName = "nodeName"; String int1 = "int1"; String int2 = "int2"; String address1 = "10.1.3.7/30"; String address2 = "128.212.155.30/24"; String address3 = "124.51.32.2/20"; ConcreteInterfaceAddress interfaceAddress1 = ConcreteInterfaceAddress.parse(address1); ConcreteInterfaceAddress interfaceAddress2 = ConcreteInterfaceAddress.parse(address2); ConcreteInterfaceAddress interfaceAddress3 = ConcreteInterfaceAddress.parse(address3); Map<String, Configuration> configs = new HashMap<>(); Configuration config = createTestConfiguration(nodeName, ConfigurationFormat.HOST, int1, int2); config .getAllInterfaces() .get(int1) .setAllAddresses(ImmutableSet.of(interfaceAddress1, interfaceAddress2)); config .getAllInterfaces() .get(int2) .setAllAddresses(ImmutableSet.of(interfaceAddress2, interfaceAddress3)); configs.put(nodeName, config); assertThat( getPrefixes(configs), equalTo( ImmutableSet.of( interfaceAddress1.getPrefix().toString(), interfaceAddress2.getPrefix().toString(), interfaceAddress3.getPrefix().toString()))); }
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; }