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 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
26 package org.onap.sdnc.config.generator.writer;
28 import static org.junit.Assert.assertEquals;
29 import java.util.HashMap;
31 import org.junit.Test;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
33 import org.onap.sdnc.config.generator.ConfigGeneratorConstant;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
36 public class TestFileWriterNode {
39 public void writeFile() throws Exception {
40 FileWriterNode FileWriterNode = new FileWriterNode();
41 Map<String, String> inParams = new HashMap<String, String>();
42 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME,
43 "src/test/resources/writer/testcvaas.json");
44 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_DATA,
45 "{'name':'Name','role':'admin'}");
46 inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test");
47 SvcLogicContext ctx = new SvcLogicContext();
48 FileWriterNode.writeFile(inParams, ctx);
49 assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,
50 ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));
53 @Test(expected=SvcLogicException.class)
54 public void testWriteFileForEmptyParams() throws Exception {
55 FileWriterNode FileWriterNode = new FileWriterNode();
56 Map<String, String> inParams = new HashMap<String, String>();
57 SvcLogicContext ctx = new SvcLogicContext();
58 FileWriterNode.writeFile(inParams, ctx);