2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.dg.aai.impl;
27 import java.util.HashMap;
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;
41 public class AAIClientMock implements AAIClient {
43 Map<String, String> mockAAI = new HashMap<>();
45 public void setMockAAI(Map<String, String> mockAAI) {
46 this.mockAAI = mockAAI;
50 public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException {
55 public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException {
60 public Vce requestNetworkVceData(String s) throws AAIServiceException {
65 public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException {
70 public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException {
75 public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException {
80 public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException {
85 public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException {
90 public Vpe requestNetworkVpeData(String s) throws AAIServiceException {
95 public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException {
100 public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException {
105 public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException {
110 public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException {
115 public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException {
120 public URL requestVserverURLNodeQuery(String s) throws AAIServiceException {
125 public String getTenantIdFromVserverUrl(URL url) {
130 public String getCloudOwnerFromVserverUrl(URL url) {
135 public String getCloudRegionFromVserverUrl(URL url) {
140 public String getVServerIdFromVserverUrl(URL url, String s) {
145 public Vserver requestVServerDataByURL(URL url) throws AAIServiceException {
150 public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException {
155 public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException {
160 public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException {
165 public Complex requestNetworkComplexData(String s) throws AAIServiceException {
170 public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException {
175 public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException {
180 public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException {
185 public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException {
190 public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
195 public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
200 public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException {
205 public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
210 public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException {
215 public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
220 public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
225 public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
230 public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
235 public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
240 public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
245 public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
250 public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
255 public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
260 public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
265 public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
270 public GenericVnf requestGenericVnfData(String s) throws AAIServiceException {
275 public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException {
280 public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException {
285 public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException {
290 public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException {
295 public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException {
300 public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException {
305 public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException {
310 public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException {
315 public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException {
320 public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException {
325 public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException {
330 public PServer requestPServerData(String s) throws AAIServiceException {
335 public boolean postPServerData(String s, PServer pServer) throws AAIServiceException {
340 public boolean deletePServerData(String s, String s1) throws AAIServiceException {
345 public L3Network requestL3NetworkData(String s) throws AAIServiceException {
350 public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException {
355 public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException {
360 public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException {
365 public VpnBinding requestVpnBindingData(String s) throws AAIServiceException {
370 public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException {
375 public VnfImage requestVnfImageData(String s) throws AAIServiceException {
380 public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException {
385 public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException {
390 public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException {
395 public SitePairSet requestSitePairSetData(String s) throws AAIServiceException {
400 public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException {
405 public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException {
410 public Service requestServiceData(String s) throws AAIServiceException {
415 public boolean postServiceData(String s, Service service) throws AAIServiceException {
420 public boolean deleteServiceData(String s, String s1) throws AAIServiceException {
425 public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException {
430 public String requestDataByURL(URL url) throws AAIServiceException {
435 public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException {
440 public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException {
445 public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException {
450 public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException {
455 public boolean updateAnAIEntry(Update update) throws AAIServiceException {
460 public QueryStatus backup(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
465 public QueryStatus restore(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
470 public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
475 public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
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());
485 return QueryStatus.SUCCESS;
488 } else if (key.equals("vnf-id = 'test_VNF1'")){
489 return QueryStatus.NOT_FOUND;
491 else if (key.equals("vnf-id = 'test_VNF3'")){
492 throw new SvcLogicException();
495 return QueryStatus.FAILURE;
502 public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException {
507 public QueryStatus save(String s, boolean b, boolean b1, String s1, Map<String, String> map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
512 public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
517 public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
522 public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
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());
532 return QueryStatus.SUCCESS;
535 } else if (key.equals("vnf-id = 'test_VNF1'")){
536 return QueryStatus.NOT_FOUND;
538 else if (key.equals("vnf-id = 'test_VNF3'")){
539 throw new SvcLogicException();
542 return QueryStatus.FAILURE;