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