* ================================================================================
* 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.
}
+ @Test(expected = SvcLogicException.class)
+ public void testunEscapeDataForInvalidDataType() throws Exception {
+ ConvertNode convertNode = new ConvertNode();
+ Map<String, String> inParams = new HashMap<String, String>();
+ 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<String, String> inParams = new HashMap<String, String>();
+ 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();
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<String, String> inParams = new HashMap<String, String>();
+ 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<String, String> inParams = new HashMap<String, String>();
+ 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));
+ }
+
}