diff options
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java')
-rw-r--r-- | appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java index 848632b31..4767d8fbc 100644 --- a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java +++ b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/pattern/TestPatternNode.java @@ -8,6 +8,8 @@ * ============================================================================= * Modifications Copyright (C) 2018 IBM. * ============================================================================= + * 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. * You may obtain a copy of the License at @@ -29,13 +31,18 @@ import static org.junit.Assert.assertEquals; 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; public class TestPatternNode { + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + @Test public void parseErrorLog() throws Exception { PatternNode patternNode = new PatternNode(); @@ -47,22 +54,19 @@ public class TestPatternNode { inParams.put(ConfigGeneratorConstant.INPUT_PARAM_LOG_DATA, logData); SvcLogicContext ctx = new SvcLogicContext(); patternNode.parseErrorLog(inParams, ctx); - assertEquals(ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS), - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); - + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); } - - @Test(expected= SvcLogicException.class) + + @Test public void testParseErrorLogForEmptyLogData() throws Exception { PatternNode patternNode = new PatternNode(); Map<String, String> inParams = new HashMap<String, String>(); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test"); - String logData = IOUtils.toString( - TestPatternNode.class.getClassLoader().getResourceAsStream("pattern/errorlog.txt"), - ConfigGeneratorConstant.STRING_ENCODING); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, ""); SvcLogicContext ctx = new SvcLogicContext(); + expectedEx.expect(SvcLogicException.class); + expectedEx.expectMessage("Log Data is missing"); patternNode.parseErrorLog(inParams, ctx); - } @@ -71,7 +75,6 @@ public class TestPatternNode { PatternNode patternNode = new PatternNode(); Map<String, String> inParams = new HashMap<String, String>(); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test"); - String xmlData = IOUtils.toString( TestPatternNode.class.getClassLoader().getResourceAsStream("pattern/xml_data.xml"), ConfigGeneratorConstant.STRING_ENCODING); @@ -97,7 +100,7 @@ public class TestPatternNode { ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } - @Test(expected = Exception.class) + @Test public void checStringData() throws Exception { PatternNode patternNode = new PatternNode(); Map<String, String> inParams = new HashMap<String, String>(); @@ -107,19 +110,19 @@ public class TestPatternNode { ConfigGeneratorConstant.STRING_ENCODING); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_CHECK_DATA, stringData); SvcLogicContext ctx = new SvcLogicContext(); + expectedEx.expect(SvcLogicException.class); + expectedEx.expectMessage("Check Data is missing"); patternNode.checkDataType(inParams, ctx); - assertEquals(ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS), - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } - + @Test public void testCheckDataType() throws Exception { PatternNode patternNode = new PatternNode(); Map<String, String> inParams = new HashMap<String, String>(); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "test"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, ""); inParams.put(ConfigGeneratorConstant.INPUT_PARAM_CHECK_DATA, "testData"); SvcLogicContext ctx = new SvcLogicContext(); patternNode.checkDataType(inParams, ctx); - assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute(ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); } } |