Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 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 Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package org.onosproject.ui.topo; |
| 18 | |
| 19 | import org.onosproject.net.Annotations; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.Link; |
| 23 | import org.onosproject.net.LinkKey; |
| 24 | import org.onosproject.net.PortNumber; |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 25 | import org.onosproject.net.driver.Behaviour; |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 26 | import org.onosproject.net.provider.ProviderId; |
| 27 | |
| 28 | /** |
| 29 | * Base class for unit tests of {@link BiLink} and {@link BiLinkMap}. |
| 30 | */ |
| 31 | public 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 | } |
Ray Milkey | d0dd135 | 2016-01-19 10:58:41 -0800 | [diff] [blame] | 58 | @Override public boolean isExpected() { |
| 59 | return false; |
| 60 | } |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 61 | @Override public Annotations annotations() { |
| 62 | return null; |
| 63 | } |
| 64 | @Override public ProviderId providerId() { |
| 65 | return null; |
| 66 | } |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 67 | |
| 68 | @Override |
| 69 | public <B extends Behaviour> B as(Class<B> projectionClass) { |
| 70 | return null; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public <B extends Behaviour> boolean is(Class<B> projectionClass) { |
| 75 | return false; |
| 76 | } |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | protected static final DeviceId DEV_A_ID = DeviceId.deviceId("device-A"); |
| 80 | protected static final DeviceId DEV_B_ID = DeviceId.deviceId("device-B"); |
| 81 | protected static final PortNumber PORT_1 = PortNumber.portNumber(1); |
| 82 | protected static final PortNumber PORT_2 = PortNumber.portNumber(2); |
| 83 | |
| 84 | protected static final ConnectPoint CP_A1 = new ConnectPoint(DEV_A_ID, PORT_1); |
| 85 | protected static final ConnectPoint CP_B2 = new ConnectPoint(DEV_B_ID, PORT_2); |
| 86 | |
| 87 | protected static final LinkKey KEY_AB = LinkKey.linkKey(CP_A1, CP_B2); |
| 88 | protected static final LinkKey KEY_BA = LinkKey.linkKey(CP_B2, CP_A1); |
| 89 | |
| 90 | protected static final Link LINK_AB = new FakeLink(CP_A1, CP_B2); |
| 91 | protected static final Link LINK_BA = new FakeLink(CP_B2, CP_A1); |
| 92 | |
| 93 | protected static class ConcreteLink extends BiLink { |
| 94 | public ConcreteLink(LinkKey key, Link link) { |
| 95 | super(key, link); |
| 96 | } |
| 97 | @Override |
| 98 | public LinkHighlight highlight(Enum<?> type) { |
| 99 | return null; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | protected static class ConcreteLinkMap extends BiLinkMap<ConcreteLink> { |
| 104 | @Override |
| 105 | public ConcreteLink create(LinkKey key, Link link) { |
| 106 | return new ConcreteLink(key, link); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | |
| 111 | } |