Jon Hall
Committed by Jonathan Hart

Fix for [ONOS-3590]

Compare two devices instead of one with itself
Add unit test for root node

Change-Id: If109dd8b05cd77825e182399b321c321865b9786
......@@ -519,7 +519,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
private TopologyVertex findRoot(Set<TopologyVertex> vertexSet) {
TopologyVertex minVertex = null;
for (TopologyVertex vertex : vertexSet) {
if ((minVertex == null) || (minVertex.deviceId()
if ((minVertex == null) || (vertex.deviceId()
.toString().compareTo(minVertex.deviceId().toString()) < 0)) {
minVertex = vertex;
}
......
......@@ -29,9 +29,11 @@ import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.ClusterId;
import org.onosproject.net.topology.DefaultGraphDescription;
import org.onosproject.net.topology.DefaultTopologyVertex;
import org.onosproject.net.topology.GraphDescription;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.TopologyCluster;
import org.onosproject.net.topology.TopologyVertex;
import java.util.Set;
......@@ -53,6 +55,9 @@ public class DefaultTopologyTest {
public static final DeviceId D4 = deviceId("of:4");
public static final DeviceId D5 = deviceId("of:5");
public static final TopologyVertex V1 = new DefaultTopologyVertex(D1);
public static final TopologyVertex V5 = new DefaultTopologyVertex(D5);
public static final PortNumber P1 = portNumber(1);
public static final PortNumber P2 = portNumber(2);
......@@ -62,6 +67,9 @@ public class DefaultTopologyTest {
private DefaultTopology dt;
public static final ClusterId C0 = ClusterId.clusterId(0);
public static final ClusterId C1 = ClusterId.clusterId(1);
@Before
public void setUp() {
long now = System.currentTimeMillis();
......@@ -81,8 +89,9 @@ public class DefaultTopologyTest {
assertEquals("incorrect device count", 5, dt.deviceCount());
assertEquals("incorrect link count", 8, dt.linkCount());
assertEquals("incorrect cluster count", 2, dt.clusterCount());
assertEquals("incorrect broadcast set size", 6,
dt.broadcastSetSize(ClusterId.clusterId(0)));
assertEquals("incorrect broadcast set size", 6, dt.broadcastSetSize(C0));
assertEquals("incorrect root node", V1, dt.getCluster(C0).root());
assertEquals("incorrect root node", V5, dt.getCluster(C1).root());
}
@Test
......