ac7a6735d4527d1060a87da01777f88951f2d07f
[appc.git] / appc-outbound / appc-aai-client / provider / src / test / java / org / openecomp / appc / aai / client / node / MockAaiService.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25
26 package org.openecomp.appc.aai.client.node;
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.openecomp.appc.aai.client.AppcAaiClientConstant;
34 //import org.openecomp.appc.aai.client.aai.AAIClientMock;
35 import org.openecomp.appc.aai.client.aai.AaiService;
36
37 import com.att.eelf.configuration.EELFLogger;
38 import com.att.eelf.configuration.EELFManager;
39 import org.openecomp.sdnc.sli.SvcLogicContext;
40 import org.openecomp.sdnc.sli.aai.AAIClient;
41
42 public class MockAaiService extends AaiService {
43     
44     // ONAP merging
45     private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
46          private AAIClient aaiClient;
47            
48          /*public MockAaiService() {
49               super(new AAIClientMock());
50          }*/
51          
52
53          public MockAaiService(AAIClient aaic) {
54              super(aaic);
55          }
56         
57         public void getVMInfo(Map<String, String> params,SvcLogicContext ctx )     throws Exception {
58             log.info("Received Mock getVmInfo call with params : " + params);
59             String vserverId =  params.get("vserverId");
60             String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
61             if ( vserverId.equals("ibcm0001id")) {
62                 ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
63                 ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
64             }
65             else {
66                 ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
67                 ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
68                 ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
69             }
70                 
71         }
72          
73         
74         public void getVnfcInfo(Map<String, String> params,SvcLogicContext ctx )     throws Exception {
75             log.info("Received Mock getVmInfo call with params : " + params);
76             String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
77             
78             String vnfcName =  params.get("vnfcName");
79             
80             if ( vnfcName.equals("vnfcName2") ) {
81                 ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
82                 ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
83                 ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
84             }
85         
86         
87         }
88 }