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