From 280a0f6c73ab1c1aed9ee87fbd053d01d3838d70 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 12 Sep 2018 16:26:03 -0400 Subject: Controller Blueprints Nitrogen to Oxygen Migration Changing package structure from org.onap.ccsdk.config to org.onap.ccsdk.features Change-Id: I7d52b498f11ed892d547220cc4354298b6182c77 Issue-ID: CCSDK-560 Signed-off-by: Singal, Kapil (ks220y) --- .../generator/service/ConfigGeneratorNodeTest.java | 222 -------------------- .../config/generator/tool/EscapeUtilsTest.java | 51 ----- .../generator/service/ConfigGeneratorNodeTest.java | 223 +++++++++++++++++++++ .../features/generator/tool/EscapeUtilsTest.java | 52 +++++ .../service_templates/generate_configuration.json | 6 +- 5 files changed, 278 insertions(+), 276 deletions(-) delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/service/ConfigGeneratorNodeTest.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/tool/EscapeUtilsTest.java create mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java create mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java (limited to 'blueprints-processor/plugin/generator-provider/src/test') diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/service/ConfigGeneratorNodeTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/service/ConfigGeneratorNodeTest.java deleted file mode 100644 index 941387347..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/service/ConfigGeneratorNodeTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.config.generator.service; - -import static org.mockito.Matchers.any; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.config.generator.ConfigGeneratorConstant; -import org.onap.ccsdk.config.model.ConfigModelConstant; -import org.onap.ccsdk.config.model.service.ConfigModelService; -import org.onap.ccsdk.config.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.config.model.utils.TransformationUtils; -import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigGeneratorNodeTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNodeTest.class); - - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - private ConfigModelService configModelService; - - @Before - public void setUp() throws Exception { - - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - MockitoAnnotations.initMocks(this); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - - Mockito.doAnswer(new Answer>() { - @Override - public List answer(InvocationOnMock invocationOnMock) throws Throwable { - List configResources = new ArrayList<>(); - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - String resourceData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/configdata.json"), Charset.defaultCharset()); - ConfigResource configResource = (ConfigResource) args[0]; - configResource.setRecipeName("Sample-recipe"); - configResource.setResourceData(resourceData); - configResources.add(configResource); - } - return configResources; - } - }).when(configResourceService).getConfigResource(any(ConfigResource.class)); - - } catch (SvcLogicException e) { - e.printStackTrace(); - } - } - - @Test - public void testInputTemplateContentNData() throws Exception { - - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - - String jsonData = IOUtils.toString( - ConfigGeneratorNodeTest.class.getClassLoader().getResourceAsStream("service_templates/configdata.json"), - Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); - - String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); - - SvcLogicContext ctx = new SvcLogicContext(); - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inParams, ctx, componentContext); - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); - - } - - @Test - public void testInputTemplateWithNullData() throws Exception { - - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - - String jsonData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/configdata_with_null.json"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); - - String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); - - SvcLogicContext ctx = new SvcLogicContext(); - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inParams, ctx, componentContext); - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); - - } - - @Test - public void testDBTemplateContentNData() throws Exception { - - String fileContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/generate_configuration.json"), Charset.defaultCharset()); - - String baseConfigTemplateContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - context = configModelService.convertServiceTemplate2Properties(fileContent, context); - - context.put("node_templates.base-config-template.content", baseConfigTemplateContent); - - Assert.assertNotNull("Failed to Prepare Context : ", context); - - context.put("request-id", "12345"); - context.put("vnf-id", "vnf12345"); - context.put("action-name", "config-generator-action"); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - TransformationUtils.printMap(context); - configModelService.assignInParamsFromModel(inputContext, inparams); - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inparams, inputContext, componentContext); - - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - inputContext.getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", inputContext - .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " + inputContext - .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - } - - @Test - public void testTemplateContentNDataForMask() throws Exception { - - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/tool/EscapeUtilsTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/tool/EscapeUtilsTest.java deleted file mode 100644 index 0bd2384bf..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/config/generator/tool/EscapeUtilsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.config.generator.tool; - -import org.junit.Assert; -import org.junit.Test; - -public class EscapeUtilsTest { - - @Test - public void testEscapeSql() { - Assert.assertEquals("", EscapeUtils.escapeSql("")); - Assert.assertEquals("text", EscapeUtils.escapeSql("text")); - - Assert.assertEquals("''", EscapeUtils.escapeSql("'")); - Assert.assertEquals("\\\\", EscapeUtils.escapeSql("\\")); - - Assert.assertEquals("text''text", EscapeUtils.escapeSql("text'text")); - Assert.assertEquals("text\\\\text", EscapeUtils.escapeSql("text\\text")); - } - - @Test - public void testEscapeSequence() { - Assert.assertEquals("", EscapeUtils.escapeSequence("")); - Assert.assertEquals("text", EscapeUtils.escapeSequence("text")); - - Assert.assertEquals("\\\'", EscapeUtils.escapeSequence("'")); - Assert.assertEquals("\\\"", EscapeUtils.escapeSequence("\"")); - Assert.assertEquals("\\\\", EscapeUtils.escapeSequence("\\")); - - Assert.assertEquals("text\\\'text", EscapeUtils.escapeSequence("text'text")); - Assert.assertEquals("text\\\"text", EscapeUtils.escapeSequence("text\"text")); - Assert.assertEquals("text\\\\text", EscapeUtils.escapeSequence("text\\text")); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java new file mode 100644 index 000000000..58a22ac14 --- /dev/null +++ b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java @@ -0,0 +1,223 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.features.generator.service; + +import static org.mockito.Matchers.any; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.stubbing.Answer; +import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; +import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; +import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; +import org.onap.ccsdk.features.generator.ConfigGeneratorConstant; +import org.onap.ccsdk.features.generator.service.ConfigGeneratorNode; +import org.onap.ccsdk.features.model.ConfigModelConstant; +import org.onap.ccsdk.features.model.service.ConfigModelService; +import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; +import org.onap.ccsdk.features.model.utils.TransformationUtils; +import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +@RunWith(MockitoJUnitRunner.class) +public class ConfigGeneratorNodeTest { + + private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNodeTest.class); + + @Mock + private ConfigResourceService configResourceService; + + @Mock + private ConfigRestAdaptorService configRestAdaptorService; + + private ConfigModelService configModelService; + + @Before + public void setUp() throws Exception { + + configModelService = new ConfigModelServiceImpl(configRestAdaptorService); + + MockitoAnnotations.initMocks(this); + + try { + Mockito.doAnswer(new Answer() { + @Override + public Void answer(InvocationOnMock invocationOnMock) throws Throwable { + Object[] args = invocationOnMock.getArguments(); + if (args != null) { + logger.trace("Transaction info " + Arrays.asList(args)); + } + return null; + } + }).when(configResourceService).save(any(TransactionLog.class)); + + Mockito.doAnswer(new Answer>() { + @Override + public List answer(InvocationOnMock invocationOnMock) throws Throwable { + List configResources = new ArrayList<>(); + Object[] args = invocationOnMock.getArguments(); + if (args != null) { + logger.trace("Transaction info " + Arrays.asList(args)); + String resourceData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/configdata.json"), Charset.defaultCharset()); + ConfigResource configResource = (ConfigResource) args[0]; + configResource.setRecipeName("Sample-recipe"); + configResource.setResourceData(resourceData); + configResources.add(configResource); + } + return configResources; + } + }).when(configResourceService).getConfigResource(any(ConfigResource.class)); + + } catch (SvcLogicException e) { + e.printStackTrace(); + } + } + + @Test + public void testInputTemplateContentNData() throws Exception { + + ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); + + Map inParams = new HashMap(); + inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); + + String jsonData = IOUtils.toString( + ConfigGeneratorNodeTest.class.getClassLoader().getResourceAsStream("service_templates/configdata.json"), + Charset.defaultCharset()); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); + + String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); + + SvcLogicContext ctx = new SvcLogicContext(); + Map componentContext = new HashMap<>(); + configGeneratorNode.process(inParams, ctx, componentContext); + Assert.assertEquals("Failed to generate Configuration Status as Failure", + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + Assert.assertNotNull("Failed to generate Configuration", + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + + logger.trace("Generated Configuration:\n " + + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + logger.trace("Generated Configuration:\n " + + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); + + } + + @Test + public void testInputTemplateWithNullData() throws Exception { + + ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); + + Map inParams = new HashMap(); + inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); + + String jsonData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/configdata_with_null.json"), Charset.defaultCharset()); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); + + String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); + inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); + + SvcLogicContext ctx = new SvcLogicContext(); + Map componentContext = new HashMap<>(); + configGeneratorNode.process(inParams, ctx, componentContext); + Assert.assertEquals("Failed to generate Configuration Status as Failure", + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + Assert.assertNotNull("Failed to generate Configuration", + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + + logger.trace("Generated Configuration:\n " + + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + logger.trace("Generated Configuration:\n " + + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); + + } + + @Test + public void testDBTemplateContentNData() throws Exception { + + String fileContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/generate_configuration.json"), Charset.defaultCharset()); + + String baseConfigTemplateContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() + .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); + + Map context = new HashMap<>(); + context = configModelService.convertServiceTemplate2Properties(fileContent, context); + + context.put("node_templates.base-config-template.content", baseConfigTemplateContent); + + Assert.assertNotNull("Failed to Prepare Context : ", context); + + context.put("request-id", "12345"); + context.put("vnf-id", "vnf12345"); + context.put("action-name", "config-generator-action"); + + Map inparams = new HashMap(); + inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); + + SvcLogicContext inputContext = new SvcLogicContext(); + context.forEach((name, value) -> { + inputContext.setAttribute(name, value); + }); + + TransformationUtils.printMap(context); + configModelService.assignInParamsFromModel(inputContext, inparams); + ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); + + Map componentContext = new HashMap<>(); + configGeneratorNode.process(inparams, inputContext, componentContext); + + Assert.assertEquals("Failed to generate Configuration Status as Failure", + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, + inputContext.getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); + Assert.assertNotNull("Failed to generate Configuration", inputContext + .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + + logger.trace("Generated Configuration:\n " + inputContext + .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); + } + + @Test + public void testTemplateContentNDataForMask() throws Exception { + + } + +} diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java new file mode 100644 index 000000000..58918685d --- /dev/null +++ b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.features.generator.tool; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.features.generator.tool.EscapeUtils; + +public class EscapeUtilsTest { + + @Test + public void testEscapeSql() { + Assert.assertEquals("", EscapeUtils.escapeSql("")); + Assert.assertEquals("text", EscapeUtils.escapeSql("text")); + + Assert.assertEquals("''", EscapeUtils.escapeSql("'")); + Assert.assertEquals("\\\\", EscapeUtils.escapeSql("\\")); + + Assert.assertEquals("text''text", EscapeUtils.escapeSql("text'text")); + Assert.assertEquals("text\\\\text", EscapeUtils.escapeSql("text\\text")); + } + + @Test + public void testEscapeSequence() { + Assert.assertEquals("", EscapeUtils.escapeSequence("")); + Assert.assertEquals("text", EscapeUtils.escapeSequence("text")); + + Assert.assertEquals("\\\'", EscapeUtils.escapeSequence("'")); + Assert.assertEquals("\\\"", EscapeUtils.escapeSequence("\"")); + Assert.assertEquals("\\\\", EscapeUtils.escapeSequence("\\")); + + Assert.assertEquals("text\\\'text", EscapeUtils.escapeSequence("text'text")); + Assert.assertEquals("text\\\"text", EscapeUtils.escapeSequence("text\"text")); + Assert.assertEquals("text\\\\text", EscapeUtils.escapeSequence("text\\text")); + } + +} diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json index 0d569ef85..326d2e8ec 100644 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json +++ b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json @@ -67,7 +67,7 @@ "generate-configuration": { "type": "component-config-generator", "interfaces": { - "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": { + "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": { "operations": { "process": { "inputs": { @@ -164,7 +164,7 @@ } }, "interfaces": { - "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": { + "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": { "operations": { "process": { "inputs": { @@ -211,7 +211,7 @@ "type": "string" }, "mask-info": { - "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.config.model.data.custom.MaskInfo ", + "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.features.model.data.custom.MaskInfo ", "required": false, "type": "string" }, -- cgit 1.2.3-korg