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