blob: bfca2c45336e25bd4756d7ddf5c914dbee1c1ed0 [file] [log] [blame]
Mahesh Poojary Huawei1d17cad2016-06-02 12:53:41 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Mahesh Poojary Huawei1d17cad2016-06-02 12:53:41 +05303 *
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 */
16package org.onosproject.pce.util;
17
18import org.onosproject.net.Link;
19import org.onosproject.net.link.LinkServiceAdapter;
20import org.onosproject.net.link.LinkListener;
21
22import java.util.ArrayList;
23import java.util.List;
24
25/**
26 * Test fixture for the link service.
27 */
28public 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}