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 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;
35 public class TestConfigResourceNode {
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);
46 @Test(expected = Exception.class)
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");
55 ConfigResourceNode dbService = new ConfigResourceNode();
56 Map<String, String> map = new HashMap<String, String>();
57 dbService.getTemplate(map, ctx);
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);
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);
82 @Test(expected = Exception.class)
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);
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);
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);
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);
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);
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);