Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DefaultLink; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.net.provider.ProviderId; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 26 | |
| 27 | import static org.junit.Assert.assertEquals; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 28 | import static org.onosproject.net.DeviceId.deviceId; |
| 29 | import static org.onosproject.net.PortNumber.portNumber; |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Tests of the topology graph edge. |
| 33 | */ |
| 34 | public class DefaultTopologyEdgeTest { |
| 35 | |
| 36 | static final DeviceId D1 = deviceId("1"); |
| 37 | static final DeviceId D2 = deviceId("2"); |
| 38 | static final PortNumber P1 = portNumber(1); |
| 39 | static final PortNumber P2 = portNumber(2); |
| 40 | |
| 41 | static final ConnectPoint CP1 = new ConnectPoint(D1, P1); |
| 42 | static final ConnectPoint CP2 = new ConnectPoint(D2, P1); |
| 43 | static final ConnectPoint CP3 = new ConnectPoint(D2, P1); |
| 44 | static final ConnectPoint CP4 = new ConnectPoint(D1, P2); |
| 45 | |
| 46 | static final DefaultTopologyVertex V1 = new DefaultTopologyVertex(D1); |
| 47 | static final DefaultTopologyVertex V2 = new DefaultTopologyVertex(D2); |
| 48 | |
| 49 | static final ProviderId PID = new ProviderId("foo", "bar"); |
| 50 | |
Yuta HIGUCHI | 2210282 | 2014-11-12 23:09:59 -0800 | [diff] [blame] | 51 | /** D1:P1 -> D2:P1. */ |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 52 | static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT); |
Yuta HIGUCHI | 2210282 | 2014-11-12 23:09:59 -0800 | [diff] [blame] | 53 | /** D2:P1 -> D1:P2. */ |
tom | 747a213 | 2014-10-02 08:18:41 -0700 | [diff] [blame] | 54 | static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT); |
| 55 | |
| 56 | @Test |
| 57 | public void basics() { |
| 58 | DefaultTopologyEdge e = new DefaultTopologyEdge(V1, V2, L1); |
| 59 | assertEquals("incorrect src", V1, e.src()); |
| 60 | assertEquals("incorrect dst", V2, e.dst()); |
| 61 | assertEquals("incorrect link", L1, e.link()); |
| 62 | |
| 63 | new EqualsTester() |
| 64 | .addEqualityGroup(new DefaultTopologyEdge(V1, V2, L1), |
| 65 | new DefaultTopologyEdge(V1, V2, L1)) |
| 66 | .addEqualityGroup(new DefaultTopologyEdge(V2, V1, L2), |
| 67 | new DefaultTopologyEdge(V2, V1, L2)) |
| 68 | .testEquals(); |
| 69 | } |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 70 | } |