2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.appc.dg.aai.impl;
25 import java.util.HashMap;
28 import org.openecomp.sdnc.sli.SvcLogicContext;
29 import org.openecomp.sdnc.sli.SvcLogicException;
30 import org.openecomp.sdnc.sli.SvcLogicResource;
31 import org.openecomp.sdnc.sli.aai.AAIClient;
32 import org.openecomp.sdnc.sli.aai.AAIServiceException;
33 import org.openecomp.sdnc.sli.aai.data.*;
34 import org.openecomp.sdnc.sli.aai.data.notify.NotifyEvent;
35 import org.openecomp.sdnc.sli.aai.data.v1507.VServer;
36 import org.openecomp.sdnc.sli.aai.update.Update;
39 public class AAIClientMock implements AAIClient {
41 Map<String, String> mockAAI = new HashMap<>();
43 public void setMockAAI(Map<String, String> mockAAI) {
44 this.mockAAI = mockAAI;
48 public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException {
53 public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException {
58 public Vce requestNetworkVceData(String s) throws AAIServiceException {
63 public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException {
68 public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException {
73 public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException {
78 public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException {
83 public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException {
88 public Vpe requestNetworkVpeData(String s) throws AAIServiceException {
93 public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException {
98 public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException {
103 public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException {
108 public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException {
113 public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException {
118 public URL requestVserverURLNodeQuery(String s) throws AAIServiceException {
123 public String getTenantIdFromVserverUrl(URL url) {
128 public String getCloudOwnerFromVserverUrl(URL url) {
133 public String getCloudRegionFromVserverUrl(URL url) {
138 public String getVServerIdFromVserverUrl(URL url, String s) {
143 public Vserver requestVServerDataByURL(URL url) throws AAIServiceException {
148 public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException {
153 public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException {
158 public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException {
163 public Complex requestNetworkComplexData(String s) throws AAIServiceException {
168 public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException {
173 public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException {
178 public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException {
183 public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException {
188 public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException {
193 public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException {
198 public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException {
203 public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException {
208 public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException {
213 public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException {
218 public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException {
223 public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException {
228 public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException {
233 public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException {
238 public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException {
243 public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException {
248 public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException {
253 public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException {
258 public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException {
263 public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException {
268 public GenericVnf requestGenericVnfData(String s) throws AAIServiceException {
273 public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException {
278 public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException {
283 public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException {
288 public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException {
293 public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException {
298 public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException {
303 public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException {
308 public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException {
313 public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException {
318 public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException {
323 public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException {
328 public PServer requestPServerData(String s) throws AAIServiceException {
333 public boolean postPServerData(String s, PServer pServer) throws AAIServiceException {
338 public boolean deletePServerData(String s, String s1) throws AAIServiceException {
343 public L3Network requestL3NetworkData(String s) throws AAIServiceException {
348 public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException {
353 public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException {
358 public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException {
363 public VpnBinding requestVpnBindingData(String s) throws AAIServiceException {
368 public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException {
373 public VnfImage requestVnfImageData(String s) throws AAIServiceException {
378 public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException {
383 public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException {
388 public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException {
393 public SitePairSet requestSitePairSetData(String s) throws AAIServiceException {
398 public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException {
403 public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException {
408 public Service requestServiceData(String s) throws AAIServiceException {
413 public boolean postServiceData(String s, Service service) throws AAIServiceException {
418 public boolean deleteServiceData(String s, String s1) throws AAIServiceException {
423 public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException {
428 public String requestDataByURL(URL url) throws AAIServiceException {
433 public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException {
438 public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException {
443 public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException {
448 public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException {
453 public boolean updateAnAIEntry(Update update) throws AAIServiceException {
458 public QueryStatus backup(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
463 public QueryStatus restore(Map<String, String> map, SvcLogicContext svcLogicContext) throws SvcLogicException {
468 public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
473 public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
478 public QueryStatus query(String s, boolean b, String s1, String key, String prefix, String s4, SvcLogicContext ctx) throws SvcLogicException {
479 if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
480 for (Map.Entry<String, String> entry : mockAAI.entrySet()) {
481 ctx.setAttribute(prefix + "." + entry.getKey(), entry.getValue());
483 return QueryStatus.SUCCESS;
486 } else if (key.equals("vnf-id = 'test_VNF1'")){
487 return QueryStatus.NOT_FOUND;
489 else if (key.equals("vnf-id = 'test_VNF3'")){
490 throw new SvcLogicException();
493 return QueryStatus.FAILURE;
500 public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException {
505 public QueryStatus save(String s, boolean b, boolean b1, String s1, Map<String, String> map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException {
510 public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
515 public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
520 public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException {
525 public QueryStatus update(String s, String key, Map<String, String> data, String prefix, SvcLogicContext ctx) throws SvcLogicException {
526 if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) {
527 for (Map.Entry<String, String> entry : data.entrySet()) {
528 mockAAI.put(entry.getKey(), entry.getValue());
530 return QueryStatus.SUCCESS;
533 } else if (key.equals("vnf-id = 'test_VNF1'")){
534 return QueryStatus.NOT_FOUND;
536 else if (key.equals("vnf-id = 'test_VNF3'")){
537 throw new SvcLogicException();
540 return QueryStatus.FAILURE;