@Test public void testThrowsIfNoFiltersMatch() { Configuration c = new NetworkFactory() .configurationBuilder() .setHostname("c") .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .build(); MockBatfish batfish = new MockBatfish(ImmutableSortedMap.of("c", c)); FindMatchingFilterLinesAnswerer answerer = new FindMatchingFilterLinesAnswerer(UNCONSTRAINED_QUESTION, batfish); _thrown.expect(IllegalArgumentException.class); answerer.answer(batfish.getSnapshot()); }
@Override public TableAnswerElement answer(NetworkSnapshot snapshot) { FindMatchingFilterLinesQuestion question = (FindMatchingFilterLinesQuestion) _question; SpecifierContext ctxt = _batfish.specifierContext(snapshot); Multimap<String, String> specifiedAcls = getSpecifiedFilters( ctxt, question.getNodeSpecifier(), question.getFilterSpecifier(), question.getIgnoreComposites()); if (specifiedAcls.values().isEmpty()) { throw new IllegalArgumentException( String.format( "Did not find any filters that meet the specified criteria. (Tips: Set '%s' to false if you want to analyze combined filters; use 'resolveFilterSpecifier' question to see which filters your nodes and filters match.)", PROP_IGNORE_COMPOSITES)); } TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); getRows(question.getHeaderConstraints(), question.getAction(), specifiedAcls, ctxt) .forEach(answer::addRow); return answer; }
FindMatchingFilterLinesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { FindMatchingFilterLinesQuestion question = (FindMatchingFilterLinesQuestion) _question; SpecifierContext ctxt = _batfish.specifierContext(snapshot); Multimap<String, String> specifiedAcls = getSpecifiedFilters( ctxt, question.getNodeSpecifier(), question.getFilterSpecifier(), question.getIgnoreComposites()); if (specifiedAcls.values().isEmpty()) { throw new IllegalArgumentException( String.format( "Did not find any filters that meet the specified criteria. (Tips: Set '%s' to false if you want to analyze combined filters; use 'resolveFilterSpecifier' question to see which filters your nodes and filters match.)", PROP_IGNORE_COMPOSITES)); } TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); getRows(question.getHeaderConstraints(), question.getAction(), specifiedAcls, ctxt) .forEach(answer::addRow); return answer; } }
FindMatchingFilterLinesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { FindMatchingFilterLinesQuestion question = (FindMatchingFilterLinesQuestion) _question; SpecifierContext ctxt = _batfish.specifierContext(snapshot); Multimap<String, String> specifiedAcls = getSpecifiedFilters( ctxt, question.getNodeSpecifier(), question.getFilterSpecifier(), question.getIgnoreComposites()); if (specifiedAcls.values().isEmpty()) { throw new IllegalArgumentException( String.format( "Did not find any filters that meet the specified criteria. (Tips: Set '%s' to false if you want to analyze combined filters; use 'resolveFilterSpecifier' question to see which filters your nodes and filters match.)", PROP_IGNORE_COMPOSITES)); } TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); getRows(question.getHeaderConstraints(), question.getAction(), specifiedAcls, ctxt) .forEach(answer::addRow); return answer; } FindMatchingFilterLinesAnswerer(Question question, IBatfish batfish); }
FindMatchingFilterLinesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { FindMatchingFilterLinesQuestion question = (FindMatchingFilterLinesQuestion) _question; SpecifierContext ctxt = _batfish.specifierContext(snapshot); Multimap<String, String> specifiedAcls = getSpecifiedFilters( ctxt, question.getNodeSpecifier(), question.getFilterSpecifier(), question.getIgnoreComposites()); if (specifiedAcls.values().isEmpty()) { throw new IllegalArgumentException( String.format( "Did not find any filters that meet the specified criteria. (Tips: Set '%s' to false if you want to analyze combined filters; use 'resolveFilterSpecifier' question to see which filters your nodes and filters match.)", PROP_IGNORE_COMPOSITES)); } TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); getRows(question.getHeaderConstraints(), question.getAction(), specifiedAcls, ctxt) .forEach(answer::addRow); return answer; } FindMatchingFilterLinesAnswerer(Question question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); }
FindMatchingFilterLinesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { FindMatchingFilterLinesQuestion question = (FindMatchingFilterLinesQuestion) _question; SpecifierContext ctxt = _batfish.specifierContext(snapshot); Multimap<String, String> specifiedAcls = getSpecifiedFilters( ctxt, question.getNodeSpecifier(), question.getFilterSpecifier(), question.getIgnoreComposites()); if (specifiedAcls.values().isEmpty()) { throw new IllegalArgumentException( String.format( "Did not find any filters that meet the specified criteria. (Tips: Set '%s' to false if you want to analyze combined filters; use 'resolveFilterSpecifier' question to see which filters your nodes and filters match.)", PROP_IGNORE_COMPOSITES)); } TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); getRows(question.getHeaderConstraints(), question.getAction(), specifiedAcls, ctxt) .forEach(answer::addRow); return answer; } FindMatchingFilterLinesAnswerer(Question question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static final String COL_NODE; static final String COL_FILTER; static final String COL_LINE; static final String COL_LINE_INDEX; static final String COL_ACTION; static final List<ColumnMetadata> COLUMN_METADATA; }