blob: 146a93a30f5d7702c3cde0fb8d87461d237ae9d6 [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
mskala32000d32017-07-14 16:27:06 +020059 public int getAvailableDeviceCount() {
60 return 0;
61 }
62
63 @Override
tom61359e92014-09-16 15:50:27 -070064 public Iterable<Device> getDevices() {
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -070065 return Collections.emptyList();
tom61359e92014-09-16 15:50:27 -070066 }
67
68 @Override
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080069 public Iterable<Device> getAvailableDevices() {
70 return FluentIterable.from(getDevices())
Sho SHIMIZU74626412015-09-11 11:46:27 -070071 .filter(input -> isAvailable(input.id()));
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080072 }
73
74 @Override
tom61359e92014-09-16 15:50:27 -070075 public Device getDevice(DeviceId deviceId) {
76 return null;
77 }
78
79 @Override
80 public MastershipRole getRole(DeviceId deviceId) {
HIGUCHI Yuta5bb99a42015-03-19 16:52:15 -070081 return MastershipRole.NONE;
tom61359e92014-09-16 15:50:27 -070082 }
83
84 @Override
85 public List<Port> getPorts(DeviceId deviceId) {
Phaneendra Manda8db7d092016-06-04 00:17:24 +053086 return portList;
tom61359e92014-09-16 15:50:27 -070087 }
88
89 @Override
sangho538108b2015-04-08 14:29:20 -070090 public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
91 return null;
92 }
93
94 @Override
Dusan Pajin11ff4a82015-08-20 18:03:05 +020095 public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
96 return null;
97 }
98
99 @Override
Viswanath KSP22774cd2016-08-20 20:06:30 +0530100 public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
101 return null;
102 }
103
104 @Override
105 public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
106 return null;
107 }
108
109 @Override
tom61359e92014-09-16 15:50:27 -0700110 public Port getPort(DeviceId deviceId, PortNumber portNumber) {
Yuta HIGUCHI37dca332016-11-14 18:43:22 -0800111 return getPorts(deviceId).stream()
112 .filter(port -> deviceId.equals(port.element().id()))
113 .filter(port -> portNumber.equals(port.number()))
114 .findFirst().orElse(null);
tom61359e92014-09-16 15:50:27 -0700115 }
116
117 @Override
118 public boolean isAvailable(DeviceId deviceId) {
119 return false;
120 }
121
122 @Override
123 public void addListener(DeviceListener listener) {
124 }
125
126 @Override
127 public void removeListener(DeviceListener listener) {
128 }
129
samuel738dfaf2015-07-11 11:08:57 +0800130 @Override
131 public Iterable<Device> getDevices(Type type) {
132 return Collections.emptyList();
133 }
134
135 @Override
136 public Iterable<Device> getAvailableDevices(Type type) {
137 return Collections.emptyList();
138 }
139
Saurav Dasd5ec9e92017-01-17 10:40:18 -0800140 @Override
141 public String localStatus(DeviceId deviceId) {
142 return null;
143 }
144
tom61359e92014-09-16 15:50:27 -0700145}