2 * ============LICENSE_START=======================================================
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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.dg.aai.impl;
28 import java.util.HashMap;
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;
42 public class AAIClientMock implements AAIClient {
44 Map<String, String> mockAAI = new HashMap<>();
46 public void setMockAAI(Map<String, String> mockAAI) {
47 this.mockAAI = mockAAI;
51 public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException {
56 public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException {
61 public Vce requestNetworkVceData(String s) throws AAIServiceException {
66 public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException {
71 public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException {
76 public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException {
81 public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException {
86 public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException {
91 public Vpe requestNetworkVpeData(String s) throws AAIServiceException {
96 public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException {
101 public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException {
106 public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException {
111 public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException {
116 public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException {
121 public URL requestVserverURLNodeQuery(String s) throws AAIServiceException {
126 public String getTenantIdFromVserverUrl(URL url) {
131 public String getCloudOwnerFromVserverUrl(URL url) {
136 public String getCloudRegionFromVserverUrl(URL url) {
141 public String getVServerIdFromVserverUrl(URL url, String s) {
146 public Vserver requestVServerDataByURL(URL url) throws AAIServiceException {
151 public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException {
156 public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException {
161 public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException {
166 public Complex requestNetworkComplexData(String s) throws AAIServiceException {
171 public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException {
176 public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException {
181 public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException {
186 public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException {
191 public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
196 public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
201 public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException {
206 public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
211 public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException {
216 public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
221 public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
226 public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
231 public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
236 public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
241 public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
246 public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
251 public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
256 public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
261 public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
266 public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
271 public GenericVnf requestGenericVnfData(String s) throws AAIServiceException {
276 public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException {
281 public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException {
286 public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException {
291 public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException {
296 public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException {
301 public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException {
306 public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException {
311 public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException {
316 public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException {
321 public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException {
326 public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException {
331 public PServer requestPServerData(String s) throws AAIServiceException {
336 public boolean postPServerData(String s, PServer pServer) throws AAIServiceException {
341 public boolean deletePServerData(String s, String s1) throws AAIServiceException {
346 public L3Network requestL3NetworkData(String s) throws AAIServiceException {
351 public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException {
356 public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException {
361 public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException {
366 public VpnBinding requestVpnBindingData(String s) throws AAIServiceException {
371 public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException {
376 public VnfImage requestVnfImageData(String s) throws AAIServiceException {
381 public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException {
386 public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException {
391 public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException {
396 public SitePairSet requestSitePairSetData(String s) throws AAIServiceException {
401 public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException {
406 public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException {
411 public Service requestServiceData(String s) throws AAIServiceException {
416 public boolean postServiceData(String s, Service service) throws AAIServiceException {
421 public boolean deleteServiceData(String s, String s1) throws AAIServiceException {
426 public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException {
431 public String requestDataByURL(URL url) throws AAIServiceException {
436 public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException {
441 public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException {
446 public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException {
451 public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException {
456 public boolean updateAnAIEntry(Update update) throws AAIServiceException {
461 public QueryStatus backup(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
466 public QueryStatus restore(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
471 public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
476 public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
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());
486 return QueryStatus.SUCCESS;
489 } else if (key.equals("vnf-id = 'test_VNF1'")){
490 return QueryStatus.NOT_FOUND;
492 else if (key.equals("vnf-id = 'test_VNF3'")){
493 throw new SvcLogicException();
496 return QueryStatus.FAILURE;
503 public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException {
508 public QueryStatus save(String s, boolean b, boolean b1, String s1, Map<String, String> map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
513 public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
518 public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
523 public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
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());
533 return QueryStatus.SUCCESS;
536 } else if (key.equals("vnf-id = 'test_VNF1'")){
537 return QueryStatus.NOT_FOUND;
539 else if (key.equals("vnf-id = 'test_VNF3'")){
540 throw new SvcLogicException();
543 return QueryStatus.FAILURE;