@Test public void testPruneInterface2() { Topology topo = new Topology(_bothEdges); topo.prune(null, null, ImmutableSet.of(_nip2)); assertThat(topo.getEdges(), equalTo(ImmutableSet.of())); assertThat(topo.getInterfaceEdges(), equalTo(ImmutableMap.of())); assertThat(topo.getNodeEdges(), equalTo(ImmutableMap.of())); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of())); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testPruneNode2() { Topology topo = new Topology(_bothEdges); topo.prune(null, ImmutableSet.of("n2"), null); assertThat(topo.getEdges(), equalTo(ImmutableSet.of())); assertThat(topo.getInterfaceEdges(), equalTo(ImmutableMap.of())); assertThat(topo.getNodeEdges(), equalTo(ImmutableMap.of())); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of())); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testPruneInterface1() { Topology topo = new Topology(_bothEdges); topo.prune(null, null, ImmutableSet.of(_nip1)); assertThat(topo.getEdges(), equalTo(_edge2to3Set)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip2, _edge2to3Set, _nip3, _edge2to3Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n2", _edge2to3Set, "n3", _edge2to3Set))); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of(_nip3))); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testPruneNode1() { Topology topo = new Topology(_bothEdges); topo.prune(null, ImmutableSet.of("n1"), null); assertThat(topo.getEdges(), equalTo(_edge2to3Set)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip2, _edge2to3Set, _nip3, _edge2to3Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n2", _edge2to3Set, "n3", _edge2to3Set))); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of(_nip3))); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testPruneNode3() { Topology topo = new Topology(_bothEdges); topo.prune(null, ImmutableSet.of("n3"), null); assertThat(topo.getEdges(), equalTo(_edge1to2Set)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip1, _edge1to2Set, _nip2, _edge1to2Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n1", _edge1to2Set, "n2", _edge1to2Set))); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of(_nip2))); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of())); }
@Test public void testEmptyTopology() { SortedSet<Edge> edges = ImmutableSortedSet.of(); Topology topo = new Topology(edges); assertThat(topo.getEdges(), equalTo(ImmutableSet.of())); assertThat(topo.getInterfaceEdges(), equalTo(ImmutableMap.of())); assertThat(topo.getNodeEdges(), equalTo(ImmutableMap.of())); assertThat( topo.getNeighbors(new NodeInterfacePair("node", "iface")), equalTo(ImmutableSet.of())); }
SortedSet<Edge> edges = topology.getNodeEdges().get(node); if (edges == null) {
@Test public void testPruneInterface3() { Topology topo = new Topology(_bothEdges); topo.prune(null, null, ImmutableSet.of(_nip3)); assertThat(topo.getEdges(), equalTo(_edge1to2Set)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip1, _edge1to2Set, _nip2, _edge1to2Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n1", _edge1to2Set, "n2", _edge1to2Set))); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of(_nip2))); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of())); } }
@Test public void testTwoEdges() { Topology topo = new Topology(_bothEdges); assertThat(topo.getEdges(), equalTo(_bothEdges)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip1, _edge1to2Set, _nip2, _bothEdges, _nip3, _edge2to3Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n1", _edge1to2Set, "n2", _bothEdges, "n3", _edge2to3Set))); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of(_nip2))); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of(_nip3))); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testPruneEdge() { Topology topo = new Topology(_bothEdges); topo.prune(_edge1to2Set, null, null); assertThat(topo.getEdges(), equalTo(_edge2to3Set)); assertThat( topo.getInterfaceEdges(), equalTo(ImmutableMap.of(_nip2, _edge2to3Set, _nip3, _edge2to3Set))); assertThat( topo.getNodeEdges(), equalTo(ImmutableMap.of("n2", _edge2to3Set, "n3", _edge2to3Set))); assertThat(topo.getNeighbors(_nip1), equalTo(ImmutableSet.of())); assertThat(topo.getNeighbors(_nip2), equalTo(ImmutableSet.of(_nip3))); assertThat(topo.getNeighbors(_nip3), equalTo(ImmutableSet.of())); }
@Test public void testOneEdge() { NodeInterfacePair nip1 = new NodeInterfacePair("n1", "i1"); NodeInterfacePair nip2 = new NodeInterfacePair("n2", "i2"); Edge edge = new Edge(nip1, nip2); SortedSet<Edge> edges = ImmutableSortedSet.of(edge); Topology topo = new Topology(edges); assertThat(topo.getEdges(), equalTo(edges)); assertThat(topo.getInterfaceEdges(), equalTo(ImmutableMap.of(nip1, edges, nip2, edges))); assertThat(topo.getNodeEdges(), equalTo(ImmutableMap.of("n1", edges, "n2", edges))); assertThat(topo.getNeighbors(nip1), equalTo(ImmutableSet.of(nip2))); assertThat(topo.getNeighbors(nip2), equalTo(ImmutableSet.of())); assertThat(topo.getNeighbors(new NodeInterfacePair("x", "y")), equalTo(ImmutableSet.of())); }
SortedSet<Edge> edges = topology.getNodeEdges().get(node); if (edges == null) {
SortedSet<Edge> edges = topology.getNodeEdges().get(node); if (edges == null) {
for (String nodeName : topology.getNodeEdges().keySet()) { Configuration configuration = configurations.get(nodeName); if (configuration == null) { configuration.getAllInterfaces(); for (Edge edge : topology.getNodeEdges().get(nodeName)) { String interface1 = edge.getInt1(); String interface2 = edge.getInt2();