blob: 9c6887c872d3c90536069f9042e03d32158d296a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -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.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.device;
tom61359e92014-09-16 15:50:27 -070017
Phaneendra Manda8db7d092016-06-04 00:17:24 +053018import java.util.Collections;
19import java.util.List;
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -070020
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.Device;
samuel738dfaf2015-07-11 11:08:57 +080022import org.onosproject.net.Device.Type;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.DeviceId;
24import org.onosproject.net.MastershipRole;
25import org.onosproject.net.Port;
26import org.onosproject.net.PortNumber;
tom61359e92014-09-16 15:50:27 -070027
Phaneendra Manda8db7d092016-06-04 00:17:24 +053028import com.google.common.collect.FluentIterable;
tom61359e92014-09-16 15:50:27 -070029
30/**
31 * Test adapter for device service.
32 */
33public class DeviceServiceAdapter implements DeviceService {
Phaneendra Manda8db7d092016-06-04 00:17:24 +053034
35 private List<Port> portList;
36
37 /**
38 * Constructor with port list.
39 *
40 * @param portList port list
41 */
42 public DeviceServiceAdapter(List<Port> portList) {
43 this.portList = portList;
44 }
45
46 /**
47 * Default constructor.
48 */
49 public DeviceServiceAdapter() {
50
51 }
52
tom61359e92014-09-16 15:50:27 -070053 @Override
54 public int getDeviceCount() {
55 return 0;
56 }
57
58 @Override
59 public Iterable<Device> getDevices() {
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -070060 return Collections.emptyList();
tom61359e92014-09-16 15:50:27 -070061 }
62
63 @Override
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080064 public Iterable<Device> getAvailableDevices() {
65 return FluentIterable.from(getDevices())
Sho SHIMIZU74626412015-09-11 11:46:27 -070066 .filter(input -> isAvailable(input.id()));
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080067 }
68
69 @Override
tom61359e92014-09-16 15:50:27 -070070 public Device getDevice(DeviceId deviceId) {
71 return null;
72 }
73
74 @Override
75 public MastershipRole getRole(DeviceId deviceId) {
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -070076 return MastershipRole.NONE;
tom61359e92014-09-16 15:50:27 -070077 }
78
79 @Override
80 public List<Port> getPorts(DeviceId deviceId) {
Phaneendra Manda8db7d092016-06-04 00:17:24 +053081 return portList;
tom61359e92014-09-16 15:50:27 -070082 }
83
84 @Override
sangho538108b2015-04-08 14:29:20 -070085 public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
86 return null;
87 }
88
89 @Override
Dusan Pajin11ff4a82015-08-20 18:03:05 +020090 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
91 return null;
92 }
93
94 @Override
Viswanath KSP22774cd2016-08-20 20:06:30 +053095 public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
96 return null;
97 }
98
99 @Override
100 public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
101 return null;
102 }
103
104 @Override
tom61359e92014-09-16 15:50:27 -0700105 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
Yuta HIGUCHI37dca332016-11-14 18:43:22 -0800106 return getPorts(deviceId).stream()
107 .filter(port -> deviceId.equals(port.element().id()))
108 .filter(port -> portNumber.equals(port.number()))
109 .findFirst().orElse(null);
tom61359e92014-09-16 15:50:27 -0700110 }
111
112 @Override
113 public boolean isAvailable(DeviceId deviceId) {
114 return false;
115 }
116
117 @Override
118 public void addListener(DeviceListener listener) {
119 }
120
121 @Override
122 public void removeListener(DeviceListener listener) {
123 }
124
samuel738dfaf2015-07-11 11:08:57 +0800125 @Override
126 public Iterable<Device> getDevices(Type type) {
127 return Collections.emptyList();
128 }
129
130 @Override
131 public Iterable<Device> getAvailableDevices(Type type) {
132 return Collections.emptyList();
133 }
134
Saurav Dasd5ec9e92017-01-17 10:40:18 -0800135 @Override
136 public String localStatus(DeviceId deviceId) {
137 return null;
138 }
139
tom61359e92014-09-16 15:50:27 -0700140}