Update license header in appc oam and outbound
[appc.git] / appc-outbound / appc-aai-client / provider / src / test / java / org / onap / appc / aai / client / node / MockAaiService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  * ============LICENSE_END=========================================================
22  */
23
24
25 package org.onap.appc.aai.client.node;
26
27 import static junit.framework.Assert.assertEquals;
28
29 import java.util.HashMap;
30 import java.util.Map;
31
32 import org.apache.commons.lang3.StringUtils;
33 import org.onap.appc.aai.client.AppcAaiClientConstant;
34 //import org.onap.appc.aai.client.aai.AAIClientMock;
35 import org.onap.appc.aai.client.aai.AaiService;
36
37 import com.att.eelf.configuration.EELFLogger;
38 import com.att.eelf.configuration.EELFManager;
39 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
42 import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
43
44 public class MockAaiService extends AaiService {
45
46     // ONAP merging
47     private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
48     private AAIClient aaiClient;
49
50          /*public MockAaiService() {
51               super(new AAIClientMock());
52          }*/
53
54
55     public MockAaiService(AAIClient aaic) {
56         super(aaic);
57     }
58
59     public void getVMInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
60         log.info("Received Mock getVmInfo call with params : " + params);
61         String vserverId = params.get("vserverId");
62         String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
63         if (vserverId.equals("ibcm0001id")) {
64             ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
65             ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
66         } else {
67             ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
68             ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
69             ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
70         }
71
72     }
73
74
75     public void getVnfcInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
76         log.info("Received Mock getVmInfo call with params : " + params);
77         String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
78
79         String vnfcName = params.get("vnfcName");
80
81         if (vnfcName.equals("vnfcName2")) {
82             ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
83             ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
84             ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
85         }
86
87
88     }
89
90     @Override
91     public SvcLogicContext readResource(String query, String prefix, String resourceType) throws SvcLogicException {
92         SvcLogicContext resourceContext = new SvcLogicContext();
93         resourceContext.setAttribute("vfModuleInfo.model-invariant-id", "invid01");
94         resourceContext.setAttribute("vfModuleInfo.model-version-id", "versid01");
95         resourceContext.setAttribute("modelInfo.model-name", "model0001");
96
97         return resourceContext;
98     }
99 }