@Nonnull public EigrpEdge reverse() { return new EigrpEdge(_node2, _node1); }
/** Return an {@link EigrpEdge} if there is an EIGRP adjacency on {@code edge}. */ @Nonnull static Optional<EigrpEdge> edgeIfAdjacent(Edge edge, Map<String, Configuration> configurations) { // vertex1 Configuration c1 = configurations.get(edge.getNode1()); Interface iface1 = c1.getAllInterfaces().get(edge.getInt1()); EigrpInterfaceSettings eigrp1 = iface1.getEigrp(); // vertex2 Configuration c2 = configurations.get(edge.getNode2()); Interface iface2 = c2.getAllInterfaces().get(edge.getInt2()); EigrpInterfaceSettings eigrp2 = iface2.getEigrp(); if (eigrp1 == null || eigrp2 == null || !eigrp1.getEnabled() || !eigrp2.getEnabled() || eigrp1.getAsn() != eigrp2.getAsn() || eigrp1.getPassive() || eigrp2.getPassive()) { return empty(); } return Optional.of( new EigrpEdge( new EigrpInterface(c1.getHostname(), iface1), new EigrpInterface(c2.getHostname(), iface2))); }
@Test public void testEigrpToRow() { EigrpEdge testEdge = new EigrpEdge( new EigrpInterface("host1", "int1", "vrf1"), new EigrpInterface("host2", "int2", "vrf2")); Row row = eigrpEdgeToRow(testEdge); assertThat( row, allOf( hasColumn( COL_INTERFACE, equalTo(new NodeInterfacePair("host1", "int1")), Schema.INTERFACE), hasColumn( COL_REMOTE_INTERFACE, equalTo(new NodeInterfacePair("host2", "int2")), Schema.INTERFACE))); }
@Test public void testGetEigrpEdges() { MutableNetwork<EigrpInterface, EigrpEdge> eigrpTopology = NetworkBuilder.directed().allowsParallelEdges(false).allowsSelfLoops(false).build(); EigrpInterface eigrpInterface1 = new EigrpInterface("host1", "int1", "vrf1"); EigrpInterface eigrpInterface2 = new EigrpInterface("host2", "int2", "vrf2"); eigrpTopology.addEdge( eigrpInterface1, eigrpInterface2, new EigrpEdge(eigrpInterface1, eigrpInterface2)); Multiset<Row> rows = getEigrpEdges(_includeNodes, _includeRemoteNodes, eigrpTopology); assertThat( rows, contains( allOf( hasColumn( COL_INTERFACE, equalTo(new NodeInterfacePair("host1", "int1")), Schema.INTERFACE), hasColumn( COL_REMOTE_INTERFACE, equalTo(new NodeInterfacePair("host2", "int2")), Schema.INTERFACE)))); }