blob: f4c5df6547d53f10b8c07c0a315f619db21a2e28 [file] [log] [blame]
tom1a4b9952014-09-16 16:59:57 -07001package org.onlab.onos.net.topology;
2
3import com.google.common.testing.EqualsTester;
4import org.junit.Test;
5
6import static org.junit.Assert.assertEquals;
7import static org.onlab.onos.net.DeviceId.deviceId;
8import static org.onlab.onos.net.topology.ClusterId.clusterId;
9
10/**
11 * Test of the default topology cluster implementation.
12 */
13public class DefaultTopologyClusterTest {
14
15 @Test
16 public void testEquals() {
17 new EqualsTester()
18 .addEqualityGroup(cluster(3, 2, 1, "of:1"), cluster(3, 2, 1, "of:1"))
19 .addEqualityGroup(cluster(3, 2, 1, "of:2"), cluster(3, 2, 1, "of:2"))
20 .addEqualityGroup(cluster(0, 2, 1, "of:1"), cluster(0, 2, 1, "of:1"))
21 .addEqualityGroup(cluster(3, 3, 1, "of:1"), cluster(3, 3, 1, "of:1"))
22 .testEquals();
23 }
24
25 @Test
26 public void basics() {
27 TopologyCluster cluster = cluster(6, 5, 4, "of:111");
28 assertEquals("incorrect id", clusterId(6), cluster.id());
29 assertEquals("incorrect id", 5, cluster.deviceCount());
30 assertEquals("incorrect id", 4, cluster.linkCount());
31 assertEquals("incorrect id", deviceId("of:111"), cluster.root());
32
33 }
34
35 private TopologyCluster cluster(int id, int dc, int lc, String root) {
36 return new DefaultTopologyCluster(clusterId(id), dc, lc, deviceId(root));
37 }
38}