blob: 4fd63f81c359d65ce38c00273782a7d6f842e968 [file] [log] [blame]
xueliang37a396a2016-09-09 14:43:49 +09001/*
Brian O'Connor0a4e6742016-09-15 23:03:10 -07002 * Copyright 2016-present Open Networking Laboratory
xueliang37a396a2016-09-09 14:43:49 +09003 *
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
17package org.onosproject.drivers.fujitsu;
18
19import com.google.common.annotations.Beta;
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030020import org.onosproject.netconf.TargetConfig;
xueliang37a396a2016-09-09 14:43:49 +090021import org.onosproject.netconf.NetconfDeviceOutputEventListener;
22import org.onosproject.netconf.NetconfException;
23import org.onosproject.netconf.NetconfSession;
24
25import java.util.List;
26import java.util.concurrent.CompletableFuture;
27
28
29/**
30 * Mock NetconfSessionImpl.
31 */
32public class FujitsuNetconfSessionMock implements NetconfSession {
33
34 private FujitsuNetconfSessionListenerTest listener;
35
36 /**
37 * Registers a listener to be invoked for verification.
38 *
39 * @param listener listener to be added
40 */
41 public void setListener(FujitsuNetconfSessionListenerTest listener) {
42 this.listener = listener;
43 }
44
45 @Override
46 public CompletableFuture<String> request(String request) throws NetconfException {
47 return null;
48 }
49
50 @Override
51 public String get(String request) throws NetconfException {
52 return null;
53 }
54
55 @Override
56 public String get(String filterSchema, String withDefaultsMode)
57 throws NetconfException {
58 boolean result = true;
59 String reply = null;
60 if (listener != null) {
61 result = listener.verifyGet(filterSchema, withDefaultsMode);
62 if (result) {
63 reply = listener.buildGetReply();
64 }
65 }
66 return result ? ((reply == null) ? filterSchema : reply) : null;
67 }
68
69 @Override
70 public String doWrappedRpc(String request) throws NetconfException {
71 boolean result = true;
72 if (listener != null) {
73 result = listener.verifyWrappedRpc(request);
74 }
75 return result ? request : null;
76 }
77
78 @Override
79 public String requestSync(String request) throws NetconfException {
80 return null;
81 }
82
83 @Override
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030084 public String getConfig(TargetConfig targetConfiguration) throws NetconfException {
85 return null;
86 }
87
88 @Override
xueliang37a396a2016-09-09 14:43:49 +090089 public String getConfig(String targetConfiguration) throws NetconfException {
90 return null;
91 }
92
93 @Override
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030094 public String getConfig(TargetConfig targetConfiguration, String configurationFilterSchema)
95 throws NetconfException {
96 return null;
97 }
98
99 @Override
xueliang37a396a2016-09-09 14:43:49 +0900100 public String getConfig(String targetConfiguration, String configurationFilterSchema)
101 throws NetconfException {
102 return null;
103 }
104
105 @Override
106 public boolean editConfig(String newConfiguration) throws NetconfException {
107 boolean result = true;
108 if (listener != null) {
109 result = listener.verifyEditConfig(newConfiguration);
110 }
111 return result;
112 }
113
114 @Override
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300115 public boolean editConfig(TargetConfig targetConfiguration, String mode, String newConfiguration)
116 throws NetconfException {
117 boolean result = true;
118 if (listener != null) {
119 result = listener.verifyEditConfig(targetConfiguration, mode, newConfiguration);
120 }
121 return result;
122 }
123
124 @Override
xueliang37a396a2016-09-09 14:43:49 +0900125 public boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
126 throws NetconfException {
127 boolean result = true;
128 if (listener != null) {
129 result = listener.verifyEditConfig(targetConfiguration, mode, newConfiguration);
130 }
131 return result;
132 }
133
134 @Override
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300135 public boolean copyConfig(TargetConfig targetConfiguration, String newConfiguration)
136 throws NetconfException {
137 return false;
138 }
139
140 @Override
xueliang37a396a2016-09-09 14:43:49 +0900141 public boolean copyConfig(String targetConfiguration, String newConfiguration)
142 throws NetconfException {
143 return false;
144 }
145
146 @Override
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300147 public boolean deleteConfig(TargetConfig targetConfiguration) throws NetconfException {
148 return false;
149 }
150
151 @Override
xueliang37a396a2016-09-09 14:43:49 +0900152 public boolean deleteConfig(String targetConfiguration) throws NetconfException {
153 return false;
154 }
155
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300156
xueliang37a396a2016-09-09 14:43:49 +0900157 @Override
158 public void startSubscription() throws NetconfException {
159 }
160
161 @Beta
162 @Override
163 public void startSubscription(String filterSchema) throws NetconfException {
164 if (listener != null) {
165 listener.verifyStartSubscription(filterSchema);
166 }
167 return;
168 }
169
170 @Override
171 public void endSubscription() throws NetconfException {
172 }
173
174 @Override
175 public boolean lock(String configType) throws NetconfException {
176 return false;
177 }
178
179 @Override
180 public boolean unlock(String configType) throws NetconfException {
181 return false;
182 }
183
184 @Override
185 public boolean lock() throws NetconfException {
186 return false;
187 }
188
189 @Override
190 public boolean unlock() throws NetconfException {
191 return false;
192 }
193
194 @Override
195 public boolean close() throws NetconfException {
196 return false;
197 }
198
199 @Override
200 public String getSessionId() {
201 return null;
202 }
203
204 @Override
205 public String getServerCapabilities() {
206 return null;
207 }
208
209 @Override
210 public void setDeviceCapabilities(List<String> capabilities) {
211 }
212
213 @Override
Andrea Campanellac3627842017-04-04 18:06:54 +0200214 public void checkAndReestablish() throws NetconfException {
215 }
216
217 @Override
xueliang37a396a2016-09-09 14:43:49 +0900218 public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
219 }
220
221 @Override
222 public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
223 }
224
225}