@Test public void testGetLayer1Edges() { Layer1Node layer1Node1 = new Layer1Node("host1", "int1"); Layer1Node layer1Node2 = new Layer1Node("host2", "int2"); Multiset<Row> rows = getLayer1Edges( _includeNodes, _includeRemoteNodes, new Layer1Topology(ImmutableSortedSet.of(new Layer1Edge(layer1Node1, layer1Node2)))); assertThat( rows, contains( allOf( hasColumn( COL_INTERFACE, equalTo(NodeInterfacePair.of("host1", "int1")), Schema.INTERFACE), hasColumn( COL_REMOTE_INTERFACE, equalTo(NodeInterfacePair.of("host2", "int2")), Schema.INTERFACE)))); }
@VisibleForTesting static Multiset<Row> getLayer1Edges( Set<String> includeNodes, Set<String> includeRemoteNodes, @Nullable Layer1Topology layer1Topology) { if (layer1Topology == null) { return HashMultiset.create(); } return layer1Topology.getGraph().edges().stream() .filter( layer1Edge -> includeNodes.contains(layer1Edge.getNode1().getHostname()) && includeRemoteNodes.contains(layer1Edge.getNode2().getHostname())) .map(EdgesAnswerer::layer1EdgeToRow) .collect(Collectors.toCollection(HashMultiset::create)); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getLayer1Edges( Set<String> includeNodes, Set<String> includeRemoteNodes, @Nullable Layer1Topology layer1Topology) { if (layer1Topology == null) { return HashMultiset.create(); } return layer1Topology.getGraph().edges().stream() .filter( layer1Edge -> includeNodes.contains(layer1Edge.getNode1().getHostname()) && includeRemoteNodes.contains(layer1Edge.getNode2().getHostname())) .map(EdgesAnswerer::layer1EdgeToRow) .collect(Collectors.toCollection(HashMultiset::create)); } }
EdgesAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getLayer1Edges( Set<String> includeNodes, Set<String> includeRemoteNodes, @Nullable Layer1Topology layer1Topology) { if (layer1Topology == null) { return HashMultiset.create(); } return layer1Topology.getGraph().edges().stream() .filter( layer1Edge -> includeNodes.contains(layer1Edge.getNode1().getHostname()) && includeRemoteNodes.contains(layer1Edge.getNode2().getHostname())) .map(EdgesAnswerer::layer1EdgeToRow) .collect(Collectors.toCollection(HashMultiset::create)); } EdgesAnswerer(Question question, IBatfish batfish); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getLayer1Edges( Set<String> includeNodes, Set<String> includeRemoteNodes, @Nullable Layer1Topology layer1Topology) { if (layer1Topology == null) { return HashMultiset.create(); } return layer1Topology.getGraph().edges().stream() .filter( layer1Edge -> includeNodes.contains(layer1Edge.getNode1().getHostname()) && includeRemoteNodes.contains(layer1Edge.getNode2().getHostname())) .map(EdgesAnswerer::layer1EdgeToRow) .collect(Collectors.toCollection(HashMultiset::create)); } EdgesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
EdgesAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> getLayer1Edges( Set<String> includeNodes, Set<String> includeRemoteNodes, @Nullable Layer1Topology layer1Topology) { if (layer1Topology == null) { return HashMultiset.create(); } return layer1Topology.getGraph().edges().stream() .filter( layer1Edge -> includeNodes.contains(layer1Edge.getNode1().getHostname()) && includeRemoteNodes.contains(layer1Edge.getNode2().getHostname())) .map(EdgesAnswerer::layer1EdgeToRow) .collect(Collectors.toCollection(HashMultiset::create)); } EdgesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }