@Test public void resolveInterfaceTest() { SpecifiersQuestion question = new SpecifiersQuestion(QueryType.INTERFACE); question.setInterfaceSpecifierInput(_iface1.getName()); assertThat( resolveInterface(question, _context).getRows().getData(), equalTo( ImmutableMultiset.of( Row.of( COL_INTERFACE, NodeInterfacePair.of(_c1.getHostname(), _iface1.getName()))))); question.setNodeSpecifierInput("foofoo"); assertThat( resolveInterface(question, _context).getRows().getData(), equalTo(ImmutableMultiset.of())); }
@VisibleForTesting static TableAnswerElement resolveInterface( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_INTERFACE, Schema.INTERFACE, "Interface", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); InterfaceSpecifier interfaceSpecifier = question.getInterfaceSpecifier(); Set<String> nodes = question.getNodeSpecifier().resolve(context); interfaceSpecifier .resolve(nodes, context) .forEach(iface -> table.addRow(Row.of(columnMap, COL_INTERFACE, iface))); return table; }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveInterface( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_INTERFACE, Schema.INTERFACE, "Interface", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); InterfaceSpecifier interfaceSpecifier = question.getInterfaceSpecifier(); Set<String> nodes = question.getNodeSpecifier().resolve(context); interfaceSpecifier .resolve(nodes, context) .forEach(iface -> table.addRow(Row.of(columnMap, COL_INTERFACE, iface))); return table; } }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveInterface( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_INTERFACE, Schema.INTERFACE, "Interface", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); InterfaceSpecifier interfaceSpecifier = question.getInterfaceSpecifier(); Set<String> nodes = question.getNodeSpecifier().resolve(context); interfaceSpecifier .resolve(nodes, context) .forEach(iface -> table.addRow(Row.of(columnMap, COL_INTERFACE, iface))); return table; } SpecifiersAnswerer(Question question, IBatfish batfish); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveInterface( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_INTERFACE, Schema.INTERFACE, "Interface", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); InterfaceSpecifier interfaceSpecifier = question.getInterfaceSpecifier(); Set<String> nodes = question.getNodeSpecifier().resolve(context); interfaceSpecifier .resolve(nodes, context) .forEach(iface -> table.addRow(Row.of(columnMap, COL_INTERFACE, iface))); return table; } SpecifiersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
SpecifiersAnswerer extends Answerer { @VisibleForTesting static TableAnswerElement resolveInterface( SpecifiersQuestion question, SpecifierContext context) { List<ColumnMetadata> columns = ImmutableList.of( new ColumnMetadata(COL_INTERFACE, Schema.INTERFACE, "Interface", false, false)); TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns)); Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap(); InterfaceSpecifier interfaceSpecifier = question.getInterfaceSpecifier(); Set<String> nodes = question.getNodeSpecifier().resolve(context); interfaceSpecifier .resolve(nodes, context) .forEach(iface -> table.addRow(Row.of(columnMap, COL_INTERFACE, iface))); 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; }