2 * ============LICENSE_START=======================================================
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
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=========================================================
25 package org.onap.appc.data.services.db;
27 import java.util.ArrayList;
28 import java.util.HashMap;
30 import static org.junit.Assert.assertFalse;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.onap.appc.data.services.AppcDataServiceConstant;
34 import org.onap.appc.data.services.node.ConfigResourceNode;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
38 import com.fasterxml.jackson.databind.JsonNode;
39 import com.fasterxml.jackson.databind.ObjectMapper;
40 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
41 import com.fasterxml.jackson.databind.node.ObjectNode;
42 import static org.junit.Assert.assertEquals;
43 import static org.junit.Assert.assertFalse;
45 public class TestConfigResourceNode {
47 @Ignore("Test is taking 60 seconds")
48 @Test(expected = Exception.class)
49 public void testgetConfigFileReferenc() throws SvcLogicException {
50 SvcLogicContext ctx = new SvcLogicContext();
51 ctx.setAttribute("test", "test");
52 ConfigResourceNode dbService = new ConfigResourceNode();
53 Map<String, String> map = new HashMap<String, String>();
54 dbService.getConfigFileReference(map, ctx);
57 @Ignore("Test is taking 60 seconds")
58 @Test(expected = Exception.class)
59 public void testgetTemplate() throws SvcLogicException {
60 SvcLogicContext ctx = new SvcLogicContext();
61 ctx.setAttribute("test", "test");
62 ctx.setAttribute(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "test");
63 ctx.setAttribute(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
64 ctx.setAttribute("template-name", "test.json");
66 ConfigResourceNode dbService = new ConfigResourceNode();
67 Map<String, String> map = new HashMap<String, String>();
68 dbService.getTemplate(map, ctx);
72 @Ignore("Test is taking 60 seconds")
73 @Test(expected = Exception.class)
74 public void testgetVnfcReference() throws SvcLogicException {
75 SvcLogicContext ctx = new SvcLogicContext();
76 ctx.setAttribute("test", "test");
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.getVnfcReference(map, ctx);
83 @Ignore("Test is taking 60 seconds")
84 @Test(expected = Exception.class)
85 public void testgetSmmChainKeyFiles() throws SvcLogicException {
86 SvcLogicContext ctx = new SvcLogicContext();
87 ctx.setAttribute("test", "test");
88 ctx.setAttribute("site-location","test/location");
89 ConfigResourceNode dbService = new ConfigResourceNode();
90 Map<String, String> map = new HashMap<String, String>();
91 map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
92 dbService.getSmmChainKeyFiles(map, ctx);
95 @Ignore("Test is taking 60 seconds")
96 @Test(expected = Exception.class)
97 public void testgetDownloadConfigTemplateByVnf() throws SvcLogicException {
98 SvcLogicContext ctx = new SvcLogicContext();
99 ctx.setAttribute("test", "test");
100 ConfigResourceNode dbService = new ConfigResourceNode();
101 Map<String, String> map = new HashMap<String, String>();
102 map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
103 dbService.getDownloadConfigTemplateByVnf(map, ctx);
107 @Ignore("Test is taking 60 seconds")
108 @Test(expected = Exception.class)
109 public void testgetCommonConfigInfo() throws SvcLogicException {
110 SvcLogicContext ctx = new SvcLogicContext();
111 ctx.setAttribute("test", "test");
112 ConfigResourceNode dbService = new ConfigResourceNode();
113 Map<String, String> map = new HashMap<String, String>();
114 dbService.getCommonConfigInfo(map, ctx);
118 @Ignore("Test is taking 60 seconds")
119 @Test(expected = Exception.class)
120 public void testupdateUploadConfigss() throws SvcLogicException {
121 SvcLogicContext ctx = new SvcLogicContext();
122 ctx.setAttribute("test", "test");
123 ConfigResourceNode dbService = new ConfigResourceNode();
124 Map<String, String> map = new HashMap<String, String>();
125 dbService.updateUploadConfig(map, ctx);
129 @Ignore("Test is taking 60 seconds")
130 @Test(expected = Exception.class)
131 public void testgetConfigFilesByVnfVmNCategory() throws SvcLogicException {
132 SvcLogicContext ctx = new SvcLogicContext();
133 ConfigResourceNode node = new ConfigResourceNode();
134 Map<String, String> inParams = new HashMap<String, String>();
135 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
136 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "config_template");
137 inParams.put((String) AppcDataServiceConstant.INPUT_PARAM_VNF_ID, "test");
138 inParams.put((String) AppcDataServiceConstant.INPUT_PARAM_VM_NAME, "test");
139 node.getConfigFilesByVnfVmNCategory(inParams, ctx);
142 @Ignore("Test is taking 60 seconds")
143 @Test(expected = Exception.class)
144 public void testsaveConfigTransactionLog() throws SvcLogicException {
145 SvcLogicContext ctx = new SvcLogicContext();
146 ConfigResourceNode node = new ConfigResourceNode();
147 Map<String, String> inParams = new HashMap<String, String>();
148 inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE, "testMessage");
149 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
150 inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE_TYPE, "testmessage");
151 ctx.setAttribute("request-id", "tets-id");
152 node.saveConfigTransactionLog(inParams, ctx);
156 @Ignore("Test is taking 60 seconds")
157 @Test(expected = Exception.class)
158 public void testsaveConfigBlock() throws SvcLogicException {
159 SvcLogicContext ctx = new SvcLogicContext();
160 ConfigResourceNode node = new ConfigResourceNode();
161 Map<String, String> inParams = new HashMap<String, String>();
162 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp");
163 ctx.setAttribute("configuration", "test");
164 ctx.setAttribute("tmp.convertconfig.escapeData", "test");
165 ctx.setAttribute("tmp.merge.mergedData", "test");
166 node.saveConfigBlock(inParams, ctx);
170 public void testProcessCapabilitiesForVMLevel () throws Exception {
171 //{"capabilities":{"vnfc":[],"vm":[{"ConfigureTest":["SSC","MMSC"]}],"vf-module":[],"vnf":["ConfigModify","HealthCheck"]}}
172 SvcLogicContext ctx = new SvcLogicContext();
173 ConfigResourceNode node = new ConfigResourceNode();
174 String findCapability="Restart";
175 JsonNode subCapabilities = JsonNodeFactory.instance.objectNode();
176 String subCaps= "[{\"Restart\":[\"SSC\",\"MMC\"]},{\"Rebuild\":[\"SSC\"]},{\"Migrate\":[\"SSC\"]},{\"Snapshot\":[\"SSC\"]},{\"Start\":[\"SSC\"]},{\"Stop\":[\"SSC\"]}]";
177 ObjectMapper m = new ObjectMapper();
178 subCapabilities = m.readTree(subCaps);
179 String vServerId="testServer";
180 ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-function-code", "MMC");
181 ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-name","testVnfc") ;
182 node.processCapabilitiesForVMLevel( vServerId, ctx,
183 findCapability, subCapabilities);
184 String result=ctx.getAttribute("capabilities");
185 assertEquals(result,"Supported");
189 public void testcheckIfCapabilityCheckNeeded () throws Exception {
190 ConfigResourceNode node = new ConfigResourceNode();
191 String findCapability="Start";
192 String capLevel="vnf";
193 boolean result=node.checkIfCapabilityCheckNeeded(capLevel,findCapability);