ee4db30b84d08195a5470340ebcd034fbf46813e
[appc.git] / appc-config / appc-data-services / provider / src / test / java / org / openecomp / appc / data / services / db / TestConfigResourceNode.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 package org.openecomp.appc.data.services.db;
26
27 import java.util.HashMap;
28 import java.util.Map;
29 import static org.junit.Assert.assertFalse;
30 import org.junit.Test;
31 import org.openecomp.appc.data.services.AppcDataServiceConstant;
32 import org.openecomp.appc.data.services.node.ConfigResourceNode;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
35
36 public class TestConfigResourceNode {
37
38     @Test(expected = Exception.class)
39     public void testgetConfigFileReferenc() throws SvcLogicException {
40         SvcLogicContext ctx = new SvcLogicContext();
41         ctx.setAttribute("test", "test");
42         ConfigResourceNode dbService = new ConfigResourceNode();
43         Map<String, String> map = new HashMap<String, String>();
44         dbService.getConfigFileReference(map, ctx);
45     }
46
47     @Test(expected = Exception.class)
48
49     public void testgetTemplate() throws SvcLogicException {
50         SvcLogicContext ctx = new SvcLogicContext();
51         ctx.setAttribute("test", "test");
52         ctx.setAttribute(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "test");
53         ctx.setAttribute(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
54         ctx.setAttribute("template-name", "test.json");
55
56         ConfigResourceNode dbService = new ConfigResourceNode();
57         Map<String, String> map = new HashMap<String, String>();
58         dbService.getTemplate(map, ctx);
59
60     }
61
62     @Test(expected = Exception.class)
63     public void testgetVnfcReference() throws SvcLogicException {
64         SvcLogicContext ctx = new SvcLogicContext();
65         ctx.setAttribute("test", "test");
66         ConfigResourceNode dbService = new ConfigResourceNode();
67         Map<String, String> map = new HashMap<String, String>();
68         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
69         dbService.getVnfcReference(map, ctx);
70     }
71
72     @Test(expected = Exception.class)
73     public void testgetSmmChainKeyFiles() throws SvcLogicException {
74         SvcLogicContext ctx = new SvcLogicContext();
75         ctx.setAttribute("test", "test");
76         ctx.setAttribute("site-location","test/location");
77         ConfigResourceNode dbService = new ConfigResourceNode();
78         Map<String, String> map = new HashMap<String, String>();
79         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
80         dbService.getSmmChainKeyFiles(map, ctx);
81     }
82
83     @Test(expected = Exception.class)
84
85     public void testgetDownloadConfigTemplateByVnf() throws SvcLogicException {
86         SvcLogicContext ctx = new SvcLogicContext();
87         ctx.setAttribute("test", "test");    
88         ConfigResourceNode dbService = new ConfigResourceNode();
89         Map<String, String> map = new HashMap<String, String>();
90         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
91         dbService.getDownloadConfigTemplateByVnf(map, ctx);
92
93     }
94
95     @Test(expected = Exception.class)
96     public void testgetCommonConfigInfo() throws SvcLogicException {
97         SvcLogicContext ctx = new SvcLogicContext();
98         ctx.setAttribute("test", "test");
99         ConfigResourceNode dbService = new ConfigResourceNode();
100         Map<String, String> map = new HashMap<String, String>();
101         dbService.getCommonConfigInfo(map, ctx);
102
103     }
104
105     @Test(expected = Exception.class)
106     public void testupdateUploadConfigss() throws SvcLogicException {
107         SvcLogicContext ctx = new SvcLogicContext();
108         ctx.setAttribute("test", "test");
109         ConfigResourceNode dbService = new ConfigResourceNode();
110         Map<String, String> map = new HashMap<String, String>();
111         dbService.updateUploadConfig(map, ctx);
112
113     }
114
115     @Test(expected = Exception.class)
116     public void testgetConfigFilesByVnfVmNCategory() throws SvcLogicException {
117         SvcLogicContext ctx = new SvcLogicContext();
118         ConfigResourceNode node = new ConfigResourceNode();
119         Map<String, String> inParams = new HashMap<String, String>();
120         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
121         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "config_template");
122         inParams.put((String) AppcDataServiceConstant.INPUT_PARAM_VNF_ID, "test");
123         inParams.put((String) AppcDataServiceConstant.INPUT_PARAM_VM_NAME, "test");
124         node.getConfigFilesByVnfVmNCategory(inParams, ctx);
125     }
126
127     @Test(expected = Exception.class)
128     public void testsaveConfigTransactionLog() throws SvcLogicException {
129         SvcLogicContext ctx = new SvcLogicContext();
130         ConfigResourceNode node = new ConfigResourceNode();
131         Map<String, String> inParams = new HashMap<String, String>();
132         inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE, "testMessage");
133         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
134         inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE_TYPE, "testmessage");
135         ctx.setAttribute("request-id", "tets-id");
136         node.saveConfigTransactionLog(inParams, ctx);
137
138     }
139
140     @Test(expected = Exception.class)
141     public void testsaveConfigBlock() throws SvcLogicException {
142         SvcLogicContext ctx = new SvcLogicContext();
143         ConfigResourceNode node = new ConfigResourceNode();
144         Map<String, String> inParams = new HashMap<String, String>();
145         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp");
146         ctx.setAttribute("configuration", "test");
147         ctx.setAttribute("tmp.convertconfig.escapeData", "test");
148         ctx.setAttribute("tmp.merge.mergedData", "test");
149         node.saveConfigBlock(inParams, ctx);
150     }
151
152     @Test
153     public void testcheckIfCapabilityCheckNeeded ()  throws Exception {
154         ConfigResourceNode node = new ConfigResourceNode();
155         String findCapability="Start";
156         String capLevel="vnf";
157         boolean result=node.checkIfCapabilityCheckNeeded(capLevel,findCapability);
158         assertFalse(result);
159     }
160
161 }