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