From 7a63f7756894e17b00e6adfa751ca90564d02ade Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 27 Nov 2018 16:34:58 +0530 Subject: added test case to TestConvertNode.java to increase code coverage Issue-ID: APPC-1086 Change-Id: Ia5890e45849fad0a17753fe03c217a60777a8945 Signed-off-by: Sandeep J --- .../config/generator/convert/TestConvertNode.java | 53 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'appc-config/appc-config-generator/provider/src') diff --git a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/convert/TestConvertNode.java b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/convert/TestConvertNode.java index b084ba3bb..c9cdad7fa 100644 --- a/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/convert/TestConvertNode.java +++ b/appc-config/appc-config-generator/provider/src/test/java/org/onap/sdnc/config/generator/convert/TestConvertNode.java @@ -6,7 +6,7 @@ * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= - * Modification Copyright (C) 2018 IBM. + * Modifications Copyright (C) 2018 IBM. * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,6 +162,29 @@ public class TestConvertNode { } + @Test(expected = SvcLogicException.class) + public void testunEscapeDataForInvalidDataType() throws Exception { + ConvertNode convertNode = new ConvertNode(); + Map inParams = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_UNESCAPE_DATA, "//"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "TXT"); + convertNode.escapeData(inParams, ctx); + + } + + @Test(expected = SvcLogicException.class) + public void testunEscapeDataForEmptyDataType() throws Exception { + ConvertNode convertNode = new ConvertNode(); + Map inParams = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_UNESCAPE_DATA, "//"); + convertNode.escapeData(inParams, ctx); + + } + @Test public void testEscapeDataForValidUnescapeDataString() throws Exception { SvcLogicContext ctx = new SvcLogicContext(); @@ -175,4 +198,32 @@ public class TestConvertNode { convertNode.escapeData(inParams, ctx); assertEquals(unescapeData, ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_ESCAPE_DATA)); } + + @Test + public void testunEscapeDataForJsonDataType() throws Exception { + ConvertNode convertNode = new ConvertNode(); + Map inParams = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + log.trace("Received unEscapeData call with params : " + inParams); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_ESCAPE_DATA, "//"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "JSON"); + convertNode.unEscapeData(inParams, ctx); + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute("tmp." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + + } + + @Test + public void testunEscapeDataForXmlDataType() throws Exception { + ConvertNode convertNode = new ConvertNode(); + Map inParams = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + log.trace("Received unEscapeData call with params : " + inParams); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX, "tmp"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_ESCAPE_DATA, "//"); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_DATA_TYPE, "XML"); + convertNode.unEscapeData(inParams, ctx); + assertEquals(ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,ctx.getAttribute("tmp." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + } + } -- cgit 1.2.3-korg