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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
26 package org.onap.appc.aai.client.node;
28 import static junit.framework.Assert.assertEquals;
30 import java.util.HashMap;
33 import org.apache.commons.lang3.StringUtils;
34 import org.onap.appc.aai.client.AppcAaiClientConstant;
35 //import org.onap.appc.aai.client.aai.AAIClientMock;
36 import org.onap.appc.aai.client.aai.AaiService;
38 import com.att.eelf.configuration.EELFLogger;
39 import com.att.eelf.configuration.EELFManager;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
42 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
43 import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
45 public class MockAaiService extends AaiService {
48 private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
49 private AAIClient aaiClient;
51 /*public MockAaiService() {
52 super(new AAIClientMock());
56 public MockAaiService(AAIClient aaic) {
60 public void getVMInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
61 log.info("Received Mock getVmInfo call with params : " + params);
62 String vserverId = params.get("vserverId");
63 String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
64 if (vserverId.equals("ibcm0001id")) {
65 ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
66 ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
68 ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
69 ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
70 ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
76 public void getVnfcInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
77 log.info("Received Mock getVmInfo call with params : " + params);
78 String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
80 String vnfcName = params.get("vnfcName");
82 if (vnfcName.equals("vnfcName2")) {
83 ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
84 ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
85 ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
92 public SvcLogicContext readResource(String query, String prefix, String resourceType) throws SvcLogicException {
93 SvcLogicContext resourceContext = new SvcLogicContext();
94 resourceContext.setAttribute("vfModuleInfo.model-invariant-id", "invid01");
95 resourceContext.setAttribute("vfModuleInfo.model-version-id", "versid01");
96 resourceContext.setAttribute("modelInfo.model-name", "model0001");
98 return resourceContext;