Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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; |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 27 | import org.onosproject.ui.AbstractUiTest; |
Simon Hunt | 05eba35 | 2017-05-11 20:17:08 -0700 | [diff] [blame] | 28 | import org.onosproject.ui.model.topo.UiLinkId; |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Base class for unit tests of {@link BiLink} and {@link BiLinkMap}. |
| 32 | */ |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 33 | public abstract class BiLinkTestBase extends AbstractUiTest { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 34 | |
| 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 Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 44 | @Override |
| 45 | public ConnectPoint src() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 46 | return src; |
| 47 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 48 | |
| 49 | @Override |
| 50 | public ConnectPoint dst() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 51 | return dst; |
| 52 | } |
| 53 | |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 54 | @Override |
| 55 | public Type type() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 56 | return null; |
| 57 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 58 | |
| 59 | @Override |
| 60 | public State state() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 61 | return null; |
| 62 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 63 | |
| 64 | @Override |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 65 | public boolean isExpected() { |
Ray Milkey | d0dd135 | 2016-01-19 10:58:41 -0800 | [diff] [blame] | 66 | return false; |
| 67 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 68 | |
| 69 | @Override |
| 70 | public Annotations annotations() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 71 | return null; |
| 72 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 73 | |
| 74 | @Override |
| 75 | public ProviderId providerId() { |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 76 | return null; |
| 77 | } |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 78 | |
| 79 | @Override |
| 80 | public <B extends Behaviour> B as(Class<B> projectionClass) { |
| 81 | return null; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public <B extends Behaviour> boolean is(Class<B> projectionClass) { |
| 86 | return false; |
| 87 | } |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | protected static final DeviceId DEV_A_ID = DeviceId.deviceId("device-A"); |
| 91 | protected static final DeviceId DEV_B_ID = DeviceId.deviceId("device-B"); |
| 92 | protected static final PortNumber PORT_1 = PortNumber.portNumber(1); |
| 93 | protected static final PortNumber PORT_2 = PortNumber.portNumber(2); |
| 94 | |
| 95 | protected static final ConnectPoint CP_A1 = new ConnectPoint(DEV_A_ID, PORT_1); |
| 96 | protected static final ConnectPoint CP_B2 = new ConnectPoint(DEV_B_ID, PORT_2); |
| 97 | |
| 98 | protected static final LinkKey KEY_AB = LinkKey.linkKey(CP_A1, CP_B2); |
| 99 | protected static final LinkKey KEY_BA = LinkKey.linkKey(CP_B2, CP_A1); |
| 100 | |
| 101 | protected static final Link LINK_AB = new FakeLink(CP_A1, CP_B2); |
| 102 | protected static final Link LINK_BA = new FakeLink(CP_B2, CP_A1); |
| 103 | |
| 104 | protected static class ConcreteLink extends BiLink { |
| 105 | public ConcreteLink(LinkKey key, Link link) { |
| 106 | super(key, link); |
| 107 | } |
Simon Hunt | f01826c | 2017-05-09 17:28:13 -0700 | [diff] [blame] | 108 | |
Simon Hunt | 05eba35 | 2017-05-11 20:17:08 -0700 | [diff] [blame] | 109 | public ConcreteLink(UiLinkId uiLinkId) { |
| 110 | super(uiLinkId); |
| 111 | } |
| 112 | |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 113 | @Override |
| 114 | public LinkHighlight highlight(Enum<?> type) { |
| 115 | return null; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | protected static class ConcreteLinkMap extends BiLinkMap<ConcreteLink> { |
| 120 | @Override |
| 121 | public ConcreteLink create(LinkKey key, Link link) { |
| 122 | return new ConcreteLink(key, link); |
| 123 | } |
| 124 | } |
| 125 | |
Simon Hunt | d6685d0 | 2015-08-21 09:56:06 -0700 | [diff] [blame] | 126 | } |