blob: f713b8129f5b3334416e1bddb41303668efe69f9 [file] [log] [blame]
Simon Huntd6685d02015-08-21 09:56:06 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Huntd6685d02015-08-21 09:56:06 -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.
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;
Thomas Vachuska3afbc7f2016-02-01 15:55:38 -080025import org.onosproject.net.driver.Behaviour;
Simon Huntd6685d02015-08-21 09:56:06 -070026import org.onosproject.net.provider.ProviderId;
Simon Huntf01826c2017-05-09 17:28:13 -070027import org.onosproject.ui.AbstractUiTest;
Simon Hunt05eba352017-05-11 20:17:08 -070028import org.onosproject.ui.model.topo.UiLinkId;
Simon Huntd6685d02015-08-21 09:56:06 -070029
30/**
31 * Base class for unit tests of {@link BiLink} and {@link BiLinkMap}.
32 */
Simon Huntf01826c2017-05-09 17:28:13 -070033public abstract class BiLinkTestBase extends AbstractUiTest {
Simon Huntd6685d02015-08-21 09:56:06 -070034
35 protected static class FakeLink implements Link {
36 private final ConnectPoint src;
37 private final ConnectPoint dst;
38
39 FakeLink(ConnectPoint src, ConnectPoint dst) {
40 this.src = src;
41 this.dst = dst;
42 }
43
Simon Huntf01826c2017-05-09 17:28:13 -070044 @Override
45 public ConnectPoint src() {
Simon Huntd6685d02015-08-21 09:56:06 -070046 return src;
47 }
Simon Huntf01826c2017-05-09 17:28:13 -070048
49 @Override
50 public ConnectPoint dst() {
Simon Huntd6685d02015-08-21 09:56:06 -070051 return dst;
52 }
53
Simon Huntf01826c2017-05-09 17:28:13 -070054 @Override
55 public Type type() {
Simon Huntd6685d02015-08-21 09:56:06 -070056 return null;
57 }
Simon Huntf01826c2017-05-09 17:28:13 -070058
59 @Override
60 public State state() {
Simon Huntd6685d02015-08-21 09:56:06 -070061 return null;
62 }
Simon Huntf01826c2017-05-09 17:28:13 -070063
64 @Override
65 public boolean isDurable() {
Simon Huntd6685d02015-08-21 09:56:06 -070066 return false;
67 }
Simon Huntf01826c2017-05-09 17:28:13 -070068
69 @Override
70 public boolean isExpected() {
Ray Milkeyd0dd1352016-01-19 10:58:41 -080071 return false;
72 }
Simon Huntf01826c2017-05-09 17:28:13 -070073
74 @Override
75 public Annotations annotations() {
Simon Huntd6685d02015-08-21 09:56:06 -070076 return null;
77 }
Simon Huntf01826c2017-05-09 17:28:13 -070078
79 @Override
80 public ProviderId providerId() {
Simon Huntd6685d02015-08-21 09:56:06 -070081 return null;
82 }
Thomas Vachuska3afbc7f2016-02-01 15:55:38 -080083
84 @Override
85 public <B extends Behaviour> B as(Class<B> projectionClass) {
86 return null;
87 }
88
89 @Override
90 public <B extends Behaviour> boolean is(Class<B> projectionClass) {
91 return false;
92 }
Simon Huntd6685d02015-08-21 09:56:06 -070093 }
94
95 protected static final DeviceId DEV_A_ID = DeviceId.deviceId("device-A");
96 protected static final DeviceId DEV_B_ID = DeviceId.deviceId("device-B");
97 protected static final PortNumber PORT_1 = PortNumber.portNumber(1);
98 protected static final PortNumber PORT_2 = PortNumber.portNumber(2);
99
100 protected static final ConnectPoint CP_A1 = new ConnectPoint(DEV_A_ID, PORT_1);
101 protected static final ConnectPoint CP_B2 = new ConnectPoint(DEV_B_ID, PORT_2);
102
103 protected static final LinkKey KEY_AB = LinkKey.linkKey(CP_A1, CP_B2);
104 protected static final LinkKey KEY_BA = LinkKey.linkKey(CP_B2, CP_A1);
105
106 protected static final Link LINK_AB = new FakeLink(CP_A1, CP_B2);
107 protected static final Link LINK_BA = new FakeLink(CP_B2, CP_A1);
108
109 protected static class ConcreteLink extends BiLink {
110 public ConcreteLink(LinkKey key, Link link) {
111 super(key, link);
112 }
Simon Huntf01826c2017-05-09 17:28:13 -0700113
Simon Hunt05eba352017-05-11 20:17:08 -0700114 public ConcreteLink(UiLinkId uiLinkId) {
115 super(uiLinkId);
116 }
117
Simon Huntd6685d02015-08-21 09:56:06 -0700118 @Override
119 public LinkHighlight highlight(Enum<?> type) {
120 return null;
121 }
122 }
123
124 protected static class ConcreteLinkMap extends BiLinkMap<ConcreteLink> {
125 @Override
126 public ConcreteLink create(LinkKey key, Link link) {
127 return new ConcreteLink(key, link);
128 }
129 }
130
Simon Huntd6685d02015-08-21 09:56:06 -0700131}