tom | 1a4b995 | 2014-09-16 16:59:57 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.topology; |
| 2 | |
| 3 | import com.google.common.testing.EqualsTester; |
| 4 | import org.junit.Test; |
| 5 | |
| 6 | import static org.junit.Assert.assertEquals; |
| 7 | import static org.onlab.onos.net.DeviceId.deviceId; |
| 8 | import static org.onlab.onos.net.topology.ClusterId.clusterId; |
| 9 | |
| 10 | /** |
| 11 | * Test of the default topology cluster implementation. |
| 12 | */ |
| 13 | public 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 | } |
Yuta HIGUCHI | 4e9c37c | 2014-09-21 14:34:33 -0700 | [diff] [blame] | 38 | } |