blob: a6beec8650613d22edb5765759cddabff5802cb0 [file] [log] [blame]
Simon Huntd6685d02015-08-21 09:56:06 -07001/*
2 * Copyright 2015 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.
Simon Huntd6685d02015-08-21 09:56:06 -070015 */
16
17package org.onosproject.ui.topo;
18
19import org.onosproject.net.Annotations;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.Link;
23import org.onosproject.net.LinkKey;
24import org.onosproject.net.PortNumber;
25import org.onosproject.net.provider.ProviderId;
26
27/**
28 * Base class for unit tests of {@link BiLink} and {@link BiLinkMap}.
29 */
30public abstract class BiLinkTestBase {
31
32 protected static class FakeLink implements Link {
33 private final ConnectPoint src;
34 private final ConnectPoint dst;
35
36 FakeLink(ConnectPoint src, ConnectPoint dst) {
37 this.src = src;
38 this.dst = dst;
39 }
40
41 @Override public ConnectPoint src() {
42 return src;
43 }
44 @Override public ConnectPoint dst() {
45 return dst;
46 }
47
48 @Override public Type type() {
49 return null;
50 }
51 @Override public State state() {
52 return null;
53 }
54 @Override public boolean isDurable() {
55 return false;
56 }
57 @Override public Annotations annotations() {
58 return null;
59 }
60 @Override public ProviderId providerId() {
61 return null;
62 }
63 }
64
65 protected static final DeviceId DEV_A_ID = DeviceId.deviceId("device-A");
66 protected static final DeviceId DEV_B_ID = DeviceId.deviceId("device-B");
67 protected static final PortNumber PORT_1 = PortNumber.portNumber(1);
68 protected static final PortNumber PORT_2 = PortNumber.portNumber(2);
69
70 protected static final ConnectPoint CP_A1 = new ConnectPoint(DEV_A_ID, PORT_1);
71 protected static final ConnectPoint CP_B2 = new ConnectPoint(DEV_B_ID, PORT_2);
72
73 protected static final LinkKey KEY_AB = LinkKey.linkKey(CP_A1, CP_B2);
74 protected static final LinkKey KEY_BA = LinkKey.linkKey(CP_B2, CP_A1);
75
76 protected static final Link LINK_AB = new FakeLink(CP_A1, CP_B2);
77 protected static final Link LINK_BA = new FakeLink(CP_B2, CP_A1);
78
79 protected static class ConcreteLink extends BiLink {
80 public ConcreteLink(LinkKey key, Link link) {
81 super(key, link);
82 }
83 @Override
84 public LinkHighlight highlight(Enum<?> type) {
85 return null;
86 }
87 }
88
89 protected static class ConcreteLinkMap extends BiLinkMap<ConcreteLink> {
90 @Override
91 public ConcreteLink create(LinkKey key, Link link) {
92 return new ConcreteLink(key, link);
93 }
94 }
95
96
97}