SDNC Blueprints Processor Model Service 73/64573/1
authorSingal, Kapil (ks220y) <ks220y@att.com>
Wed, 5 Sep 2018 02:42:09 +0000 (22:42 -0400)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Wed, 5 Sep 2018 02:42:09 +0000 (22:42 -0400)
Creating SDN Controller Blueprints Processor Model Service JUnit Tests - 1

Change-Id: Ib13d6132bc024ca6e43d2088b5c577130a305479
Issue-ID: CCSDK-516
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
12 files changed:
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/ResourceDictionaryUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonParserUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ResourceAssignmentUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ServiceTemplateUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/TransformationUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/validator/ServiceTemplateValidationTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ComponentNodeTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ConfigModelServiceTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ExpressionUtilsTest.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/MockComponentNode.java [new file with mode: 0644]
blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ServiceTemplateCreateUtils.java [new file with mode: 0644]

diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/ResourceDictionaryUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/ResourceDictionaryUtilsTest.java
new file mode 100644 (file)
index 0000000..1b3dc9c
--- /dev/null
@@ -0,0 +1,216 @@
+/*\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.model;\r
+\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.config.model.data.PropertyDefinition;\r
+import org.onap.ccsdk.config.model.data.ResourceAssignment;\r
+import org.onap.ccsdk.config.model.data.dict.ResourceDefinition;\r
+import org.onap.ccsdk.config.model.data.dict.SourcesDefinition;\r
+import org.onap.ccsdk.config.model.data.dict.SourcesProperties;\r
+import org.onap.ccsdk.config.model.utils.ResourceDictionaryUtils;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ResourceDictionaryUtilsTest {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);\r
+\r
+    @Test\r
+    public void validateSingleInputSource() {\r
+        try {\r
+            logger.info(" **************** Validating validateSingleInputSource *****************");\r
+            ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+            resourceAssignment.setName("test-input-key");\r
+\r
+            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+            propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
+\r
+            SourcesProperties sourcesProp = new SourcesProperties();\r
+            sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
+\r
+            SourcesDefinition sourceDef = new SourcesDefinition();\r
+            sourceDef.setProperties(sourcesProp);\r
+\r
+            HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
+            sources.put("input", sourceDef);\r
+\r
+            ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+            resourceDefinition.setProperty(propertyDefinition);\r
+            resourceDefinition.setSources(sources);\r
+\r
+            ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+\r
+            Assert.assertNotNull("Resource assignment input sourceName is missing ",\r
+                    resourceAssignment.getDictionarySource());\r
+            Assert.assertNotNull("Resource assignment input sourceName property is missing ",\r
+                    resourceAssignment.getProperty());\r
+            Assert.assertNotNull("Resource assignment input sourceName property type is missing ",\r
+                    resourceAssignment.getProperty().getType());\r
+\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void validateSingleDbSource() {\r
+        try {\r
+            logger.info(" **************** Validating validateSingleDbSource *****************");\r
+            ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+            resourceAssignment.setName("test-db-key");\r
+\r
+            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+            propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
+\r
+            SourcesProperties sourcesProp = new SourcesProperties();\r
+            sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
+\r
+            SourcesDefinition sourceDef = new SourcesDefinition();\r
+            sourceDef.setProperties(sourcesProp);\r
+\r
+            HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
+            sources.put("db", sourceDef);\r
+\r
+            ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+            resourceDefinition.setProperty(propertyDefinition);\r
+            resourceDefinition.setSources(sources);\r
+\r
+            ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+            Assert.assertNotNull("Resource assignment db sourceName sourceName is missing ",\r
+                    resourceAssignment.getDictionarySource());\r
+            Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ",\r
+                    resourceAssignment.getProperty());\r
+            Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ",\r
+                    resourceAssignment.getProperty().getType());\r
+\r
+            Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies());\r
+            Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2,\r
+                    resourceAssignment.getDependencies().size());\r
+\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void validateMultiSource() {\r
+        try {\r
+            logger.info(" **************** Validating validateMultiSource *****************");\r
+            ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+            resourceAssignment.setName("test-multi-key");\r
+\r
+            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+            propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
+\r
+            SourcesProperties sourcesProp = new SourcesProperties();\r
+            sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
+\r
+            SourcesDefinition sourceDef = new SourcesDefinition();\r
+            sourceDef.setProperties(sourcesProp);\r
+\r
+            HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
+            sources.put("input", sourceDef);\r
+            sources.put("mdsal", sourceDef);\r
+\r
+            ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+            resourceDefinition.setProperty(propertyDefinition);\r
+            resourceDefinition.setSources(sources);\r
+\r
+            ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+            Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ",\r
+                    resourceAssignment.getProperty());\r
+            Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ",\r
+                    resourceAssignment.getProperty().getType());\r
+            Assert.assertNull("Resource assignment multi sourceName sourceName definition is present ",\r
+                    resourceAssignment.getDictionarySource());\r
+            Assert.assertNull("Resource assignment  multi sourceName dependecy is present ",\r
+                    resourceAssignment.getDependencies());\r
+\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+\r
+    @Test\r
+    public void testSourceDefault() {\r
+        logger.info(" **************** Validating testSourceDefault *****************");\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        resourceAssignment.setName("test-input-key");\r
+\r
+        PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+        propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
+\r
+        SourcesProperties sourcesProp = new SourcesProperties();\r
+        sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
+\r
+        SourcesDefinition sourceDef = new SourcesDefinition();\r
+        sourceDef.setProperties(sourcesProp);\r
+\r
+        HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
+        sources.put("default", sourceDef);\r
+\r
+        ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+        resourceDefinition.setProperty(propertyDefinition);\r
+        resourceDefinition.setSources(sources);\r
+\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+\r
+        Assert.assertNotNull("Resource assignment default sourceName is missing ",\r
+                resourceAssignment.getDictionarySource());\r
+        Assert.assertNotNull("Resource assignment default sourceName property is missing ",\r
+                resourceAssignment.getProperty());\r
+        Assert.assertNotNull("Resource assignment default sourceName property type is missing ",\r
+                resourceAssignment.getProperty().getType());\r
+    }\r
+\r
+    @Test\r
+    public void testSourceMdsal() {\r
+        logger.info(" **************** Validating testSourceMdsal *****************");\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        resourceAssignment.setName("test-input-key");\r
+\r
+        PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+        propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING);\r
+\r
+        SourcesProperties sourcesProp = new SourcesProperties();\r
+        sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"}));\r
+\r
+        SourcesDefinition sourceDef = new SourcesDefinition();\r
+        sourceDef.setProperties(sourcesProp);\r
+\r
+        HashMap<String, SourcesDefinition> sources = new HashMap<>();\r
+        sources.put("mdsal", sourceDef);\r
+\r
+        ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+        resourceDefinition.setProperty(propertyDefinition);\r
+        resourceDefinition.setSources(sources);\r
+\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+\r
+        Assert.assertNotNull("Resource assignment mdsal sourceName is missing ",\r
+                resourceAssignment.getDictionarySource());\r
+        Assert.assertNotNull("Resource assignment mdsal sourceName property is missing ",\r
+                resourceAssignment.getProperty());\r
+        Assert.assertNotNull("Resource assignment mdsal sourceName property type is missing ",\r
+                resourceAssignment.getProperty().getType());\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonParserUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonParserUtilsTest.java
new file mode 100644 (file)
index 0000000..693c505
--- /dev/null
@@ -0,0 +1,43 @@
+/*\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.model.utils;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+\r
+public class JsonParserUtilsTest {\r
+\r
+    @Test\r
+    public void testParse() {\r
+        final String jsonExample = "{\"key\":\"value\"}";\r
+\r
+        JsonNode rootJsonNode = JsonParserUtils.parse(jsonExample, "$");\r
+        Assert.assertEquals(jsonExample, rootJsonNode.toString());\r
+\r
+        JsonNode keyJsonNode = JsonParserUtils.parse(rootJsonNode, "$['key']");\r
+        Assert.assertEquals("value", keyJsonNode.asText());\r
+\r
+        Assert.assertEquals(jsonExample,\r
+                JsonParserUtils.parseNSet("{\"key\":\"NOT_VALUE\"}", "$['key']", keyJsonNode).toString());\r
+\r
+        rootJsonNode = JsonParserUtils.parse("{\"key\":\"NOT_VALUE\"}", "$");\r
+        Assert.assertEquals(jsonExample, JsonParserUtils.parseNSet(rootJsonNode, "$['key']", keyJsonNode).toString());\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/JsonUtilsTest.java
new file mode 100644 (file)
index 0000000..5dd0fae
--- /dev/null
@@ -0,0 +1,103 @@
+/*\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.model.utils;\r
+\r
+import static org.junit.Assert.assertTrue;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.config.model.ValidTypes;\r
+import com.fasterxml.jackson.databind.node.ArrayNode;\r
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
+import com.fasterxml.jackson.databind.node.ObjectNode;\r
+\r
+public class JsonUtilsTest {\r
+\r
+    @Test\r
+    public void testPopulatePrimitiveValues() {\r
+        ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
+        JsonUtils.populatePrimitiveValues("key1", "value", "", objectNode);\r
+        JsonUtils.populatePrimitiveValues("key2", true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
+        JsonUtils.populatePrimitiveValues("key3", 1, ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
+        JsonUtils.populatePrimitiveValues("key4", 1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
+        JsonUtils.populatePrimitiveValues("key5", "13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
+\r
+        assertTrue("value".equals(objectNode.get("key1").asText()));\r
+        assertTrue(objectNode.get("key2").asBoolean());\r
+        assertTrue(objectNode.get("key3").asInt() == 1);\r
+        assertTrue(objectNode.get("key4").floatValue() == 1.1f);\r
+        assertTrue("13213123131".equals(objectNode.get("key5").asText()));\r
+    }\r
+\r
+    @Test\r
+    public void testPopulatePrimitiveValuesArrayNode() {\r
+        ArrayNode objectNode = JsonNodeFactory.instance.arrayNode();\r
+        JsonUtils.populatePrimitiveValues("value", "", objectNode);\r
+        JsonUtils.populatePrimitiveValues(true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
+        JsonUtils.populatePrimitiveValues(1, ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
+        JsonUtils.populatePrimitiveValues(1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
+        JsonUtils.populatePrimitiveValues("13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
+\r
+        assertTrue(objectNode.size() == 5);\r
+    }\r
+\r
+    @Test\r
+    public void testPopulatePrimitiveDefaultValues() {\r
+        ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
+        JsonUtils.populatePrimitiveDefaultValues("key1", "", objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValues("key2", ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValues("key3", ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValues("key4", ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
+\r
+        assertTrue("".equals(objectNode.get("key1").asText()));\r
+        assertTrue(objectNode.get("key2").asBoolean() == false);\r
+        assertTrue(objectNode.get("key3").asInt() == 0);\r
+        assertTrue(objectNode.get("key4").floatValue() == 0.0f);\r
+    }\r
+\r
+    @Test\r
+    public void testPopulatePrimitiveDefaultValuesForArrayNode() {\r
+        ArrayNode objectNode = JsonNodeFactory.instance.arrayNode();\r
+        JsonUtils.populatePrimitiveDefaultValuesForArrayNode("", objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_INTEGER, objectNode);\r
+        JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_FLOAT, objectNode);\r
+\r
+        assertTrue(objectNode.size() == 4);\r
+    }\r
+\r
+    @Test\r
+    public void testPopulateJsonNodeValues() {\r
+        ObjectNode objectNode = JsonNodeFactory.instance.objectNode();\r
+        JsonUtils.populateJsonNodeValues("key1", JsonNodeFactory.instance.textNode("value"),\r
+                ValidTypes.DATA_TYPE_STRING, objectNode);\r
+        JsonUtils.populateJsonNodeValues("key2", JsonNodeFactory.instance.booleanNode(true),\r
+                ValidTypes.DATA_TYPE_BOOLEAN, objectNode);\r
+        JsonUtils.populateJsonNodeValues("key3", JsonNodeFactory.instance.numberNode(1), ValidTypes.DATA_TYPE_INTEGER,\r
+                objectNode);\r
+        JsonUtils.populateJsonNodeValues("key4", JsonNodeFactory.instance.numberNode(1.1f), ValidTypes.DATA_TYPE_FLOAT,\r
+                objectNode);\r
+        JsonUtils.populateJsonNodeValues("key5", JsonNodeFactory.instance.textNode("13213123131"),\r
+                ValidTypes.DATA_TYPE_TIMESTAMP, objectNode);\r
+        assertTrue(objectNode.get("key2").asBoolean());\r
+\r
+        assertTrue("value".equals(objectNode.get("key1").asText()));\r
+        assertTrue(objectNode.get("key2").asBoolean());\r
+        assertTrue(objectNode.get("key3").asInt() == 1);\r
+        assertTrue(objectNode.get("key4").floatValue() == 1.1f);\r
+        assertTrue("13213123131".equals(objectNode.get("key5").asText()));\r
+    }\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ResourceAssignmentUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ResourceAssignmentUtilsTest.java
new file mode 100644 (file)
index 0000000..034d70d
--- /dev/null
@@ -0,0 +1,198 @@
+/*\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.model.utils;\r
+\r
+import static org.junit.Assert.assertTrue;\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.ConfigModelException;\r
+import org.onap.ccsdk.config.model.ValidTypes;\r
+import org.onap.ccsdk.config.model.data.PropertyDefinition;\r
+import org.onap.ccsdk.config.model.data.ResourceAssignment;\r
+import org.onap.ccsdk.config.model.data.dict.ResourceDefinition;\r
+import com.fasterxml.jackson.core.type.TypeReference;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+public class ResourceAssignmentUtilsTest {\r
+\r
+    @Test\r
+    public void testGetArtifactNodeContent() {\r
+        String nodeTemplateName = "nodeTemplateNmae";\r
+        String templateContent = "content";\r
+        Map<String, Object> context = new HashMap<String, Object>();\r
+        context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content", templateContent);\r
+\r
+        String retrievedContent = ResourceAssignmentUtils.getArtifactNodeContent(nodeTemplateName, context);\r
+\r
+        assertTrue(templateContent.equals(retrievedContent));\r
+    }\r
+\r
+    @Test\r
+    public void testGetArtifactNodeMapping() {\r
+        String nodeTemplateName = "nodeTemplateNmae";\r
+        String templateContent = "[]";\r
+        Map<String, Object> context = new HashMap<String, Object>();\r
+        context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping", templateContent);\r
+\r
+        List<ResourceAssignment> map = ResourceAssignmentUtils.getArtifactNodeMapping(nodeTemplateName, context);\r
+        assertTrue(map.size() == 0);\r
+    }\r
+\r
+    @Test\r
+    public void testCleanContextTemplateNDictionaryKeys() {\r
+        String recipeName = "recipe";\r
+        Map<String, Object> componentContext = new HashMap<String, Object>();\r
+        componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
+        componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".", "value1");\r
+        componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".", "value2");\r
+        ResourceAssignmentUtils.cleanContextTemplateNDictionaryKeys(componentContext);\r
+\r
+        assertTrue(componentContext.size() == 1);\r
+    }\r
+\r
+    @Test\r
+    public void testGetDictionaryKeyValue() {\r
+        String recipeName = "recipe";\r
+        String dictionaryName = "dictionaryKey";\r
+        Map<String, Object> componentContext = new HashMap<String, Object>();\r
+        componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
+        componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName,\r
+                "value1");\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        resourceAssignment.setDictionaryName(dictionaryName);\r
+\r
+        String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceAssignment);\r
+        assertTrue("value1".equals(value));\r
+    }\r
+\r
+    @Test\r
+    public void testGetDictionaryKeyValueWithDictionaryDefinition() {\r
+        String recipeName = "recipe";\r
+        String dictionaryName = "dictionaryKey";\r
+        Map<String, Object> componentContext = new HashMap<String, Object>();\r
+        componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
+        componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName,\r
+                "value1");\r
+        ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+        resourceDefinition.setName(dictionaryName);\r
+\r
+        String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceDefinition);\r
+        assertTrue("value1".equals(value));\r
+    }\r
+\r
+    @Test\r
+    public void testGetTemplateKeyValue() {\r
+        String recipeName = "recipe";\r
+        String templateKeyName = "templateKey";\r
+        Map<String, Object> componentContext = new HashMap<String, Object>();\r
+        componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
+        componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName,\r
+                "value1");\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        resourceAssignment.setName(templateKeyName);\r
+\r
+        String value = (String) ResourceAssignmentUtils.getTemplateKeyValue(componentContext, resourceAssignment);\r
+        assertTrue("value1".equals(value));\r
+    }\r
+\r
+    @Test\r
+    public void testSetResourceDataValue() throws Exception {\r
+        String recipeName = "recipe";\r
+        Map<String, Object> componentContext = new HashMap<String, Object>();\r
+        componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);\r
+\r
+        ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, null);\r
+        Object value = "value";\r
+        ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
+        assertTrue(value.equals(resourceAssignment.getProperty().getValue()));\r
+\r
+        resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_INTEGER, null);\r
+        value = "1";\r
+        ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
+        assertTrue((int) resourceAssignment.getProperty().getValue() == 1);\r
+\r
+        resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_BOOLEAN, null);\r
+        value = "true";\r
+        ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
+        assertTrue((boolean) resourceAssignment.getProperty().getValue());\r
+\r
+        resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_FLOAT, null);\r
+        value = "1.1";\r
+        ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value);\r
+        assertTrue((float) resourceAssignment.getProperty().getValue() == 1.1f);\r
+    }\r
+\r
+    @Test\r
+    public void testSetFailedResourceDataValue() throws Exception {\r
+        ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value");\r
+        String message = "message";\r
+        ResourceAssignmentUtils.setFailedResourceDataValue(null, resourceAssignment, message);\r
+\r
+        assertTrue(message.equals(resourceAssignment.getMessage()));\r
+        assertTrue(ConfigModelConstant.STATUS_FAILURE.equals(resourceAssignment.getStatus()));\r
+    }\r
+\r
+    @Test(expected = ConfigModelException.class)\r
+    public void testAssertTemplateKeyValueNotNull() throws Exception {\r
+        Map<String, Object> componentContext = null;\r
+        ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value");\r
+        ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment);\r
+    }\r
+\r
+    @Test\r
+    public void testGenerateResourceDataForAssignments() throws Exception {\r
+        List<ResourceAssignment> assignments = new ArrayList<ResourceAssignment>();\r
+        assignments.add(createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "string"));\r
+        assignments.add(createResourceAssignment("name2", ValidTypes.DATA_TYPE_BOOLEAN, true));\r
+        assignments.add(createResourceAssignment("name3", ValidTypes.DATA_TYPE_INTEGER, 1));\r
+        assignments.add(createResourceAssignment("name4", ValidTypes.DATA_TYPE_FLOAT, 1.1f));\r
+        assignments.add(createResourceAssignment("name5", ValidTypes.DATA_TYPE_TIMESTAMP, "1523908097735"));\r
+        assignments.add(createResourceAssignment("name6", "", new HashMap<String, String>()));\r
+        ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
+    }\r
+\r
+    public void testResourceAssignmentForNullEmptyValues() throws Exception {\r
+\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        JsonNode raContent =\r
+                mapper.readTree(new File("src/test/resources/service_templates/ra-content-with-mising-value.json"));\r
+\r
+        List<ResourceAssignment> assignments =\r
+                mapper.readValue(raContent.toString(), new TypeReference<List<ResourceAssignment>>() {});\r
+\r
+        ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);\r
+    }\r
+\r
+    private ResourceAssignment createResourceAssignment(String name, String dataType, Object value) {\r
+        PropertyDefinition property = new PropertyDefinition();\r
+        property.setType(dataType);\r
+        property.setValue(value);\r
+        property.setRequired(true);\r
+        ResourceAssignment ra = new ResourceAssignment();\r
+        ra.setName(name);\r
+        ra.setProperty(property);\r
+        return ra;\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ServiceTemplateUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/ServiceTemplateUtilsTest.java
new file mode 100644 (file)
index 0000000..5364ae9
--- /dev/null
@@ -0,0 +1,77 @@
+/*\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.model.utils;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.config.model.data.ArtifactDefinition;\r
+import org.onap.ccsdk.config.model.data.CapabilityAssignment;\r
+import org.onap.ccsdk.config.model.data.NodeTemplate;\r
+\r
+public class ServiceTemplateUtilsTest {\r
+\r
+    ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();\r
+\r
+    @Test\r
+    public void testPopulateVnfNodeProperties() {\r
+        NodeTemplate nodeTemplate = createNodeTemplate();\r
+\r
+        String nodeTemplateKey = "nodeTemplateKey";\r
+        Map<String, String> context = new HashMap<String, String>();\r
+\r
+        Map<String, String> result =\r
+                serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null);\r
+\r
+        Assert.assertTrue(result.size() > 0);\r
+    }\r
+\r
+    @Test\r
+    public void testPopulateNodeTemplateArtifacts() {\r
+        String nodeTemplateKey = "nodeTemplateKey";\r
+        NodeTemplate nodeTemplate = createNodeTemplate();\r
+        Map<String, String> context = new HashMap<String, String>();\r
+\r
+        Map<String, String> result =\r
+                serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context);\r
+\r
+        Assert.assertTrue(result.size() > 0);\r
+    }\r
+\r
+    private NodeTemplate createNodeTemplate() {\r
+        NodeTemplate nodeTemplate = new NodeTemplate();\r
+        Map<String, Object> properties = new HashMap<String, Object>();\r
+        properties.put("prop1", "value");\r
+        CapabilityAssignment capabilityAssignment = new CapabilityAssignment();\r
+        capabilityAssignment.setProperties(properties);\r
+        Map<String, CapabilityAssignment> capabilities = new HashMap<String, CapabilityAssignment>();\r
+        capabilities.put("key", capabilityAssignment);\r
+        nodeTemplate.setCapabilities(capabilities);\r
+\r
+        ArtifactDefinition artifactDefinition = new ArtifactDefinition();\r
+        artifactDefinition.setFile("file");\r
+        artifactDefinition.setDeployPath("deployPath");\r
+        artifactDefinition.setContent("content");\r
+        Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();\r
+        artifacts.put("artifactName1", artifactDefinition);\r
+        nodeTemplate.setArtifacts(artifacts);\r
+\r
+        return nodeTemplate;\r
+    }\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/TransformationUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/utils/TransformationUtilsTest.java
new file mode 100644 (file)
index 0000000..ca57e5f
--- /dev/null
@@ -0,0 +1,90 @@
+/*\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.model.utils;\r
+\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import org.junit.Test;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+\r
+public class TransformationUtilsTest {\r
+\r
+    @Test\r
+    public void testGetJson() {\r
+        Map<String, Object> configparameters = new HashMap<String, Object>();\r
+        configparameters.put("key", "value");\r
+        String json = TransformationUtils.getJson(configparameters);\r
+        assertTrue("{\"key\":\"value\"}".equals(json));\r
+    }\r
+\r
+    @Test\r
+    public void testGetJsonNodeForString() {\r
+        String content = "{\"key\":\"value\"}";\r
+        JsonNode jsonNodeForString = TransformationUtils.getJsonNodeForString(content);\r
+        assertNotNull(jsonNodeForString);\r
+    }\r
+\r
+    @Test\r
+    public void testGetMapfromJson() {\r
+        String content = "{\"key\":\"value\"}";\r
+        Map<String, Object> mapfromJson = TransformationUtils.getMapfromJson(content);\r
+        assertTrue(mapfromJson.size() == 1);\r
+        assertTrue("value".equals(mapfromJson.get("key")));\r
+    }\r
+\r
+    @Test\r
+    public void testGetMapfromJsonString() {\r
+        String content = "{\"key\":\"value\"}";\r
+        Map<String, Object> mapfromJson = TransformationUtils.getMapfromJsonString(content);\r
+        assertTrue(mapfromJson.size() == 1);\r
+        assertTrue("value".equals(mapfromJson.get("key")));\r
+    }\r
+\r
+    @Test\r
+    public void testConvertJson2RootProperties() throws Exception {\r
+        Map<String, String> context = new HashMap<String, String>();\r
+        String jsonContent = "{\"key\":\"value\"}";\r
+        Map<String, String> convertJson2RootProperties =\r
+                TransformationUtils.convertJson2RootProperties(context, jsonContent);\r
+        assertTrue(convertJson2RootProperties.size() == 1);\r
+        assertTrue("value".equals(convertJson2RootProperties.get("key")));\r
+    }\r
+\r
+    @SuppressWarnings("unchecked")\r
+    @Test\r
+    public void testGetJsonNodeAndTreeToValueAndConvertJson2Properties() throws Exception {\r
+        Map<String, String> configparameters = new HashMap<String, String>();\r
+        configparameters.put("key", "value");\r
+        JsonNode jsonNode = TransformationUtils.getJsonNode(configparameters);\r
+        assertNotNull(jsonNode);\r
+\r
+        Map<String, String> result = TransformationUtils.treeToValue(jsonNode, HashMap.class);\r
+        assertTrue("value".equals(result.get("key")));\r
+\r
+        result = TransformationUtils.convertJson2Properties(null, jsonNode, null);\r
+        assertTrue("value".equals(result.get("key")));\r
+    }\r
+\r
+    @Test\r
+    public void testGetJsonSchema() {\r
+        String jsonSchema = TransformationUtils.getJsonSchema(String.class);\r
+        assertNotNull(jsonSchema);\r
+    }\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/validator/ServiceTemplateValidationTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/model/validator/ServiceTemplateValidationTest.java
new file mode 100644 (file)
index 0000000..5776b51
--- /dev/null
@@ -0,0 +1,51 @@
+/*\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.model.validator;\r
+\r
+import java.nio.charset.Charset;\r
+import org.apache.commons.io.IOUtils;\r
+import org.junit.Test;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ServiceTemplateValidationTest {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);\r
+\r
+    @Test\r
+    public void validateServiceTemplate() {\r
+        try {\r
+            logger.info(" **************** Validating Default *****************");\r
+            String serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader()\r
+                    .getResourceAsStream("service_templates/default.json"), Charset.defaultCharset());\r
+            ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();\r
+            serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
+            logger.info(" **************** Reqource Assignment *****************");\r
+            serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader()\r
+                    .getResourceAsStream("service_templates/resource_assignment.json"), Charset.defaultCharset());\r
+            serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
+            logger.info(" **************** Activate Netconf *****************");\r
+            serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader()\r
+                    .getResourceAsStream("service_templates/download_config.json"), Charset.defaultCharset());\r
+            serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ComponentNodeTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ComponentNodeTest.java
new file mode 100644 (file)
index 0000000..d73a622
--- /dev/null
@@ -0,0 +1,140 @@
+/*\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.params.service;\r
+\r
+import static org.mockito.Matchers.any;\r
+import java.io.File;\r
+import java.nio.charset.Charset;\r
+import java.util.Arrays;\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.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.MockitoAnnotations;\r
+import org.mockito.invocation.InvocationOnMock;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.mockito.stubbing.Answer;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\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.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.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 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 ComponentNodeTest {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeTest.class);\r
+    @Mock\r
+    private ConfigResourceService configResourceService;\r
+\r
+    @Mock\r
+    private ConfigRestAdaptorService configRestAdaptorService;\r
+\r
+    BundleContext bundleContext = MockOsgi.newBundleContext();\r
+\r
+    @Before\r
+    public void before() {\r
+        MockitoAnnotations.initMocks(this);\r
+\r
+        MockComponentNode mockSvcLogicPlugin = new MockComponentNode();\r
+        bundleContext.registerService(MockComponentNode.class, mockSvcLogicPlugin, null);\r
+\r
+        try {\r
+            Mockito.doAnswer(new Answer<Void>() {\r
+                @Override\r
+                public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
+                    Object[] args = invocationOnMock.getArguments();\r
+                    if (args != null) {\r
+                        logger.trace("Transaction info " + Arrays.asList(args));\r
+                    }\r
+                    return null;\r
+                }\r
+            }).when(configResourceService).save(any(TransactionLog.class));\r
+        } catch (SvcLogicException e) {\r
+            // TODO Auto-generated catch block\r
+            e.printStackTrace();\r
+        }\r
+    }\r
+\r
+    @After\r
+    public void after() {\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testProcess() {\r
+\r
+        try {\r
+            String serviceTemplateContent = FileUtils.readFileToString(\r
+                    new File("src/test/resources/componentnode/default.json"), Charset.defaultCharset());\r
+            ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+\r
+            Map<String, String> map = new HashMap<>();\r
+            configModelService.convertServiceTemplate2Properties(serviceTemplateContent, map);\r
+\r
+            SvcLogicContext ctx = new SvcLogicContext();\r
+            map.forEach((name, value) -> {\r
+                if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {\r
+                    ctx.setAttribute(name, value);\r
+                }\r
+            });\r
+            ctx.setAttribute("vnf-id", "1234");\r
+\r
+            ComponentNodeServiceImpl componentNodeService =\r
+                    new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
+\r
+            ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
+            Map<String, String> inParams = new HashMap<>();\r
+            inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
+\r
+            componentNodeDelegate.process(inParams, ctx);\r
+            TransformationUtils.printMap(inParams);\r
+\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+\r
+    }\r
+\r
+    @Test(expected = SvcLogicException.class)\r
+    public void testFailure() throws Exception {\r
+        ComponentNodeServiceImpl componentNodeService =\r
+                new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService);\r
+        ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService);\r
+\r
+        Map<String, String> inParams = new HashMap<String, String>();\r
+        inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
+        SvcLogicContext ctx = new SvcLogicContext();\r
+        componentNodeDelegate.process(inParams, ctx);\r
+    }\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ConfigModelServiceTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ConfigModelServiceTest.java
new file mode 100644 (file)
index 0000000..77972a6
--- /dev/null
@@ -0,0 +1,219 @@
+/*\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.params.service;\r
+\r
+import static org.junit.Assert.fail;\r
+import java.io.File;\r
+import java.nio.charset.Charset;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.apache.commons.io.FileUtils;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Matchers;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.data.ServiceTemplate;\r
+import org.onap.ccsdk.config.model.domain.ConfigModel;\r
+import org.onap.ccsdk.config.model.domain.ConfigModelContent;\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.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class ConfigModelServiceTest {\r
+\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceTest.class);\r
+\r
+    @Mock\r
+    private ConfigRestAdaptorService configRestAdaptorService;\r
+\r
+    @Test\r
+    public void testConfigAssignmentInputOutputParams() throws Exception {\r
+\r
+        String fileContent = FileUtils.readFileToString(\r
+                new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset());\r
+\r
+        Map<String, String> context = new HashMap<>();\r
+        ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        context = configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context);\r
+\r
+        Assert.assertNotNull("Failed to Prepare Context : ", context);\r
+\r
+        context.put("request-id", "12345");\r
+        context.put("vnf-id", "vnf12345");\r
+\r
+        Map<String, String> inparams = new HashMap<String, String>();\r
+        inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
+\r
+        SvcLogicContext inputContext = new SvcLogicContext();\r
+        context.forEach((name, value) -> {\r
+            inputContext.setAttribute(name, value);\r
+        });\r
+\r
+        // TransformationUtils.printProperty(inputContext.toProperties());\r
+\r
+        configModelServiceImpl.assignInParamsFromModel(inputContext, inparams);\r
+        Assert.assertNotNull("In Param is Null : ", inparams);\r
+        Assert.assertNotNull("Failed to get entity-id in Inparms : ", inparams.get("resource-id"));\r
+        Assert.assertEquals("Failed to get entity-id vlaue in Inparms ", String.valueOf("vnf12345"),\r
+                inparams.get("resource-id"));\r
+        Assert.assertNotNull("Failed to get request-id in Inparms : ", inparams.get("request-id"));\r
+        Assert.assertEquals("Failed to get request-id vlaue in Inparms ", String.valueOf("12345"),\r
+                inparams.get("request-id"));\r
+\r
+        configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams);\r
+        logger.info("*************** Output Params *************");\r
+        // TransformationUtils.printProperty(inputContext.toProperties());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testConvertServiceTemplate2PropertiesComplex() throws Exception {\r
+        String fileContent = FileUtils.readFileToString(\r
+                new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset());\r
+\r
+        Map<String, String> context = new HashMap<>();\r
+        context.put("host-password", "1234");\r
+        context.put("host-ip-address", "[123.23.34.45, 123.23.34.45]");\r
+\r
+        ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context);\r
+\r
+        // TransformationUtils.printMap(context);\r
+\r
+        Map<String, String> inparams = new HashMap<String, String>();\r
+        inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment");\r
+        logger.info("Before Input Result: " + inparams);\r
+\r
+        SvcLogicContext inputContext = new SvcLogicContext();\r
+        context.forEach((name, value) -> {\r
+            inputContext.setAttribute(name, value);\r
+        });\r
+\r
+        configModelServiceImpl.assignInParamsFromModel(inputContext, inparams);\r
+        logger.info("----------Input Result: " + inparams);\r
+\r
+        inputContext.setAttribute("assignment-params", "default-assigned");\r
+        configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams);\r
+\r
+        // TransformationUtils.printProperty(inputContext.toProperties());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testGetNodeTemplateContent() throws Exception {\r
+        String templateContent = "{\"id\":\"id\"}";\r
+        SvcLogicContext context = new SvcLogicContext();\r
+        context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent + ".content",\r
+                templateContent);\r
+\r
+        ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        String content = configModelServiceImpl.getNodeTemplateContent(context, templateContent);\r
+\r
+        Assert.assertEquals(content, templateContent);\r
+    }\r
+\r
+    @Test\r
+    public void testGetNodeTemplateMapping() throws Exception {\r
+        String templateContent = "{\"capabilities\":{\"mapping\":{\"properties\":{\"mapping\":[\"test\"]}}}}";\r
+        SvcLogicContext context = new SvcLogicContext();\r
+        context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent, templateContent);\r
+\r
+        ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        configModelServiceImpl.getNodeTemplateMapping(context, templateContent);\r
+        // Assert.assertEquals(content, templateContent);\r
+    }\r
+\r
+    @Test\r
+    public void testValidateServiceTemplate() throws Exception {\r
+        ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        ServiceTemplate serviceTemplate = new ServiceTemplate();\r
+\r
+        try {\r
+            configModelServiceImpl.validateServiceTemplate(null);\r
+            fail("Should have thrown exception");\r
+        } catch (SvcLogicException e) {\r
+        }\r
+\r
+        try {\r
+            configModelServiceImpl.validateServiceTemplate(serviceTemplate);\r
+            fail("Should have thrown exception");\r
+        } catch (SvcLogicException e) {\r
+        }\r
+\r
+        Map<String, String> metadata = new HashMap<String, String>();\r
+        metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR, "author");\r
+        metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "name");\r
+        metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "version");\r
+        serviceTemplate.setMetadata(metadata);\r
+\r
+        Assert.assertTrue(configModelServiceImpl.validateServiceTemplate(serviceTemplate));\r
+    }\r
+\r
+    @Test\r
+    public void testPrepareContext() throws Exception {\r
+        Mockito.when(configRestAdaptorService.getResource(Matchers.anyString(), Matchers.anyString(), Matchers.any()))\r
+                .thenReturn(createConfigModel());\r
+\r
+        String input = "{\"action-name\": \"resource-assignment-action\"}";\r
+        ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+\r
+        Map<String, String> ctx =\r
+                configModelService.prepareContext(null, input, "serviceTemplateName", "serviceTemplateVersion");\r
+        Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME));\r
+\r
+        ctx = configModelService.prepareContext(null, input, "{}");\r
+        Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME));\r
+    }\r
+\r
+    @Test\r
+    public void testConvertServiceTemplate2Properties() throws Exception {\r
+        Map<String, String> metadata = new HashMap<String, String>();\r
+        metadata.put("key", "value");\r
+        ServiceTemplate serviceTemplate = new ServiceTemplate();\r
+        serviceTemplate.setMetadata(metadata);\r
+        Map<String, String> context = new HashMap<String, String>();\r
+\r
+        ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+        Map<String, String> ctx = configModelService.convertServiceTemplate2Properties(serviceTemplate, context);\r
+\r
+        Assert.assertEquals("value", ctx.get("key"));\r
+    }\r
+\r
+    private ConfigModel createConfigModel() {\r
+        ConfigModel configModel = new ConfigModel();\r
+        List<ConfigModelContent> configModelContents = new ArrayList<ConfigModelContent>();\r
+        ConfigModelContent configModelContent = new ConfigModelContent();\r
+        configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);\r
+        configModelContent.setContent("{\"description\": \"description\"}");\r
+        configModelContents.add(configModelContent);\r
+        configModel.setConfigModelContents(configModelContents);\r
+        configModel.setPublished("Y");\r
+        return configModel;\r
+    }\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ExpressionUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ExpressionUtilsTest.java
new file mode 100644 (file)
index 0000000..e72b053
--- /dev/null
@@ -0,0 +1,76 @@
+/*\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.params.service;\r
+\r
+import java.io.File;\r
+import java.nio.charset.Charset;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.apache.commons.io.FileUtils;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.config.model.utils.ExpressionUtils;\r
+import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+public class ExpressionUtilsTest {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtilsTest.class);\r
+\r
+    @Test\r
+    public void testProcessJsonExpression() throws Exception {\r
+        String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/default.json"),\r
+                Charset.defaultCharset());\r
+\r
+        SvcLogicContext context = new SvcLogicContext();\r
+        context.setAttribute("host-password", "1234");\r
+        context.setAttribute("host-ip-address", "[\"123.23.34.45\", \"123.23.34.45\"]");\r
+        context.setAttribute("loopback-default", "[\"Sample\", \"Brinda\"]");\r
+\r
+        Map<String, String> inparams = new HashMap<String, String>();\r
+        ExpressionUtils jsonExpressionUtils = new ExpressionUtils(context, inparams);\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        JsonNode rootArray = mapper.readTree(fileContent);\r
+        jsonExpressionUtils.processJsonExpression(rootArray);\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testJson2Property() throws Exception {\r
+        String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/convert.json"),\r
+                Charset.defaultCharset());\r
+\r
+        List<String> blockKeys = new ArrayList<String>();\r
+        blockKeys.add(\r
+                "interfaces.ResourceAssignmentService.operations.getResourceAssignment.inputs.assignment-mappings");\r
+        blockKeys.add("interfaces.ResourceAssignmentService.operations.getResourceAssignment.outputs");\r
+        blockKeys.add("type");\r
+\r
+        Map<String, String> workflowMap = new HashMap<>();\r
+        Map<String, String> propertyMap =\r
+                TransformationUtils.convertJson2Properties(workflowMap, fileContent, blockKeys);\r
+\r
+        TransformationUtils.printMap(propertyMap);\r
+\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/MockComponentNode.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/MockComponentNode.java
new file mode 100644 (file)
index 0000000..00260c9
--- /dev/null
@@ -0,0 +1,62 @@
+/*\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.params.service;\r
+\r
+import java.util.Map;\r
+import org.onap.ccsdk.config.model.service.ComponentNode;\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 MockComponentNode implements ComponentNode {\r
+    private static EELFLogger logger = EELFManager.getInstance().getLogger(MockComponentNode.class);\r
+\r
+    @Override\r
+    public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+            throws SvcLogicException {\r
+        logger.info("Received preCondition ");\r
+        componentContext.put("test-key", "test");\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
+\r
+    }\r
+\r
+    @Override\r
+    public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+            throws SvcLogicException {\r
+        logger.info("Received Request " + componentContext);\r
+    }\r
+\r
+    @Override\r
+    public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+            throws SvcLogicException {\r
+        logger.info("Received preProcess ");\r
+\r
+    }\r
+\r
+    @Override\r
+    public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+            throws SvcLogicException {\r
+        logger.info("Received postProcess ");\r
+    }\r
+\r
+}\r
diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ServiceTemplateCreateUtils.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/config/params/service/ServiceTemplateCreateUtils.java
new file mode 100644 (file)
index 0000000..6bfa903
--- /dev/null
@@ -0,0 +1,295 @@
+/*\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.params.service;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\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.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.data.DataType;\r
+import org.onap.ccsdk.config.model.data.NodeTemplate;\r
+import org.onap.ccsdk.config.model.data.NodeType;\r
+import org.onap.ccsdk.config.model.data.ServiceTemplate;\r
+import org.onap.ccsdk.config.model.data.TopologyTemplate;\r
+import org.onap.ccsdk.config.model.data.dict.ResourceDefinition;\r
+import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
+\r
+public class ServiceTemplateCreateUtils {\r
+\r
+    public void createNodeTypes(String serviceTemplateFileName) throws IOException {\r
+        if (StringUtils.isNotBlank(serviceTemplateFileName)) {\r
+            String fileContent =\r
+                    FileUtils.readFileToString(new File(serviceTemplateFileName), Charset.defaultCharset());\r
+            if (StringUtils.isNotBlank(fileContent)) {\r
+                // System.out.println("NodeTypeCreateUtils.createNodeTypes()" +fileContent );\r
+                ServiceTemplate serviceTemplate = TransformationUtils.readValue(fileContent, ServiceTemplate.class);\r
+\r
+                String formattedServiceTemplateContent = TransformationUtils.getJson(serviceTemplate, true);\r
+\r
+                FileUtils.writeStringToFile(new File("src/test/resources/service_templates/_default.json"),\r
+                        formattedServiceTemplateContent, Charset.defaultCharset());\r
+\r
+                createNetconfdownloadNodeTemplate(serviceTemplate);\r
+                createRestconfdownloadNodeTemplate(serviceTemplate);\r
+                // createResourceAssignmentNodeTemplate(serviceTemplate);\r
+                createVrrNodeTemplate(serviceTemplate);\r
+                createDictionarySchema();\r
+\r
+            }\r
+        }\r
+    }\r
+\r
+    public void createNodeTypes(ServiceTemplate serviceTemplate) throws IOException {\r
+\r
+        if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) {\r
+            serviceTemplate.getNodeTypes().forEach((nodeTypeKey, node_types) -> {\r
+\r
+                if (node_types != null && StringUtils.isNotBlank(node_types.getDerivedFrom())) {\r
+\r
+                    try {\r
+                        String fileName = "src/test/resources/node_types/";\r
+                        if (ConfigModelConstant.MODEL_TYPE_NODE_VNF.equalsIgnoreCase(node_types.getDerivedFrom())) {\r
+                            fileName = fileName + "vnf/" + nodeTypeKey + ".json";\r
+                        }\r
+                        if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(node_types.getDerivedFrom())) {\r
+                            fileName = fileName + "dg/" + nodeTypeKey + ".json";\r
+                        }\r
+                        if (ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT\r
+                                .equalsIgnoreCase(node_types.getDerivedFrom())) {\r
+                            fileName = fileName + "component/" + nodeTypeKey + ".json";\r
+                        }\r
+                        String content = TransformationUtils.getJson(node_types, true);\r
+                        FileUtils.write(new File(fileName), content, Charset.defaultCharset());\r
+                    } catch (IOException e) {\r
+                        e.printStackTrace();\r
+                    }\r
+\r
+                }\r
+                System.out.println("NodeTypeCreateUtils.createNodeTypes()" + nodeTypeKey);\r
+            });\r
+        }\r
+\r
+    }\r
+\r
+    public void createNetconfdownloadNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
+        if (serviceTemplate != null) {\r
+            ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
+            workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
+\r
+            Map<String, DataType> data_types = new HashMap<String, DataType>();\r
+            data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property"));\r
+            data_types.put("datatype-resource-assignment",\r
+                    serviceTemplate.getDataTypes().get("datatype-resource-assignment"));\r
+            workingServiceTemplate.setDataTypes(data_types);\r
+\r
+            TopologyTemplate topology_template = new TopologyTemplate();\r
+            Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
+\r
+            Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
+\r
+            node_templates.put("activate-action", node_Templates.get("activate-action"));\r
+            node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
+            node_templates.put("vrr-netconf-device", node_Templates.get("vrr-netconf-device"));\r
+            node_templates.put("get-netconf-config", node_Templates.get("get-netconf-config"));\r
+            node_templates.put("edit-netconf-config", node_Templates.get("edit-netconf-config"));\r
+            node_templates.put("transaction-netconf-baseconfig", node_Templates.get("transaction-netconf-baseconfig"));\r
+\r
+            topology_template.setNodeTemplates(node_templates);\r
+            topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
+\r
+            Map<String, NodeType> node_types = new HashMap<String, NodeType>();\r
+            node_types.put("dg-activate-netconf", serviceTemplate.getNodeTypes().get("dg-activate-netconf"));\r
+            node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template"));\r
+            node_types.put("component-transaction-netconf",\r
+                    serviceTemplate.getNodeTypes().get("component-transaction-netconf"));\r
+            node_types.put("component-netconf-edit", serviceTemplate.getNodeTypes().get("component-netconf-edit"));\r
+            node_types.put("component-netconf-get", serviceTemplate.getNodeTypes().get("component-netconf-get"));\r
+            node_types.put("vnf-netconf-device", serviceTemplate.getNodeTypes().get("vnf-netconf-device"));\r
+\r
+            workingServiceTemplate.setNodeTypes(node_types);\r
+            workingServiceTemplate.setTopologyTemplate(topology_template);\r
+\r
+            String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true);\r
+\r
+            FileUtils.writeStringToFile(new File("src/test/resources/service_templates/download_config.json"),\r
+                    workingServiceTemplateContent, Charset.defaultCharset());\r
+\r
+            File lcmFile = new File(\r
+                    "../../../adaptors/netconf-adaptor/provider/src/test/resources/service_templates/download_config.json");\r
+            FileUtils.writeStringToFile(lcmFile, workingServiceTemplateContent, Charset.defaultCharset());\r
+\r
+        }\r
+    }\r
+\r
+    public void createRestconfdownloadNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
+        if (serviceTemplate != null) {\r
+            ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
+            workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
+\r
+            Map<String, DataType> data_types = new HashMap<String, DataType>();\r
+            data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property"));\r
+            data_types.put("datatype-resource-assignment",\r
+                    serviceTemplate.getDataTypes().get("datatype-resource-assignment"));\r
+            workingServiceTemplate.setDataTypes(data_types);\r
+\r
+            TopologyTemplate topology_template = new TopologyTemplate();\r
+            Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
+\r
+            Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
+            node_templates.put("activate-restconf-action", node_Templates.get("activate-restconf-action"));\r
+            node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
+            node_templates.put("vrr-restconf-device", node_Templates.get("vrr-restconf-device"));\r
+            node_templates.put("edit-restconf-config", node_Templates.get("edit-restconf-config"));\r
+            node_templates.put("transaction-restconf-baseconfig",\r
+                    node_Templates.get("transaction-restconf-baseconfig"));\r
+\r
+            topology_template.setNodeTemplates(node_templates);\r
+            topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
+\r
+            Map<String, NodeType> node_types = new HashMap<String, NodeType>();\r
+            node_types.put("dg-activate-restconf", serviceTemplate.getNodeTypes().get("dg-activate-restconf"));\r
+            node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template"));\r
+            node_types.put("component-transaction-restconf",\r
+                    serviceTemplate.getNodeTypes().get("component-transaction-restconf"));\r
+            node_types.put("component-restconf", serviceTemplate.getNodeTypes().get("component-restconf"));\r
+            node_types.put("vnf-restconf-device", serviceTemplate.getNodeTypes().get("vnf-restconf-device"));\r
+\r
+            workingServiceTemplate.setNodeTypes(node_types);\r
+            workingServiceTemplate.setTopologyTemplate(topology_template);\r
+\r
+            String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true);\r
+\r
+            FileUtils.writeStringToFile(new File("src/test/resources/service_templates/restconf_download_config.json"),\r
+                    workingServiceTemplateContent, Charset.defaultCharset());\r
+\r
+            File lcmFile = new File(\r
+                    "../../../adaptors/netconf-adaptor/provider/src/test/resources/service_templates/restconf_download_config.json");\r
+            FileUtils.writeStringToFile(lcmFile, workingServiceTemplateContent, Charset.defaultCharset());\r
+\r
+        }\r
+\r
+    }\r
+\r
+    public void createResourceAssignmentNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
+        if (serviceTemplate != null) {\r
+            ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
+            workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
+\r
+            Map<String, DataType> data_types = new HashMap<String, DataType>();\r
+            data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property"));\r
+            data_types.put("datatype-resource-assignment",\r
+                    serviceTemplate.getDataTypes().get("datatype-resource-assignment"));\r
+\r
+            workingServiceTemplate.setDataTypes(data_types);\r
+\r
+            TopologyTemplate topology_template = new TopologyTemplate();\r
+            Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
+\r
+            Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
+\r
+            node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
+            node_templates.put("licence-template", node_Templates.get("licence-template"));\r
+\r
+            node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action"));\r
+            node_templates.put("resource-assignment", node_Templates.get("resource-assignment"));\r
+\r
+            topology_template.setNodeTemplates(node_templates);\r
+            topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
+\r
+            Map<String, NodeType> node_types = new HashMap<String, NodeType>();\r
+            node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template"));\r
+            node_types.put("dg-resource-assignment", serviceTemplate.getNodeTypes().get("dg-resource-assignment"));\r
+            node_types.put("component-resource-assignment",\r
+                    serviceTemplate.getNodeTypes().get("component-resource-assignment"));\r
+\r
+            workingServiceTemplate.setNodeTypes(node_types);\r
+            workingServiceTemplate.setTopologyTemplate(topology_template);\r
+\r
+            String workingServiceTemplateConmtent = TransformationUtils.getJson(workingServiceTemplate, true);\r
+\r
+            FileUtils.writeStringToFile(new File("src/test/resources/service_templates/resource_assignment.json"),\r
+                    workingServiceTemplateConmtent, Charset.defaultCharset());\r
+\r
+            File lcmFile = new File(\r
+                    "../../../northbound/selfservice-api/provider/src/test/resources/service_templates/resource_assignment.json");\r
+            FileUtils.writeStringToFile(lcmFile, workingServiceTemplateConmtent, Charset.defaultCharset());\r
+\r
+            File resourceAssignmetFile = new File(\r
+                    "../../../plugin/assignment/provider/src/test/resources/service_templates/resource_assignment.json");\r
+            FileUtils.writeStringToFile(resourceAssignmetFile, workingServiceTemplateConmtent,\r
+                    Charset.defaultCharset());\r
+\r
+            System.out.println("NodeTypeCreateUtils.createNodeTemplate() :" + workingServiceTemplateConmtent);\r
+        }\r
+\r
+    }\r
+\r
+    public void createVrrNodeTemplate(ServiceTemplate serviceTemplate) throws IOException {\r
+        if (serviceTemplate != null) {\r
+            ServiceTemplate workingServiceTemplate = new ServiceTemplate();\r
+            workingServiceTemplate.setMetadata(serviceTemplate.getMetadata());\r
+\r
+            TopologyTemplate topology_template = new TopologyTemplate();\r
+            Map<String, NodeTemplate> node_templates = new HashMap<String, NodeTemplate>();\r
+\r
+            Map<String, NodeTemplate> node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates();\r
+\r
+            node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action"));\r
+            node_templates.put("resource-assignment", node_Templates.get("resource-assignment"));\r
+\r
+            node_templates.put("activate-action", node_Templates.get("activate-action"));\r
+            node_templates.put("base-config-template", node_Templates.get("base-config-template"));\r
+            node_templates.put("licence-template", node_Templates.get("licence-template"));\r
+            node_templates.put("vrr-netconf-device", node_Templates.get("vrr-netconf-device"));\r
+            node_templates.put("get-netconf-config", node_Templates.get("get-netconf-config"));\r
+            node_templates.put("edit-netconf-config", node_Templates.get("edit-netconf-config"));\r
+            node_templates.put("transaction-netconf-baseconfig", node_Templates.get("transaction-netconf-baseconfig"));\r
+\r
+            topology_template.setNodeTemplates(node_templates);\r
+            topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs());\r
+\r
+            workingServiceTemplate.setTopologyTemplate(topology_template);\r
+\r
+            String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true);\r
+\r
+            FileUtils.writeStringToFile(new File("src/test/resources/service_templates/vrr_config.json"),\r
+                    workingServiceTemplateContent, Charset.defaultCharset());\r
+\r
+        }\r
+    }\r
+\r
+    public void createDictionarySchema() throws IOException {\r
+        String schema = TransformationUtils.getJsonSchema(ResourceDefinition.class);\r
+        FileUtils.writeStringToFile(new File("src/test/resources/dictionary/dictionary_schema.json"), schema,\r
+                Charset.defaultCharset());\r
+    }\r
+\r
+    public static void main(String[] args) {\r
+        try {\r
+            ServiceTemplateCreateUtils utils = new ServiceTemplateCreateUtils();\r
+            utils.createNodeTypes("src/test/resources/service_templates/default.json");\r
+        } catch (Exception e) {\r
+            // TODO: handle exception\r
+        }\r
+    }\r
+\r
+}\r