--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.assignment.service;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.apache.commons.collections.MapUtils;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.assignment.ConfigAssignmentConstants;\r
+import org.onap.ccsdk.config.assignment.data.ResourceAssignmentData;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\r
+import org.onap.ccsdk.config.generator.service.ConfigGeneratorService;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.service.ComponentNode;\r
+import org.onap.ccsdk.config.model.service.ComponentNodeService;\r
+import org.onap.ccsdk.config.model.service.ConfigModelService;\r
+import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
+import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ConfigAssignmentNode implements ComponentNode {\r
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNode.class);\r
+\r
+ private ComponentNodeService componentNodeService;\r
+ private ConfigResourceService configResourceService;\r
+ private ConfigModelService configModelService;\r
+ private ConfigRestAdaptorService configRestAdaptorService;\r
+ private ConfigGeneratorService configGeneratorService;\r
+\r
+ public ConfigAssignmentNode(ConfigResourceService configResourceService,\r
+ ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
+ ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
+ logger.info("{} Constrctor Initiated", "ConfigAssignmentNode");\r
+ this.componentNodeService = componentNodeService;\r
+ this.configResourceService = configResourceService;\r
+ this.configModelService = configModelService;\r
+ this.configRestAdaptorService = configRestAdaptorService;\r
+ this.configGeneratorService = configGeneratorService;\r
+ }\r
+\r
+ @Override\r
+ public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ return Boolean.TRUE;\r
+ }\r
+\r
+ @Override\r
+ public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ // Auto-generated method stub\r
+ }\r
+\r
+ /**\r
+ * This method is used to resolve the resources defined in the template. Generic Resource API DG\r
+ * calls this execute node.\r
+ *\r
+ * @param inParams This is the input parameter to process this node\r
+ * \r
+ * <pre>\r
+ request-id (string): Tracking Id \r
+ resource-type (string): Resource Type ( ex : vnf-type) \r
+ resource-id (string): Resource Id \r
+ service-template-name (string): Blueprint Name \r
+ service-template-version (string): Blueprint Version \r
+ action-name (string): \r
+ template-names (List of string): Template Names / Artifact Node Names to resolve. ["template1", "template2"] \r
+ input-data (string): Input Data in JSON String, for the substitution in the Template. \r
+ prifix (string): Return Value selector\r
+ * </pre>\r
+ * \r
+ * @param ctx This is the service logger context, Output will be stored (\r
+ * <responsePrefix>.resource-assignment-params.<template-name> : Output Data in JSON String.\r
+ * <responsePrefix>.status <responsePrefix>.error-message )\r
+ * @throws SvcLogicException On processing error.\r
+ */\r
+\r
+ @Override\r
+ public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
+\r
+ final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR))\r
+ ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".")\r
+ : "";\r
+ try {\r
+\r
+ ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams);\r
+ resourceAssignmentData.setSvcLogicContext(ctx);\r
+ Map<String, Object> componentContext = new HashMap<>();\r
+ resourceAssignmentData.setContext(componentContext);\r
+ resourceAssignmentData.setReloadModel(true);\r
+\r
+ ConfigAssignmentProcessService configAssignmentProcessService =\r
+ new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService,\r
+ configModelService, componentNodeService, configGeneratorService);\r
+ configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
+\r
+ if (MapUtils.isNotEmpty(resourceAssignmentData.getTemplatesMashedContents())) {\r
+ resourceAssignmentData.getTemplatesMashedContents().forEach((templateName, previewContent) -> {\r
+ logger.debug("For Template name : ({}),\n Preview Content is : ({})", templateName, previewContent);\r
+ ctx.setAttribute(\r
+ responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_MASHED_DATA + "." + templateName,\r
+ previewContent);\r
+ });\r
+ }\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
+ ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS);\r
+ } catch (Exception e) {\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
+ ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE);\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
+ throw new SvcLogicException(e.getMessage(), e);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+\r
+ final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR))\r
+ ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".")\r
+ : "";\r
+ try {\r
+\r
+ ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams);\r
+ resourceAssignmentData.setSvcLogicContext(ctx);\r
+ resourceAssignmentData.setContext(componentContext);\r
+ resourceAssignmentData.setReloadModel(false);\r
+\r
+ ConfigAssignmentProcessService configAssignmentProcessService =\r
+ new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService,\r
+ configModelService, componentNodeService, configGeneratorService);\r
+ configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
+ ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS);\r
+\r
+ } catch (Exception e) {\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS,\r
+ ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE);\r
+ ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
+ throw new SvcLogicException(e.getMessage(), e);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ // Do Nothing\r
+ }\r
+\r
+ private ResourceAssignmentData populateResourceData(Map<String, String> inParams) throws SvcLogicException {\r
+ validateInputParams(inParams);\r
+\r
+ String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID);\r
+ String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID);\r
+ String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE);\r
+ String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME);\r
+ String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION);\r
+ String actionName = inParams.get(ConfigModelConstant.PROPERTY_ACTION_NAME);\r
+ String inputData = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA);\r
+\r
+ String templateNamesStr = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES);\r
+ List<String> templateNames = TransformationUtils.getListfromJson(templateNamesStr, String.class);\r
+\r
+ ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();\r
+ resourceAssignmentData.setRequestId(requestId);\r
+ resourceAssignmentData.setResourceId(resourceId);\r
+ resourceAssignmentData.setResourceType(resourceType);\r
+ resourceAssignmentData.setServiceTemplateName(serviceTemplateName);\r
+ resourceAssignmentData.setServiceTemplateVersion(serviceTemplateVersion);\r
+ resourceAssignmentData.setActionName(actionName);\r
+ resourceAssignmentData.setInputData(inputData);\r
+ resourceAssignmentData.setTemplateNames(templateNames);\r
+\r
+ return resourceAssignmentData;\r
+ }\r
+\r
+ private void validateInputParams(Map<String, String> inParams) throws SvcLogicException {\r
+ if (inParams == null) {\r
+ throw new SvcLogicException("Input parameters missing");\r
+ }\r
+\r
+ String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID);\r
+ if (StringUtils.isBlank(requestId)) {\r
+ throw new SvcLogicException("Request id parameters missing");\r
+ }\r
+ String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID);\r
+ if (StringUtils.isBlank(resourceId)) {\r
+ throw new SvcLogicException("Resource id parameter is missing");\r
+ }\r
+ String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE);\r
+ if (StringUtils.isBlank(resourceType)) {\r
+ throw new SvcLogicException("Resource type parameter is missing");\r
+ }\r
+ String recipeName = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_ACTION_NAME);\r
+ if (StringUtils.isBlank(recipeName)) {\r
+ throw new SvcLogicException("Action name is parameter is missing");\r
+ }\r
+ String templateNames = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES);\r
+ if (StringUtils.isBlank(templateNames)) {\r
+ throw new SvcLogicException("Template names parameter missing");\r
+ }\r
+ String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME);\r
+ if (StringUtils.isBlank(serviceTemplateName)) {\r
+ throw new SvcLogicException("Service Template name parameter missing");\r
+ }\r
+ String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION);\r
+ if (StringUtils.isBlank(serviceTemplateVersion)) {\r
+ throw new SvcLogicException("Service Template version parameter missing");\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.assignment.service;\r
+\r
+import java.io.File;\r
+import java.nio.charset.Charset;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import org.apache.commons.io.FileUtils;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.apache.sling.testing.mock.osgi.MockOsgi;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Rule;\r
+import org.junit.Test;\r
+import org.junit.rules.ExpectedException;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.onap.ccsdk.config.assignment.ConfigAssignmentConstants;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\r
+import org.onap.ccsdk.config.generator.service.ConfigGeneratorService;\r
+import org.onap.ccsdk.config.generator.service.ConfigGeneratorServiceImpl;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.service.ComponentNodeDelegate;\r
+import org.onap.ccsdk.config.model.service.ComponentNodeService;\r
+import org.onap.ccsdk.config.model.service.ComponentNodeServiceImpl;\r
+import org.onap.ccsdk.config.model.service.ConfigModelService;\r
+import org.onap.ccsdk.config.model.service.ConfigModelServiceImpl;\r
+import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import org.osgi.framework.BundleContext;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class ConfigAssignmentNodeTest {\r
+\r
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNodeTest.class);\r
+\r
+ @Rule\r
+ public ExpectedException thrown = ExpectedException.none();\r
+\r
+ @Mock\r
+ private ConfigResourceService configResourceService;\r
+\r
+ @Mock\r
+ private ConfigRestAdaptorService configRestAdaptorService;\r
+\r
+ private ConfigModelService configModelService;\r
+\r
+ private ComponentNodeService componentNodeService;\r
+\r
+ private ConfigGeneratorService configGeneratorService;\r
+\r
+ BundleContext bundleContext = MockOsgi.newBundleContext();\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Before\r
+ public void before() throws Exception {\r
+ MockitoAnnotations.initMocks(this);\r
+ /*\r
+ * ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(componentNodeService,\r
+ * configResourceService, configModelService, configRestAdaptorService, configGeneratorService);\r
+ * bundleContext.registerService(ConfigAssignmentNode.class, configAssignmentNode, null);\r
+ */\r
+ }\r
+\r
+ @Test\r
+ public void testResourceAssignment() throws Exception {\r
+ ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
+ "assignments/empty-dictionary.json");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
+\r
+ componentNodeService =\r
+ new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
+ configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+ configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
+\r
+ ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
+ configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
+\r
+ String inputContent = FileUtils.readFileToString(\r
+ new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
+\r
+ Map<String, String> inParams = new HashMap<>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
+ inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
+\r
+ // Populate the SvcContext ( Simulation)\r
+ SvcLogicContext svcLogicContext = new SvcLogicContext();\r
+ Map<String, String> context = new HashMap<>();\r
+ context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
+ context = configModelService.prepareContext(context, inputContent, "vpe-201802-baseconfig", "1.0.0");\r
+ context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));\r
+\r
+ Map<String, Object> componentContext = new HashMap<>();\r
+ configAssignmentNode.process(inParams, svcLogicContext, componentContext);\r
+ Assert.assertNotNull("Failed to get response status", svcLogicContext.getAttribute("test.status"));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSimplePreview() throws Exception {\r
+ ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
+ "assignments/empty-dictionary.json");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
+\r
+ componentNodeService =\r
+ new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
+ configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+ configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
+\r
+ ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
+ configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
+\r
+ String inputContent = FileUtils.readFileToString(\r
+ new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());\r
+\r
+ Map<String, String> inParams = new HashMap<>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
+ inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
+ SvcLogicContext ctx = new SvcLogicContext();\r
+ configAssignmentNode.process(inParams, ctx);\r
+ Assert.assertNotNull("Failed to get response mashed Content",\r
+ ctx.getAttribute("test.mashed-data.base-config-template"));\r
+ }\r
+\r
+ @Test\r
+ public void testComplexPreview() throws Exception {\r
+ ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "vpe-201802-baseconfig");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,\r
+ "service_templates/vpe-201802-baseconfig/dict.json");\r
+\r
+ ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService);\r
+\r
+ componentNodeService =\r
+ new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
+ configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+ configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);\r
+\r
+ ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService,\r
+ configRestAdaptorService, configModelService, componentNodeService, configGeneratorService);\r
+\r
+ String inputContent = FileUtils.readFileToString(\r
+ new File("src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json"),\r
+ Charset.defaultCharset());\r
+\r
+ Map<String, String> inParams = new HashMap<>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "complex-test");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "request-1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig");\r
+ inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0");\r
+ inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action");\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent);\r
+ inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]");\r
+ SvcLogicContext ctx = new SvcLogicContext();\r
+ configAssignmentNode.process(inParams, ctx);\r
+ Assert.assertNotNull("Failed to get response mashed Content",\r
+ ctx.getAttribute("complex-test.mashed-data.base-config-template"));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void inputValidator() {\r
+ SvcLogicContext ctx = new SvcLogicContext();\r
+ try {\r
+\r
+ logger.info(" ******************************* inputValidator ***************************");\r
+ String serviceTemplateContent = FileUtils.readFileToString(\r
+ new File("src/test/resources/service_templates/resource_assignment.json"),\r
+ Charset.defaultCharset());\r
+\r
+ String inputcontent = FileUtils.readFileToString(\r
+ new File("src/test/resources/service_templates/input/inputValidateTest.json"),\r
+ Charset.defaultCharset());\r
+\r
+ Map<String, String> context = new HashMap<>();\r
+ configModelService.prepareContext(context, inputcontent, serviceTemplateContent);\r
+\r
+ // TransformationUtils.printMap(context);\r
+\r
+ context.forEach((name, value) -> {\r
+ if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {\r
+ ctx.setAttribute(name, value);\r
+ }\r
+ });\r
+\r
+ ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
+ Map<String, String> inParams = new HashMap<>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
+ componentNodeDelegate.process(inParams, ctx);\r
+ Assert.fail();\r
+ } catch (Exception e) {\r
+ logger.error("Failed in inputValidator" + e.getMessage());\r
+ logger.info("** ctx.getAttribute Check for **" + ctx.getAttribute("resource-assignment.error-message"));\r
+ }\r
+\r
+ }\r
+\r
+}\r