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.openecomp.appc.data.services.db;
27 import java.util.HashMap;
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;
36 public class TestConfigResourceNode {
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);
47 @Test(expected = Exception.class)
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");
56 ConfigResourceNode dbService = new ConfigResourceNode();
57 Map<String, String> map = new HashMap<String, String>();
58 dbService.getTemplate(map, ctx);
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);
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);
83 @Test(expected = Exception.class)
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);
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);
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);
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);
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);
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);
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);