tom

Added more unit tests for a few small things.

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.*;
7 +import static org.onlab.onos.net.topology.ClusterId.clusterId;
8 +
9 +/**
10 + * Test of the cluster ID.
11 + */
12 +public class ClusterIdTest {
13 +
14 + @Test
15 + public void testEquals() {
16 + new EqualsTester()
17 + .addEqualityGroup(clusterId(1), clusterId(1))
18 + .addEqualityGroup(clusterId(3), clusterId(3)).testEquals();
19 + }
20 +
21 + @Test
22 + public void basics() {
23 + assertEquals("incorrect index", 123, clusterId(123).index());
24 + }
25 +
26 +}
...\ No newline at end of file ...\ No newline at end of file
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 + }
38 +}
...\ No newline at end of file ...\ No newline at end of file