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