@Test public void testRowGenerationDuplicatesOnly() { Multiset<Row> rows = IpOwnersAnswerer.generateRows(_ownersMap, _interfaceMap, true); assertThat(rows, hasSize(2)); for (Row row : rows) { assertThat(row.getIp(COL_IP), equalTo(_duplicateIp)); } }
@VisibleForTesting static Multiset<Row> generateRows( Map<Ip, Set<String>> ipNodeOwners, Map<String, Set<Interface>> interfaces, boolean duplicatesOnly) { Multiset<Row> rows = HashMultiset.create(); interfaces.forEach( (hostname, interfaceSet) -> interfaceSet.forEach( iface -> { iface .getAllConcreteAddresses() .forEach( address -> { if (ipNodeOwners.getOrDefault(address.getIp(), ImmutableSet.of()).size() > 1 || !duplicatesOnly) { rows.add( Row.builder() .put(COL_NODE, new Node(hostname)) .put(COL_VRFNAME, iface.getVrfName()) .put(COL_INTERFACE_NAME, iface.getName()) .put(COL_IP, address.getIp()) .put(COL_MASK, address.getNetworkBits()) .put(COL_ACTIVE, iface.getActive()) .build()); } }); })); return rows; }
IpOwnersAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> generateRows( Map<Ip, Set<String>> ipNodeOwners, Map<String, Set<Interface>> interfaces, boolean duplicatesOnly) { Multiset<Row> rows = HashMultiset.create(); interfaces.forEach( (hostname, interfaceSet) -> interfaceSet.forEach( iface -> { iface .getAllConcreteAddresses() .forEach( address -> { if (ipNodeOwners.getOrDefault(address.getIp(), ImmutableSet.of()).size() > 1 || !duplicatesOnly) { rows.add( Row.builder() .put(COL_NODE, new Node(hostname)) .put(COL_VRFNAME, iface.getVrfName()) .put(COL_INTERFACE_NAME, iface.getName()) .put(COL_IP, address.getIp()) .put(COL_MASK, address.getNetworkBits()) .put(COL_ACTIVE, iface.getActive()) .build()); } }); })); return rows; } }
IpOwnersAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> generateRows( Map<Ip, Set<String>> ipNodeOwners, Map<String, Set<Interface>> interfaces, boolean duplicatesOnly) { Multiset<Row> rows = HashMultiset.create(); interfaces.forEach( (hostname, interfaceSet) -> interfaceSet.forEach( iface -> { iface .getAllConcreteAddresses() .forEach( address -> { if (ipNodeOwners.getOrDefault(address.getIp(), ImmutableSet.of()).size() > 1 || !duplicatesOnly) { rows.add( Row.builder() .put(COL_NODE, new Node(hostname)) .put(COL_VRFNAME, iface.getVrfName()) .put(COL_INTERFACE_NAME, iface.getName()) .put(COL_IP, address.getIp()) .put(COL_MASK, address.getNetworkBits()) .put(COL_ACTIVE, iface.getActive()) .build()); } }); })); return rows; } IpOwnersAnswerer(Question question, IBatfish batfish); }
IpOwnersAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> generateRows( Map<Ip, Set<String>> ipNodeOwners, Map<String, Set<Interface>> interfaces, boolean duplicatesOnly) { Multiset<Row> rows = HashMultiset.create(); interfaces.forEach( (hostname, interfaceSet) -> interfaceSet.forEach( iface -> { iface .getAllConcreteAddresses() .forEach( address -> { if (ipNodeOwners.getOrDefault(address.getIp(), ImmutableSet.of()).size() > 1 || !duplicatesOnly) { rows.add( Row.builder() .put(COL_NODE, new Node(hostname)) .put(COL_VRFNAME, iface.getVrfName()) .put(COL_INTERFACE_NAME, iface.getName()) .put(COL_IP, address.getIp()) .put(COL_MASK, address.getNetworkBits()) .put(COL_ACTIVE, iface.getActive()) .build()); } }); })); return rows; } IpOwnersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); }
IpOwnersAnswerer extends Answerer { @VisibleForTesting static Multiset<Row> generateRows( Map<Ip, Set<String>> ipNodeOwners, Map<String, Set<Interface>> interfaces, boolean duplicatesOnly) { Multiset<Row> rows = HashMultiset.create(); interfaces.forEach( (hostname, interfaceSet) -> interfaceSet.forEach( iface -> { iface .getAllConcreteAddresses() .forEach( address -> { if (ipNodeOwners.getOrDefault(address.getIp(), ImmutableSet.of()).size() > 1 || !duplicatesOnly) { rows.add( Row.builder() .put(COL_NODE, new Node(hostname)) .put(COL_VRFNAME, iface.getVrfName()) .put(COL_INTERFACE_NAME, iface.getName()) .put(COL_IP, address.getIp()) .put(COL_MASK, address.getNetworkBits()) .put(COL_ACTIVE, iface.getActive()) .build()); } }); })); return rows; } IpOwnersAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot);  }