tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.net.topology; |
| 2 | |
| 3 | import com.google.common.testing.EqualsTester; |
| 4 | import org.junit.Test; |
| 5 | import org.onlab.onos.net.ConnectPoint; |
| 6 | import org.onlab.onos.net.DefaultLink; |
| 7 | import org.onlab.onos.net.DeviceId; |
| 8 | import org.onlab.onos.net.Link; |
| 9 | import org.onlab.onos.net.PortNumber; |
| 10 | import org.onlab.onos.net.provider.ProviderId; |
| 11 | |
| 12 | import static org.junit.Assert.assertEquals; |
| 13 | import static org.onlab.onos.net.DeviceId.deviceId; |
| 14 | import static org.onlab.onos.net.PortNumber.portNumber; |
| 15 | |
| 16 | /** |
| 17 | * Tests of the topology graph edge. |
| 18 | */ |
| 19 | public class DefaultTopologyEdgeTest { |
| 20 | |
| 21 | static final DeviceId D1 = deviceId("1"); |
| 22 | static final DeviceId D2 = deviceId("2"); |
| 23 | static final PortNumber P1 = portNumber(1); |
| 24 | static final PortNumber P2 = portNumber(2); |
| 25 | |
| 26 | static final ConnectPoint CP1 = new ConnectPoint(D1, P1); |
| 27 | static final ConnectPoint CP2 = new ConnectPoint(D2, P1); |
| 28 | static final ConnectPoint CP3 = new ConnectPoint(D2, P1); |
| 29 | static final ConnectPoint CP4 = new ConnectPoint(D1, P2); |
| 30 | |
| 31 | static final DefaultTopologyVertex V1 = new DefaultTopologyVertex(D1); |
| 32 | static final DefaultTopologyVertex V2 = new DefaultTopologyVertex(D2); |
| 33 | |
| 34 | static final ProviderId PID = new ProviderId("foo", "bar"); |
| 35 | |
| 36 | static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT); |
| 37 | static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT); |
| 38 | |
| 39 | @Test |
| 40 | public void basics() { |
| 41 | DefaultTopologyEdge e = new DefaultTopologyEdge(V1, V2, L1); |
| 42 | assertEquals("incorrect src", V1, e.src()); |
| 43 | assertEquals("incorrect dst", V2, e.dst()); |
| 44 | assertEquals("incorrect link", L1, e.link()); |
| 45 | |
| 46 | new EqualsTester() |
| 47 | .addEqualityGroup(new DefaultTopologyEdge(V1, V2, L1), |
| 48 | new DefaultTopologyEdge(V1, V2, L1)) |
| 49 | .addEqualityGroup(new DefaultTopologyEdge(V2, V1, L2), |
| 50 | new DefaultTopologyEdge(V2, V1, L2)) |
| 51 | .testEquals(); |
| 52 | } |
| 53 | |
| 54 | } |