2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Modfication Copyright (C) 2018 IBM.
10 * ================================================================================
11 * Modifications Copyright (C) 2019 Ericsson
12 * =============================================================================
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
17 * http://www.apache.org/licenses/LICENSE-2.0
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
25 * ============LICENSE_END=========================================================
28 package org.onap.sdnc.config.generator.writer;
30 import static org.junit.Assert.assertEquals;
31 import java.util.HashMap;
33 import org.junit.Test;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
35 import org.onap.sdnc.config.generator.ConfigGeneratorConstant;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
38 public class TestFileWriterNode {
41 public void writeFile() throws Exception {
42 FileWriterNode FileWriterNode = new FileWriterNode();
43 Map<String, String> inParams = new HashMap<String, String>();
44 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME,
45 "src/test/resources/writer/testcvaas.json");
46 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_DATA,
47 "{'name':'Name','role':'admin'}");
48 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
49 SvcLogicContext ctx = new SvcLogicContext();
50 FileWriterNode.writeFile(inParams, ctx);
51 assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,
52 ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
56 public void writeFileForLongParameters() throws Exception {
57 FileWriterNode FileWriterNode = new FileWriterNode();
58 Map<String, String> inParams = new HashMap<String, String>();
59 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME,
60 "src/test/resources/writer/testcvaas.json");
61 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_DATA,
62 "{'name':'Name','role':'admin'}");
63 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
64 inParams.put("TEST", "Lorem ipsum dolor sit amet, prompta mediocrem quo an, eos odio esse pertinax an."
65 + " Vis timeam suscipiantur no, eos ex vidisse appareat. Vel ipsum verterem in, qui eu cetero"
66 + " vituperatoribus. Semper insolens contentiones mei ea, vitae persius suavitate no quo, prompta"
67 + " impedit minimum cu sed. Everti disputationi id eam, essent.");
68 SvcLogicContext ctx = new SvcLogicContext();
69 FileWriterNode.writeFile(inParams, ctx);
70 assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,
71 ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
74 @Test(expected = SvcLogicException.class)
75 public void testWriteFileForEmptyParams() throws Exception {
76 FileWriterNode FileWriterNode = new FileWriterNode();
77 Map<String, String> inParams = new HashMap<String, String>();
78 SvcLogicContext ctx = new SvcLogicContext();
79 FileWriterNode.writeFile(inParams, ctx);