Initial OpenECOMP APPC commit
[appc.git] / app-c / appc / appc-dg / appc-dg-shared / appc-dg-aai / src / main / test / java / org / openecomp / appc / dg / aai / impl / AAIClientMock.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.dg.aai.impl;
23
24 import java.net.URL;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import org.openecomp.sdnc.sli.SvcLogicContext;
29 import org.openecomp.sdnc.sli.SvcLogicException;
30 import org.openecomp.sdnc.sli.SvcLogicResource;
31 import org.openecomp.sdnc.sli.aai.AAIClient;
32 import org.openecomp.sdnc.sli.aai.AAIServiceException;
33 import org.openecomp.sdnc.sli.aai.data.*;
34 import org.openecomp.sdnc.sli.aai.data.notify.NotifyEvent;
35 import org.openecomp.sdnc.sli.aai.data.v1507.VServer;
36 import org.openecomp.sdnc.sli.aai.update.Update;
37
38
39 public class AAIClientMock implements AAIClient {
40
41     Map<String, String> mockAAI = new HashMap<>();
42
43     public void setMockAAI(Map<String, String> mockAAI) {
44         this.mockAAI = mockAAI;
45     }
46
47     @Override
48     public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException {
49         return null;
50     }
51
52     @Override
53     public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException {
54         return false;
55     }
56
57     @Override
58     public Vce requestNetworkVceData(String s) throws AAIServiceException {
59         return null;
60     }
61
62     @Override
63     public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException {
64         return false;
65     }
66
67     @Override
68     public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException {
69         return null;
70     }
71
72     @Override
73     public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException {
74         return null;
75     }
76
77     @Override
78     public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException {
79         return false;
80     }
81
82     @Override
83     public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException {
84         return null;
85     }
86
87     @Override
88     public Vpe requestNetworkVpeData(String s) throws AAIServiceException {
89         return null;
90     }
91
92     @Override
93     public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException {
94         return false;
95     }
96
97     @Override
98     public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException {
99         return false;
100     }
101
102     @Override
103     public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException {
104         return null;
105     }
106
107     @Override
108     public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException {
109         return false;
110     }
111
112     @Override
113     public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException {
114         return false;
115     }
116
117     @Override
118     public URL requestVserverURLNodeQuery(String s) throws AAIServiceException {
119         return null;
120     }
121
122     @Override
123     public String getTenantIdFromVserverUrl(URL url) {
124         return null;
125     }
126
127     @Override
128     public String getCloudOwnerFromVserverUrl(URL url) {
129         return null;
130     }
131
132     @Override
133     public String getCloudRegionFromVserverUrl(URL url) {
134         return null;
135     }
136
137     @Override
138     public String getVServerIdFromVserverUrl(URL url, String s) {
139         return null;
140     }
141
142     @Override
143     public Vserver requestVServerDataByURL(URL url) throws AAIServiceException {
144         return null;
145     }
146
147     @Override
148     public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException {
149         return null;
150     }
151
152     @Override
153     public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException {
154         return false;
155     }
156
157     @Override
158     public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException {
159         return false;
160     }
161
162     @Override
163     public Complex requestNetworkComplexData(String s) throws AAIServiceException {
164         return null;
165     }
166
167     @Override
168     public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException {
169         return false;
170     }
171
172     @Override
173     public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException {
174         return false;
175     }
176
177     @Override
178     public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException {
179         return null;
180     }
181
182     @Override
183     public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException {
184         return null;
185     }
186
187     @Override
188     public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
189         return null;
190     }
191
192     @Override
193     public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
194         return null;
195     }
196
197     @Override
198     public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException {
199         return null;
200     }
201
202     @Override
203     public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
204         return null;
205     }
206
207     @Override
208     public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException {
209         return null;
210     }
211
212     @Override
213     public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
214         return null;
215     }
216
217     @Override
218     public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
219         return null;
220     }
221
222     @Override
223     public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
224         return null;
225     }
226
227     @Override
228     public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
229         return false;
230     }
231
232     @Override
233     public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
234         return false;
235     }
236
237     @Override
238     public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
239         return false;
240     }
241
242     @Override
243     public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
244         return false;
245     }
246
247     @Override
248     public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
249         return false;
250     }
251
252     @Override
253     public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
254         return false;
255     }
256
257     @Override
258     public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
259         return false;
260     }
261
262     @Override
263     public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
264         return false;
265     }
266
267     @Override
268     public GenericVnf requestGenericVnfData(String s) throws AAIServiceException {
269         return null;
270     }
271
272     @Override
273     public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException {
274         return false;
275     }
276
277     @Override
278     public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException {
279         return false;
280     }
281
282     @Override
283     public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException {
284         return null;
285     }
286
287     @Override
288     public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException {
289         return false;
290     }
291
292     @Override
293     public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException {
294         return false;
295     }
296
297     @Override
298     public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException {
299         return null;
300     }
301
302     @Override
303     public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException {
304         return false;
305     }
306
307     @Override
308     public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException {
309         return false;
310     }
311
312     @Override
313     public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException {
314         return null;
315     }
316
317     @Override
318     public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException {
319         return false;
320     }
321
322     @Override
323     public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException {
324         return false;
325     }
326
327     @Override
328     public PServer requestPServerData(String s) throws AAIServiceException {
329         return null;
330     }
331
332     @Override
333     public boolean postPServerData(String s, PServer pServer) throws AAIServiceException {
334         return false;
335     }
336
337     @Override
338     public boolean deletePServerData(String s, String s1) throws AAIServiceException {
339         return false;
340     }
341
342     @Override
343     public L3Network requestL3NetworkData(String s) throws AAIServiceException {
344         return null;
345     }
346
347     @Override
348     public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException {
349         return null;
350     }
351
352     @Override
353     public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException {
354         return false;
355     }
356
357     @Override
358     public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException {
359         return false;
360     }
361
362     @Override
363     public VpnBinding requestVpnBindingData(String s) throws AAIServiceException {
364         return null;
365     }
366
367     @Override
368     public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException {
369         return false;
370     }
371
372     @Override
373     public VnfImage requestVnfImageData(String s) throws AAIServiceException {
374         return null;
375     }
376
377     @Override
378     public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException {
379         return null;
380     }
381
382     @Override
383     public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException {
384         return null;
385     }
386
387     @Override
388     public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException {
389         return false;
390     }
391
392     @Override
393     public SitePairSet requestSitePairSetData(String s) throws AAIServiceException {
394         return null;
395     }
396
397     @Override
398     public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException {
399         return false;
400     }
401
402     @Override
403     public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException {
404         return false;
405     }
406
407     @Override
408     public Service requestServiceData(String s) throws AAIServiceException {
409         return null;
410     }
411
412     @Override
413     public boolean postServiceData(String s, Service service) throws AAIServiceException {
414         return false;
415     }
416
417     @Override
418     public boolean deleteServiceData(String s, String s1) throws AAIServiceException {
419         return false;
420     }
421
422     @Override
423     public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException {
424         return null;
425     }
426
427     @Override
428     public String requestDataByURL(URL url) throws AAIServiceException {
429         return null;
430     }
431
432     @Override
433     public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException {
434         return null;
435     }
436
437     @Override
438     public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException {
439         return null;
440     }
441
442     @Override
443     public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException {
444         return null;
445     }
446
447     @Override
448     public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException {
449         return false;
450     }
451
452     @Override
453     public boolean updateAnAIEntry(Update update) throws AAIServiceException {
454         return false;
455     }
456
457     @Override
458     public QueryStatus backup(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
459         return null;
460     }
461
462     @Override
463     public QueryStatus restore(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
464         return null;
465     }
466
467     @Override
468     public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
469         return null;
470     }
471
472     @Override
473     public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
474         return null;
475     }
476
477     @Override
478     public QueryStatus query(String s, boolean b, String s1, String key, String prefix, String s4, SvcLogicContext ctx) throws SvcLogicException {
479         if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
480             for (Map.Entry<String, String> entry : mockAAI.entrySet()) {
481                 ctx.setAttribute(prefix + "." + entry.getKey(), entry.getValue());
482             }
483             return QueryStatus.SUCCESS;
484
485
486         } else if (key.equals("vnf-id = 'test_VNF1'")){
487             return QueryStatus.NOT_FOUND;
488         }
489         else if (key.equals("vnf-id = 'test_VNF3'")){
490             throw new SvcLogicException();
491         }
492         else {
493             return QueryStatus.FAILURE;
494         }
495
496
497     }
498
499     @Override
500     public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException {
501         return null;
502     }
503
504     @Override
505     public QueryStatus save(String s, boolean b, boolean b1, String s1, Map<String, String> map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
506         return null;
507     }
508
509     @Override
510     public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
511         return null;
512     }
513
514     @Override
515     public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
516         return null;
517     }
518
519     @Override
520     public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
521         return null;
522     }
523
524     @Override
525     public QueryStatus update(String s, String key, Map<String, String> data, String prefix, SvcLogicContext ctx) throws SvcLogicException {
526         if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
527             for (Map.Entry<String, String> entry : data.entrySet()) {
528                 mockAAI.put(entry.getKey(), entry.getValue());
529             }
530             return QueryStatus.SUCCESS;
531
532
533         } else if (key.equals("vnf-id = 'test_VNF1'")){
534             return QueryStatus.NOT_FOUND;
535         }
536         else if (key.equals("vnf-id = 'test_VNF3'")){
537             throw new SvcLogicException();
538         }
539         else {
540             return QueryStatus.FAILURE;
541         }
542
543     }
544 }