blob: 79d260fd4299c24238803f1756e2c427eef5e9a6 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology;
tom747a2132014-10-02 08:18:41 -070017
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DefaultLink;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.Link;
24import org.onosproject.net.PortNumber;
25import org.onosproject.net.provider.ProviderId;
tom747a2132014-10-02 08:18:41 -070026
27import static org.junit.Assert.assertEquals;
Brian O'Connorabafb502014-12-02 22:26:20 -080028import static org.onosproject.net.DeviceId.deviceId;
29import static org.onosproject.net.PortNumber.portNumber;
tom747a2132014-10-02 08:18:41 -070030
31/**
32 * Tests of the topology graph edge.
33 */
34public 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
HIGUCHI Yuta67023a22016-03-28 13:35:44 -070051 /** D1:P1 {@literal ->} D2:P1. */
Ray Milkey2693bda2016-01-22 16:08:14 -080052 static final Link L1 = DefaultLink.builder()
53 .providerId(PID)
54 .src(CP1)
55 .dst(CP2)
56 .type(Link.Type.INDIRECT)
57 .build();
HIGUCHI Yuta67023a22016-03-28 13:35:44 -070058 /** D2:P1 {@literal ->} D1:P2. */
Ray Milkey2693bda2016-01-22 16:08:14 -080059 static final Link L2 = DefaultLink.builder()
60 .providerId(PID)
61 .src(CP3)
62 .dst(CP4)
63 .type(Link.Type.INDIRECT)
64 .build();
tom747a2132014-10-02 08:18:41 -070065
66 @Test
67 public void basics() {
68 DefaultTopologyEdge e = new DefaultTopologyEdge(V1, V2, L1);
69 assertEquals("incorrect src", V1, e.src());
70 assertEquals("incorrect dst", V2, e.dst());
71 assertEquals("incorrect link", L1, e.link());
72
73 new EqualsTester()
74 .addEqualityGroup(new DefaultTopologyEdge(V1, V2, L1),
75 new DefaultTopologyEdge(V1, V2, L1))
76 .addEqualityGroup(new DefaultTopologyEdge(V2, V1, L2),
77 new DefaultTopologyEdge(V2, V1, L2))
78 .testEquals();
79 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070080}