Mahesh Poojary Huawei | 1d17cad | 2016-06-02 12:53:41 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Foundation |
Mahesh Poojary Huawei | 1d17cad | 2016-06-02 12:53:41 +0530 | [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. |
| 15 | */ |
| 16 | package org.onosproject.pce.util; |
| 17 | |
| 18 | import org.onosproject.net.Link; |
| 19 | import org.onosproject.net.link.LinkServiceAdapter; |
| 20 | import org.onosproject.net.link.LinkListener; |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.List; |
| 24 | |
| 25 | /** |
| 26 | * Test fixture for the link service. |
| 27 | */ |
| 28 | public class MockLinkService extends LinkServiceAdapter { |
| 29 | List<Link> links = new ArrayList<>(); |
| 30 | LinkListener listener; |
| 31 | |
| 32 | @Override |
| 33 | public int getLinkCount() { |
| 34 | return links.size(); |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public Iterable<Link> getLinks() { |
| 39 | return links; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public void addListener(LinkListener listener) { |
| 44 | this.listener = listener; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Get listener. |
| 49 | */ |
| 50 | public LinkListener getListener() { |
| 51 | return listener; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Add link. |
| 56 | * |
| 57 | * @param link needs to be added to list |
| 58 | */ |
| 59 | public void addLink(Link link) { |
| 60 | links.add(link); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Delete link. |
| 65 | * |
| 66 | * @param link needs to be deleted from list |
| 67 | */ |
| 68 | public void removeLink(Link link) { |
| 69 | links.remove(link); |
| 70 | } |
| 71 | } |