diff options
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java')
-rw-r--r-- | appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java index 80d8cdc80..4ca246ac0 100644 --- a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java +++ b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/reader/TestReaderNode.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications Copyright (C) 2018 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,26 +25,45 @@ package org.onap.sdnc.config.generator.reader; +import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.apache.commons.io.IOUtils; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.sdnc.config.generator.ConfigGeneratorConstant; -import org.onap.sdnc.config.generator.merge.TestMergeNode; public class TestReaderNode { - @Test(expected = Exception.class) - public void testGetFileData() throws SvcLogicException, IOException { + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void testGetFileDataSuccess() throws SvcLogicException, IOException { ReaderNode r = new ReaderNode(); Map<String, String> inParams = new HashMap<String, String>(); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test"); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME, - IOUtils.toString(TestMergeNode.class.getClassLoader() - .getResourceAsStream("convert/payload_cli_config.json"))); + "src/test/resources/convert/payload_cli_config.json"); + SvcLogicContext ctx = new SvcLogicContext(); + r.getFileData(inParams, ctx); + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + } + + @Test + public void testGetFileDataFailure() throws SvcLogicException, IOException { + ReaderNode r = new ReaderNode(); + Map<String, String> inParams = new HashMap<String, String>(); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, ""); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME, + "non_existent_filename"); SvcLogicContext ctx = new SvcLogicContext(); + expectedEx.expect(SvcLogicException.class); + expectedEx.expectMessage("File 'non_existent_filename' does not exist"); r.getFileData(inParams, ctx); } } |