@Test public void testMatchesAllPrefixesWithoutSpecifying() { Multiset<Row> answer = getRows(_prefixTracingInfo, null, _prefixTracingInfo.keySet()); assertThat(answer, hasSize(3)); }
@VisibleForTesting static Multiset<Row> getRows( SortedMap<String, SortedMap<String, Map<Prefix, Map<String, Set<String>>>>> prefixTracingInfo, @Nullable Prefix desiredPrefix, @Nonnull Set<String> nodes) { HashMultiset<Row> rows = HashMultiset.create(); prefixTracingInfo.keySet().stream() .filter(nodes::contains) .forEach( node -> { SortedMap<String, Map<Prefix, Map<String, Set<String>>>> vrfs = prefixTracingInfo.get(node); vrfs.forEach( (vrf, prefixes) -> prefixes.forEach( (prefix, actions) -> { if (desiredPrefix == null || prefix.equals(desiredPrefix)) { actions.forEach( (action, neighbors) -> neighbors.forEach( neighbor -> rows.add( Row.builder() .put(COL_NODE, new Node(node)) .put(COL_VRF, vrf) .put(COL_PEER, new Node(neighbor)) .put(COL_ACTION, action) .put(COL_PREFIX, prefix) .build()))); } })); }); return rows; }
PrefixTracerAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( SortedMap<String, SortedMap<String, Map<Prefix, Map<String, Set<String>>>>> prefixTracingInfo, @Nullable Prefix desiredPrefix, @Nonnull Set<String> nodes) { HashMultiset<Row> rows = HashMultiset.create(); prefixTracingInfo.keySet().stream() .filter(nodes::contains) .forEach( node -> { SortedMap<String, Map<Prefix, Map<String, Set<String>>>> vrfs = prefixTracingInfo.get(node); vrfs.forEach( (vrf, prefixes) -> prefixes.forEach( (prefix, actions) -> { if (desiredPrefix == null || prefix.equals(desiredPrefix)) { actions.forEach( (action, neighbors) -> neighbors.forEach( neighbor -> rows.add( Row.builder() .put(COL_NODE, new Node(node)) .put(COL_VRF, vrf) .put(COL_PEER, new Node(neighbor)) .put(COL_ACTION, action) .put(COL_PREFIX, prefix) .build()))); } })); }); return rows; } }
PrefixTracerAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( SortedMap<String, SortedMap<String, Map<Prefix, Map<String, Set<String>>>>> prefixTracingInfo, @Nullable Prefix desiredPrefix, @Nonnull Set<String> nodes) { HashMultiset<Row> rows = HashMultiset.create(); prefixTracingInfo.keySet().stream() .filter(nodes::contains) .forEach( node -> { SortedMap<String, Map<Prefix, Map<String, Set<String>>>> vrfs = prefixTracingInfo.get(node); vrfs.forEach( (vrf, prefixes) -> prefixes.forEach( (prefix, actions) -> { if (desiredPrefix == null || prefix.equals(desiredPrefix)) { actions.forEach( (action, neighbors) -> neighbors.forEach( neighbor -> rows.add( Row.builder() .put(COL_NODE, new Node(node)) .put(COL_VRF, vrf) .put(COL_PEER, new Node(neighbor)) .put(COL_ACTION, action) .put(COL_PREFIX, prefix) .build()))); } })); }); return rows; } PrefixTracerAnswerer(Question question, IBatfish batfish); }
PrefixTracerAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( SortedMap<String, SortedMap<String, Map<Prefix, Map<String, Set<String>>>>> prefixTracingInfo, @Nullable Prefix desiredPrefix, @Nonnull Set<String> nodes) { HashMultiset<Row> rows = HashMultiset.create(); prefixTracingInfo.keySet().stream() .filter(nodes::contains) .forEach( node -> { SortedMap<String, Map<Prefix, Map<String, Set<String>>>> vrfs = prefixTracingInfo.get(node); vrfs.forEach( (vrf, prefixes) -> prefixes.forEach( (prefix, actions) -> { if (desiredPrefix == null || prefix.equals(desiredPrefix)) { actions.forEach( (action, neighbors) -> neighbors.forEach( neighbor -> rows.add( Row.builder() .put(COL_NODE, new Node(node)) .put(COL_VRF, vrf) .put(COL_PEER, new Node(neighbor)) .put(COL_ACTION, action) .put(COL_PREFIX, prefix) .build()))); } })); }); return rows; } PrefixTracerAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
PrefixTracerAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getRows( SortedMap<String, SortedMap<String, Map<Prefix, Map<String, Set<String>>>>> prefixTracingInfo, @Nullable Prefix desiredPrefix, @Nonnull Set<String> nodes) { HashMultiset<Row> rows = HashMultiset.create(); prefixTracingInfo.keySet().stream() .filter(nodes::contains) .forEach( node -> { SortedMap<String, Map<Prefix, Map<String, Set<String>>>> vrfs = prefixTracingInfo.get(node); vrfs.forEach( (vrf, prefixes) -> prefixes.forEach( (prefix, actions) -> { if (desiredPrefix == null || prefix.equals(desiredPrefix)) { actions.forEach( (action, neighbors) -> neighbors.forEach( neighbor -> rows.add( Row.builder() .put(COL_NODE, new Node(node)) .put(COL_VRF, vrf) .put(COL_PEER, new Node(neighbor)) .put(COL_ACTION, action) .put(COL_PREFIX, prefix) .build()))); } })); }); return rows; } PrefixTracerAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }