@Test public void resolveIpSpaceOfLocationTest() { SpecifiersQuestion questionWithLocation = new SpecifiersQuestion(QueryType.IP_SPACE_OF_LOCATION); questionWithLocation.setLocationSpecifierInput(_c1.getHostname()); assertThat( resolveIpSpaceOfLocation(questionWithLocation, _context).getRows().getData(), equalTo( ImmutableMultiset.of( Row.of( COL_LOCATIONS, ImmutableSet.of(new InterfaceLocation(_c1.getHostname(), _iface1.getName())) .toString(), COL_IP_SPACE, _iface1.getConcreteAddress().getIp().toIpSpace().toString())))); }
@VisibleForTesting static TableAnswerElement resolveIpSpaceOfLocation( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false), new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); IpSpaceAssignment ipSpaceAssignment = question.getIpSpaceSpecifier().resolve(locations, context); for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) { table.addRow( Row.of( columnMap, COL_LOCATIONS, entry.getLocations().toString(), COL_IP_SPACE, Objects.toString(entry.getIpSpace()))); } return table; }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveIpSpaceOfLocation( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false), new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); IpSpaceAssignment ipSpaceAssignment = question.getIpSpaceSpecifier().resolve(locations, context); for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) { table.addRow( Row.of( columnMap, COL_LOCATIONS, entry.getLocations().toString(), COL_IP_SPACE, Objects.toString(entry.getIpSpace()))); } return table; } }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveIpSpaceOfLocation( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false), new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); IpSpaceAssignment ipSpaceAssignment = question.getIpSpaceSpecifier().resolve(locations, context); for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) { table.addRow( Row.of( columnMap, COL_LOCATIONS, entry.getLocations().toString(), COL_IP_SPACE, Objects.toString(entry.getIpSpace()))); } return table; } SpecifiersAnswerer(Question question, IBatfish batfish); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveIpSpaceOfLocation( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false), new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); IpSpaceAssignment ipSpaceAssignment = question.getIpSpaceSpecifier().resolve(locations, context); for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) { table.addRow( Row.of( columnMap, COL_LOCATIONS, entry.getLocations().toString(), COL_IP_SPACE, Objects.toString(entry.getIpSpace()))); } return table; } SpecifiersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveIpSpaceOfLocation( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false), new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); IpSpaceAssignment ipSpaceAssignment = question.getIpSpaceSpecifier().resolve(locations, context); for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) { table.addRow( Row.of( columnMap, COL_LOCATIONS, entry.getLocations().toString(), COL_IP_SPACE, Objects.toString(entry.getIpSpace()))); } return table; } SpecifiersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static final String COL_FILTER_NAME; static final String COL_INTERFACE; static final String COL_IP_SPACE; static final String COL_LOCATION; static final String COL_LOCATIONS; static final String COL_NODE; }