@Test public void testAddressGroupDisplayString() { Configuration cfg = new Configuration("host", ConfigurationFormat.CISCO_IOS); Configuration cfgHuman = new Configuration("host", ConfigurationFormat.CISCO_IOS); cfgHuman.setHumanName("human"); String bookName = GeneratedRefBookUtils.getName(cfg.getHostname(), BookType.PublicIps); assertThat(addressGroupDisplayString(cfg, bookName, "group"), equalTo("host public IP")); assertThat( addressGroupDisplayString(cfgHuman, bookName, "group"), equalTo("host public IP (human)")); }
@VisibleForTesting static String addressGroupDisplayString( Configuration configuration, String bookName, String groupName) { String suffix = configuration.getHumanName() == null ? "" : String.format(" (%s)", configuration.getHumanName()); if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PoolAddresses))) { return String.format( "Pool address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.VirtualAddresses))) { return String.format( "Virtual address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PublicIps))) { return String.format("%s public IP%s", configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.AwsSeviceIps))) { return groupName; } return String.format( "%s in %s on %s%s", groupName, bookName, configuration.getHostname(), suffix); }
CompletionMetadataUtils { @VisibleForTesting static String addressGroupDisplayString( Configuration configuration, String bookName, String groupName) { String suffix = configuration.getHumanName() == null ? "" : String.format(" (%s)", configuration.getHumanName()); if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PoolAddresses))) { return String.format( "Pool address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.VirtualAddresses))) { return String.format( "Virtual address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PublicIps))) { return String.format("%s public IP%s", configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.AwsSeviceIps))) { return groupName; } return String.format( "%s in %s on %s%s", groupName, bookName, configuration.getHostname(), suffix); } }
CompletionMetadataUtils { @VisibleForTesting static String addressGroupDisplayString( Configuration configuration, String bookName, String groupName) { String suffix = configuration.getHumanName() == null ? "" : String.format(" (%s)", configuration.getHumanName()); if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PoolAddresses))) { return String.format( "Pool address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.VirtualAddresses))) { return String.format( "Virtual address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PublicIps))) { return String.format("%s public IP%s", configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.AwsSeviceIps))) { return groupName; } return String.format( "%s in %s on %s%s", groupName, bookName, configuration.getHostname(), suffix); } private  CompletionMetadataUtils(); }
CompletionMetadataUtils { @VisibleForTesting static String addressGroupDisplayString( Configuration configuration, String bookName, String groupName) { String suffix = configuration.getHumanName() == null ? "" : String.format(" (%s)", configuration.getHumanName()); if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PoolAddresses))) { return String.format( "Pool address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.VirtualAddresses))) { return String.format( "Virtual address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PublicIps))) { return String.format("%s public IP%s", configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.AwsSeviceIps))) { return groupName; } return String.format( "%s in %s on %s%s", groupName, bookName, configuration.getHostname(), suffix); } 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 { @VisibleForTesting static String addressGroupDisplayString( Configuration configuration, String bookName, String groupName) { String suffix = configuration.getHumanName() == null ? "" : String.format(" (%s)", configuration.getHumanName()); if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PoolAddresses))) { return String.format( "Pool address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.VirtualAddresses))) { return String.format( "Virtual address %s on %s%s", groupName, configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.PublicIps))) { return String.format("%s public IP%s", configuration.getHostname(), suffix); } if (bookName.equals( GeneratedRefBookUtils.getName(configuration.getHostname(), BookType.AwsSeviceIps))) { return groupName; } return String.format( "%s in %s on %s%s", groupName, bookName, configuration.getHostname(), suffix); } 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; }