@Test public void testNoOutputCommunities() { _policyBuilder.setStatements( ImmutableList.of( new SetCommunity(new LiteralCommunity(StandardCommunity.parse("2:40"))), new StaticStatement(Statements.ExitAccept))); RoutingPolicy policy = _policyBuilder.build(); SearchRoutePoliciesQuestion question = new SearchRoutePoliciesQuestion( EMPTY_CONSTRAINTS, BgpRouteConstraints.builder() .setCommunities( new RegexConstraints(ImmutableList.of(new RegexConstraint(".*", true)))) .build(), HOSTNAME, policy.getName(), Action.PERMIT); SearchRoutePoliciesAnswerer answerer = new SearchRoutePoliciesAnswerer(question, _batfish); TableAnswerElement answer = (TableAnswerElement) answerer.answer(_batfish.getSnapshot()); assertEquals(answer.getRows().size(), 0); }
@Override public AnswerElement answer(NetworkSnapshot snapshot) { SpecifierContext context = _batfish.specifierContext(snapshot); Multiset<Row> rows = _nodeSpecifier.resolve(context).stream() .flatMap(node -> searchPoliciesForNode(node, _policySpecifier.resolve(node, context))) .map(SearchRoutePoliciesAnswerer::toRow) .collect(ImmutableMultiset.toImmutableMultiset()); TableAnswerElement answerElement = new TableAnswerElement(metadata()); answerElement.postProcessAnswer(_question, rows); return answerElement; }
SearchRoutePoliciesAnswerer extends Answerer { @Override public AnswerElement answer(NetworkSnapshot snapshot) { SpecifierContext context = _batfish.specifierContext(snapshot); Multiset<Row> rows = _nodeSpecifier.resolve(context).stream() .flatMap(node -> searchPoliciesForNode(node, _policySpecifier.resolve(node, context))) .map(SearchRoutePoliciesAnswerer::toRow) .collect(ImmutableMultiset.toImmutableMultiset()); TableAnswerElement answerElement = new TableAnswerElement(metadata()); answerElement.postProcessAnswer(_question, rows); return answerElement; } }
SearchRoutePoliciesAnswerer extends Answerer { @Override public AnswerElement answer(NetworkSnapshot snapshot) { SpecifierContext context = _batfish.specifierContext(snapshot); Multiset<Row> rows = _nodeSpecifier.resolve(context).stream() .flatMap(node -> searchPoliciesForNode(node, _policySpecifier.resolve(node, context))) .map(SearchRoutePoliciesAnswerer::toRow) .collect(ImmutableMultiset.toImmutableMultiset()); TableAnswerElement answerElement = new TableAnswerElement(metadata()); answerElement.postProcessAnswer(_question, rows); return answerElement; } SearchRoutePoliciesAnswerer(SearchRoutePoliciesQuestion question, IBatfish batfish); }
SearchRoutePoliciesAnswerer extends Answerer { @Override public AnswerElement answer(NetworkSnapshot snapshot) { SpecifierContext context = _batfish.specifierContext(snapshot); Multiset<Row> rows = _nodeSpecifier.resolve(context).stream() .flatMap(node -> searchPoliciesForNode(node, _policySpecifier.resolve(node, context))) .map(SearchRoutePoliciesAnswerer::toRow) .collect(ImmutableMultiset.toImmutableMultiset()); TableAnswerElement answerElement = new TableAnswerElement(metadata()); answerElement.postProcessAnswer(_question, rows); return answerElement; } SearchRoutePoliciesAnswerer(SearchRoutePoliciesQuestion question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static TableMetadata metadata(); }
SearchRoutePoliciesAnswerer extends Answerer { @Override public AnswerElement answer(NetworkSnapshot snapshot) { SpecifierContext context = _batfish.specifierContext(snapshot); Multiset<Row> rows = _nodeSpecifier.resolve(context).stream() .flatMap(node -> searchPoliciesForNode(node, _policySpecifier.resolve(node, context))) .map(SearchRoutePoliciesAnswerer::toRow) .collect(ImmutableMultiset.toImmutableMultiset()); TableAnswerElement answerElement = new TableAnswerElement(metadata()); answerElement.postProcessAnswer(_question, rows); return answerElement; } SearchRoutePoliciesAnswerer(SearchRoutePoliciesQuestion question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static TableMetadata metadata(); static final String COL_NODE; static final String COL_POLICY_NAME; static final String COL_INPUT_ROUTE; static final String COL_ACTION; static final String COL_OUTPUT_ROUTE; static final String COL_DIFF; }