@Test public void resolveLocationTest() { SpecifiersQuestion question = new SpecifiersQuestion(QueryType.LOCATION); question.setLocationSpecifierInput(_c1.getHostname()); assertThat( resolveLocation(question, _context).getRows().getData(), equalTo( ImmutableMultiset.of( Row.of( COL_LOCATION, new InterfaceLocation(_c1.getHostname(), _iface1.getName()).toString())))); }
@VisibleForTesting static TableAnswerElement resolveLocation(SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata(COL_LOCATION, Schema.STRING, "Location", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); for (Location location : locations) { table.addRow(Row.of(columnMap, COL_LOCATION, location.toString())); } return table; }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveLocation(SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata(COL_LOCATION, Schema.STRING, "Location", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); for (Location location : locations) { table.addRow(Row.of(columnMap, COL_LOCATION, location.toString())); } return table; } }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveLocation(SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata(COL_LOCATION, Schema.STRING, "Location", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); for (Location location : locations) { table.addRow(Row.of(columnMap, COL_LOCATION, location.toString())); } return table; } SpecifiersAnswerer(Question question, IBatfish batfish); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveLocation(SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata(COL_LOCATION, Schema.STRING, "Location", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); for (Location location : locations) { table.addRow(Row.of(columnMap, COL_LOCATION, location.toString())); } return table; } SpecifiersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveLocation(SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of(new ColumnMetadata(COL_LOCATION, Schema.STRING, "Location", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); Set<Location> locations = question.getLocationSpecifier().resolve(context); for (Location location : locations) { table.addRow(Row.of(columnMap, COL_LOCATION, location.toString())); } 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; }