Add relationships type files load structure. 78/75478/7
authorMuthuramalingam, Brinda Santh <bs2796@att.com>
Tue, 8 Jan 2019 16:17:05 +0000 (11:17 -0500)
committerBrinda Santh Muthuramalingam <bs2796@att.com>
Thu, 10 Jan 2019 19:59:36 +0000 (19:59 +0000)
Change-Id: I1be3ba493956674b476058094e05d681ce358711
Issue-ID: CCSDK-746
Signed-off-by: Muthuramalingam, Brinda Santh <bs2796@att.com>
18 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json [new file with mode: 0644]
components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java [deleted file]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java [deleted file]
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java [deleted file]
ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt [new file with mode: 0644]

index 6a50680..8caec75 100644 (file)
 \r
 package org.onap.ccsdk.apps.controllerblueprints.core.service\r
 \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.node.ArrayNode\r
 import com.fasterxml.jackson.databind.node.ObjectNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
 \r
 /**\r
  *\r
@@ -34,12 +34,6 @@ import com.att.eelf.configuration.EELFManager
 object BluePrintExpressionService {\r
     val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
 \r
-    @JvmStatic\r
-    fun getExpressionData(propertyAssignment: Any): ExpressionData {\r
-        val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment)\r
-        return getExpressionData(propertyAssignmentNode)\r
-    }\r
-\r
     @JvmStatic\r
     fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData {\r
         log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)\r
@@ -53,19 +47,19 @@ object BluePrintExpressionService {
                 expressionData.expressionNode = propertyAssignmentNode\r
 \r
                 when (expressionData.command) {\r
-                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> {\r
+                    BluePrintConstants.EXPRESSION_GET_INPUT -> {\r
                         expressionData.inputExpression = populateInputExpression(propertyAssignmentNode)\r
                     }\r
-                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {\r
+                    BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {\r
                         expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode)\r
                     }\r
-                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> {\r
+                    BluePrintConstants.EXPRESSION_GET_PROPERTY -> {\r
                         expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode)\r
                     }\r
-                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {\r
+                    BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {\r
                         expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode)\r
                     }\r
-                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {\r
+                    BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {\r
                         expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode)\r
                     }\r
                 }\r
index 5540047..bd19ae4 100644 (file)
@@ -67,6 +67,12 @@ interface BluePrintRuntimeService<T> {
    */\r
     fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode>\r
 \r
+    fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capability: String): MutableMap<String,\r
+            JsonNode>\r
+\r
+    fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap<String,\r
+            JsonNode>\r
+\r
     fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>\r
 \r
     fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>\r
@@ -193,17 +199,15 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
 \r
-        val propertyAssignments: MutableMap<String, JsonNode> =\r
-                nodeTemplate.properties as MutableMap<String, JsonNode>\r
+        val propertyAssignments: MutableMap<String, JsonNode> = nodeTemplate.properties!!\r
 \r
         // Get the Node Type Definitions\r
-        val nodeTypeProperties: MutableMap<String, PropertyDefinition> =\r
-                bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!!\r
+        val nodeTypeProperties: MutableMap<String, PropertyDefinition> = bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!!\r
 \r
         // Iterate Node Type Properties\r
         nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
             // Get the Express or Value for the Node Template\r
-            val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]\r
+            val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]\r
 \r
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
@@ -223,6 +227,18 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
         return propertyAssignmentValue\r
     }\r
 \r
+    override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String):\r
+            MutableMap<String, JsonNode> {\r
+        log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " +\r
+                "($capabilityName)")\r
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    }\r
+\r
+    override fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap<String, JsonNode> {\r
+        log.info("resolveNodeTemplateRequirementProperties for node template($nodeTemplateName) requirement ($requirementName)")\r
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    }\r
+\r
     override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
                                                              interfaceName: String, operationName: String): MutableMap<String, JsonNode> {\r
         log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " +\r
@@ -230,8 +246,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
-        val propertyAssignments: MutableMap<String, Any> =\r
-                bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
+        val propertyAssignments: MutableMap<String, JsonNode> =\r
+                bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
                         ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
@@ -245,7 +261,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
         // Iterate Node Type Properties\r
         nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
             // Get the Express or Value for the Node Template\r
-            val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]\r
+            val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]\r
 \r
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
@@ -275,8 +291,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
-        val propertyAssignments: MutableMap<String, Any> =\r
-                bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
+        val propertyAssignments: MutableMap<String, JsonNode> =\r
+                bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
                         ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
@@ -289,7 +305,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
         nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
 \r
             // Get the Express or Value for the Node Template\r
-            val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]\r
+            val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]\r
 \r
             var resolvedValue: JsonNode = NullNode.getInstance()\r
             if (propertyAssignment != null) {\r
index 36c141f..17380fc 100644 (file)
@@ -47,7 +47,7 @@ If Property Assignment is Expression.
  */\r
 \r
     fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String,\r
-                                    assignment: Any): JsonNode {\r
+                                    assignment: JsonNode): JsonNode {\r
         val valueNode: JsonNode\r
         log.trace("Assignment ({})", assignment)\r
         val expressionData = BluePrintExpressionService.getExpressionData(assignment)\r
index 7ecf44b..1dfb89a 100644 (file)
@@ -55,6 +55,18 @@ class BluePrintRuntimeServiceTest {
         assertNotNull(propContext, "Failed to populate interface property values")\r
     }\r
 \r
+    @Test\r
+    fun testResolveNodeTemplateCapabilityProperties() {\r
+        log.info("************************ testResolveNodeTemplateRequirementProperties **********************")\r
+        //TODO\r
+    }\r
+\r
+    @Test\r
+    fun testResolveNodeTemplateRequirementProperties() {\r
+        log.info("************************ testResolveNodeTemplateRequirementProperties **********************")\r
+        //TODO\r
+    }\r
+\r
     @Test\r
     fun testResolveNodeTemplateInterfaceOperationInputs() {\r
         log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")\r
@@ -72,7 +84,7 @@ class BluePrintRuntimeServiceTest {
         assertNotNull(inContext, "Failed to populate interface input property values")\r
         assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
         assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
-      }\r
+    }\r
 \r
     @Test\r
     fun testResolveNodeTemplateInterfaceOperationOutputs() {\r
index 7d3a17a..6a44635 100644 (file)
             "file": "Scripts/SamplePythonComponentNode.py"
           }
         }
+      },
+      "activate-netconf": {
+        "type": "component-netconf-executor",
+        "interfaces": {
+          "NetconfExecutorComponent": {
+            "operations": {
+              "process": {
+                "implementation": {
+                  "primary": "component-script"
+                },
+                "inputs": {
+                  "instance-dependencies": [
+                    "json-parser-service",
+                    "netconf-rpc-service"
+                  ]
+                },
+                "outputs": {
+                  "response-data": "",
+                  "status": ""
+                }
+              }
+            }
+          }
+        },
+        "requirements": {
+          "netconf-connection": {
+            "capability": "netconf",
+            "node": "sample-netconf-device",
+            "relationship": "tosca.relationships.ConnectsTo"
+          }
+        },
+        "artifacts": {
+          "component-script": {
+            "type": "artifact-script-jython",
+            "file": "Scripts/SamplePythonComponentNode.py"
+          }
+        }
+      },
+      "sample-netconf-device": {
+        "type": "vnf-netconf-device",
+        "capabilities": {
+          "netconf": {
+            "properties": {
+              "login-key": "sample-key",
+              "login-account": "sample-account",
+              "target-ip-address": "localhost",
+              "port-number": 830,
+              "connection-time-out": 30
+            }
+          }
+        }
       }
     },
     "workflows": {
index 6a156ff..f7970bf 100644 (file)
       "version": "1.0.0",
       "derived_from": "tosca.nodes.Root"
     },
+    "tosca.nodes.ResourceSource" : {
+      "description" : "TOSCA base type for Resource Sources",
+      "version" : "1.0.0",
+      "derived_from" : "tosca.nodes.Root"
+    },
+    "tosca.nodes.Vnf" : {
+      "description" : "This is VNF Node Type",
+      "version" : "1.0.0",
+      "derived_from" : "tosca.nodes.Root"
+    },
     "tosca.nodes.component.Jython": {
       "description": "This is Resource Assignment Jython Component API",
       "version": "1.0.0",
       "derived_from": "tosca.nodes.Root"
     },
+    "component-netconf-executor": {
+      "description": "This is Netconf Transaction Configuration Component API",
+      "version": "1.0.0",
+      "capabilities": {
+        "component-node": {
+          "type": "tosca.capabilities.Node"
+        }
+      },
+      "requirements": {
+        "netconf-connection": {
+          "capability": "netconf",
+          "node": "vnf-netconf-device",
+          "relationship": "tosca.relationships.ConnectsTo"
+        }
+      },
+      "interfaces": {
+        "NetconfExecutorComponent": {
+          "operations": {
+            "process": {
+              "inputs": {
+                "instance-dependencies": {
+                  "description": "Instance Names to Inject to Jython Script.",
+                  "required": true,
+                  "type": "list",
+                  "entry_schema": {
+                    "type": "string"
+                  }
+                }
+              },
+              "outputs": {
+                "response-data": {
+                  "description": "Execution Response Data in JSON format.",
+                  "required": false,
+                  "type": "string"
+                },
+                "status": {
+                  "description": "Status of the Component Execution ( success or failure )",
+                  "required": true,
+                  "type": "string"
+                }
+              }
+            }
+          }
+        }
+      },
+      "derived_from": "tosca.nodes.component.Jython"
+    },
     "component-resource-assignment": {
       "description": "This is Resource Assignment Component API",
       "version": "1.0.0",
         }
       },
       "derived_from": "tosca.nodes.component.Jython"
+    },
+    "vnf-netconf-device": {
+      "description": "This is VNF Device with Netconf  Capability",
+      "version": "1.0.0",
+      "capabilities": {
+        "netconf": {
+          "type": "tosca.capabilities.Netconf",
+          "properties": {
+            "login-key": {
+              "required": true,
+              "type": "string",
+              "default": "sdnc"
+            },
+            "login-account": {
+              "required": true,
+              "type": "string",
+              "default": "sdnc-tacacs"
+            },
+            "source": {
+              "required": true,
+              "type": "string",
+              "default": "npm"
+            },
+            "target-ip-address": {
+              "required": true,
+              "type": "string"
+            },
+            "port-number": {
+              "required": true,
+              "type": "integer",
+              "default": 830
+            },
+            "connection-time-out": {
+              "required": false,
+              "type": "integer",
+              "default": 30
+            }
+          }
+        }
+      },
+      "derived_from": "tosca.nodes.Vnf"
     }
   }
 }
\ No newline at end of file
index 7e1d813..b8ac762 100644 (file)
       "operations": {\r
         "process": {\r
           "inputs": {\r
-            "request-id": {\r
-              "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+            "instance-dependencies": {\r
               "required": true,\r
-              "type": "string"\r
-            },\r
-            "template-name": {\r
-              "description": "Service Template Name",\r
-              "required": true,\r
-              "type": "string"\r
-            },\r
-            "template-version": {\r
-              "description": "Service Template Version",\r
-              "required": true,\r
-              "type": "string"\r
-            },\r
-            "action-name": {\r
-              "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
-              "required": false,\r
-              "type": "string"\r
-            },\r
-            "resource-type": {\r
-              "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
-              "required": false,\r
-              "type": "string"\r
-            },\r
-            "resource-id": {\r
-              "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
-              "required": false,\r
-              "type": "string"\r
-            },\r
-            "reservation-id": {\r
-                               "description": "Reservation Id used to send to NPM",\r
-                               "required": false,\r
-                               "type": "string"\r
-                       },\r
-            "execution-script": {\r
-              "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.",\r
-              "required": true,\r
-              "type": "string"\r
+              "description": "Instance Names to Inject to Jython Script.",\r
+              "type": "list",\r
+              "entry_schema": {\r
+                "type": "string"\r
+              }\r
             }\r
           },\r
           "outputs": {\r
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json
new file mode 100644 (file)
index 0000000..4abb948
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "description": "Relationship tosca.relationships.ConnectsTo",
+  "version": "1.0.0",
+  "derived_from": "tosca.relationships.Root"
+}
\ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json
new file mode 100644 (file)
index 0000000..89987ff
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "description": "Relationship tosca.relationships.DependsOn",
+  "version": "1.0.0",
+  "derived_from": "tosca.relationships.Root"
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
deleted file mode 100644 (file)
index 9641f89..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*\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.apps.controllerblueprints.service.validator;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * ModelTypeValidation.java Purpose: Provide Validation Service for Model Type ModelTypeValidation\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-\r
-public class ModelTypeValidator {\r
-\r
-    private ModelTypeValidator() {\r
-\r
-    }\r
-\r
-    private static List<String> getValidModelDefinitionType() {\r
-        List<String> validTypes = new ArrayList<>();\r
-        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);\r
-        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);\r
-        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);\r
-        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE);\r
-        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE);\r
-        return validTypes;\r
-    }\r
-\r
-    /**\r
-     * This is a validateModelTypeDefinition\r
-     * \r
-     * @param definitionType definitionType\r
-     * @param definitionContent definitionContent\r
-     * @return boolean\r
-     * @throws BluePrintException BluePrintException\r
-     */\r
-    public static boolean validateModelTypeDefinition(String definitionType, JsonNode definitionContent)\r
-            throws BluePrintException {\r
-        if (definitionContent != null) {\r
-            if (BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)) {\r
-                DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);\r
-                if (dataType == null) {\r
-                    throw new BluePrintException(\r
-                            "Model type definition is not DataType valid content " + definitionContent);\r
-                }\r
-            } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {\r
-                NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);\r
-                if (nodeType == null) {\r
-                    throw new BluePrintException(\r
-                            "Model type definition is not NodeType valid content " + definitionContent);\r
-                }\r
-            } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {\r
-                ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);\r
-                if (artifactType == null) {\r
-                    throw new BluePrintException(\r
-                            "Model type definition is not ArtifactType valid content " + definitionContent);\r
-                }\r
-            }else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {\r
-                CapabilityDefinition capabilityDefinition =\r
-                        JacksonUtils.readValue(definitionContent, CapabilityDefinition.class);\r
-                if (capabilityDefinition == null) {\r
-                    throw new BluePrintException(\r
-                            "Model type definition is not CapabilityDefinition valid content " + definitionContent);\r
-                }\r
-            }\r
-\r
-        }\r
-        return true;\r
-    }\r
-\r
-    /**\r
-     * This is a validateModelType method\r
-     * \r
-     * @param modelType modelType\r
-     * @return boolean\r
-     * @throws BluePrintException BluePrintException\r
-     */\r
-    public static boolean validateModelType(ModelType modelType) throws BluePrintException {\r
-        if (modelType != null) {\r
-\r
-            if (StringUtils.isBlank(modelType.getModelName())) {\r
-                throw new BluePrintException("Model Name Information is missing.");\r
-            }\r
-\r
-            if (StringUtils.isBlank(modelType.getDefinitionType())) {\r
-                throw new BluePrintException("Model Root Type Information is missing.");\r
-            }\r
-            if (StringUtils.isBlank(modelType.getDerivedFrom())) {\r
-                throw new BluePrintException("Model Type Information is missing.");\r
-            }\r
-\r
-            if (modelType.getDefinition() == null) {\r
-                throw new BluePrintException("Model Definition Information is missing.");\r
-            }\r
-            if (StringUtils.isBlank(modelType.getDescription())) {\r
-                throw new BluePrintException("Model Description Information is missing.");\r
-            }\r
-\r
-            if (StringUtils.isBlank(modelType.getVersion())) {\r
-                throw new BluePrintException("Model Version Information is missing.");\r
-            }\r
-\r
-            if (StringUtils.isBlank(modelType.getUpdatedBy())) {\r
-                throw new BluePrintException("Model Updated By Information is missing.");\r
-            }\r
-\r
-            List<String> validRootTypes = getValidModelDefinitionType();\r
-            if (!validRootTypes.contains(modelType.getDefinitionType())) {\r
-                throw new BluePrintException("Not Valid Model Root Type(" + modelType.getDefinitionType()\r
-                        + "), It should be " + validRootTypes);\r
-            }\r
-\r
-            validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());\r
-\r
-        } else {\r
-            throw new BluePrintException("Model Type Information is missing.");\r
-        }\r
-\r
-        return true;\r
-\r
-    }\r
-\r
-}\r
index 8b6e54a..8144a1e 100644 (file)
@@ -17,6 +17,7 @@
 package org.onap.ccsdk.apps.controllerblueprints.service.load
 
 import com.att.eelf.configuration.EELFManager
+import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.springframework.boot.context.event.ApplicationReadyEvent
 import org.springframework.context.event.EventListener
@@ -49,7 +50,9 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
         if (bluePrintLoadConfiguration.loadModelType) {
             val paths = bluePrintLoadConfiguration.loadModeTypePaths?.split(",")
             paths?.let {
-                modelTypeLoadService.loadPathsModelType(paths)
+                runBlocking {
+                    modelTypeLoadService.loadPathsModelType(paths)
+                }
             }
         }
     }
index 51bbca7..061ef88 100644 (file)
@@ -21,9 +21,8 @@ import kotlinx.coroutines.*
 import org.apache.commons.io.FilenameUtils
 import org.apache.commons.lang3.text.StrBuilder
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
-import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
 import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
@@ -37,11 +36,14 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
     private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java)
     private val updateBySystem = "System"
 
-    open fun loadPathsModelType(modelTypePaths: List<String>) {
-        modelTypePaths.forEach { loadPathModelType(it) }
+    open suspend fun loadPathsModelType(modelTypePaths: List<String>) {
+        modelTypePaths.forEach { runBlocking { loadPathModelType(it) } }
     }
 
-    open fun loadPathModelType(modelTypePath: String) = runBlocking {
+    /**
+     * Load the Model Type file content from the defined path, Load of sequencing should be maintained.
+     */
+    open suspend fun loadPathModelType(modelTypePath: String) = runBlocking {
         log.info(" *************************** loadModelType **********************")
         try {
             val errorBuilder = StrBuilder()
@@ -51,17 +53,35 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
 
                 val deferredResults = mutableListOf<Deferred<Unit>>()
 
-                for (file in dataTypeFiles) deferredResults += async { loadDataType(file, errorBuilder) }
+                for (file in dataTypeFiles) deferredResults += async {
+                    loadModelType(file, DataType::class.java, errorBuilder)
+                }
 
                 deferredResults.awaitAll()
             }
 
             coroutineScope {
-                val artifactTypefiles = File("$modelTypePath/artifact_type").listFiles()
+                val artifactTypeFiles = File("$modelTypePath/artifact_type").listFiles()
 
                 val deferredResults = mutableListOf<Deferred<Unit>>()
 
-                for (file in artifactTypefiles) deferredResults += async { loadArtifactType(file, errorBuilder) }
+                for (file in artifactTypeFiles) deferredResults += async {
+                    loadModelType(file,
+                            ArtifactType::class.java, errorBuilder)
+                }
+
+                deferredResults.awaitAll()
+            }
+
+            coroutineScope {
+                val relationshipTypeFiles = File("$modelTypePath/relationship_type").listFiles()
+
+                val deferredResults = mutableListOf<Deferred<Unit>>()
+
+                for (file in relationshipTypeFiles) deferredResults += async {
+                    loadModelType(file,
+                            RelationshipType::class.java, errorBuilder)
+                }
 
                 deferredResults.awaitAll()
             }
@@ -71,7 +91,10 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
 
                 val deferredResults = mutableListOf<Deferred<Unit>>()
 
-                for (file in nodeTypeFiles) deferredResults += async { loadNodeType(file, errorBuilder) }
+                for (file in nodeTypeFiles) deferredResults += async {
+                    loadModelType(file,
+                            NodeType::class.java, errorBuilder)
+                }
                 deferredResults.awaitAll()
             }
 
@@ -83,76 +106,45 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
         }
     }
 
-    private fun loadDataType(file: File, errorBuilder: StrBuilder) {
-        try {
-            log.trace("Loading DataType(${file.name}")
-            val dataKey = FilenameUtils.getBaseName(file.name)
-            val definitionContent = file.readText(Charset.defaultCharset())
-            val dataType = JacksonUtils.readValue(definitionContent, DataType::class.java)
-            checkNotNull(dataType) { "failed to get data type from file : ${file.name}" }
-
-            val modelType = ModelType()
-            modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
-            modelType.derivedFrom = dataType.derivedFrom
-            modelType.description = dataType.description
-            modelType.definition = JacksonUtils.jsonNode(definitionContent)
-            modelType.modelName = dataKey
-            modelType.version = dataType.version
-            modelType.updatedBy = updateBySystem
-            modelType.tags = (dataKey + "," + dataType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
-            modelTypeHandler.saveModel(modelType)
-            log.trace("DataType(${file.name}) loaded successfully ")
-        } catch (e: Exception) {
-            errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}")
-        }
-    }
-
-    private fun loadArtifactType(file: File, errorBuilder: StrBuilder) {
+    private inline fun <reified T> loadModelType(file: File, classType: Class<T>, errorBuilder: StrBuilder) {
         try {
-            log.trace("Loading ArtifactType(${file.name}")
+            log.trace("Loading ${classType.name} (${file.name})")
             val dataKey = FilenameUtils.getBaseName(file.name)
             val definitionContent = file.readText(Charset.defaultCharset())
-            val artifactType = JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
-            checkNotNull(artifactType) { "failed to get artifact type from file : ${file.name}" }
+            val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType
+            //checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
 
             val modelType = ModelType()
-            modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE
-            modelType.derivedFrom = artifactType.derivedFrom
-            modelType.description = artifactType.description
+            val definitionType: String?
+            when (T::class) {
+                DataType::class -> {
+                    definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+                }
+                RelationshipType::class -> {
+                    definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE
+                }
+                ArtifactType::class -> {
+                    definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE
+                }
+                NodeType::class -> {
+                    definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE
+                }
+                else -> {
+                    throw BluePrintException("couldn't process model type($classType) definition")
+                }
+            }
+            modelType.definitionType = definitionType
+            modelType.derivedFrom = definition.derivedFrom
+            modelType.description = definition.description
             modelType.definition = JacksonUtils.jsonNode(definitionContent)
             modelType.modelName = dataKey
-            modelType.version = artifactType.version
+            modelType.version = definition.version
             modelType.updatedBy = updateBySystem
-            modelType.tags = (dataKey + "," + artifactType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
+            modelType.tags = (dataKey + "," + definition.derivedFrom + "," + definitionType)
             modelTypeHandler.saveModel(modelType)
-            log.trace("ArtifactType(${file.name}) loaded successfully ")
+            log.trace("${classType.name}(${file.name}) loaded successfully ")
         } catch (e: Exception) {
-            errorBuilder.appendln("Couldn't load ArtifactType(${file.name}: ${e.message}")
+            errorBuilder.appendln("Couldn't load ${classType.name}(${file.name}: ${e.message}")
         }
     }
-
-    private fun loadNodeType(file: File, errorBuilder: StrBuilder) {
-        try {
-            log.trace("Loading NodeType(${file.name}")
-            val nodeKey = FilenameUtils.getBaseName(file.name)
-            val definitionContent = file.readText(Charset.defaultCharset())
-            val nodeType = JacksonUtils.readValue(definitionContent, NodeType::class.java)
-            checkNotNull(nodeType) { "failed to get node type from file : ${file.name}" }
-
-            val modelType = ModelType()
-            modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE
-            modelType.derivedFrom = nodeType.derivedFrom
-            modelType.description = nodeType.description
-            modelType.definition = JacksonUtils.jsonNode(definitionContent)
-            modelType.modelName = nodeKey
-            modelType.version = nodeType.version
-            modelType.updatedBy = updateBySystem
-            modelType.tags = (nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + nodeType.derivedFrom)
-            modelTypeHandler.saveModel(modelType)
-            log.trace("NodeType(${file.name}) loaded successfully ")
-        } catch (e: Exception) {
-            errorBuilder.appendln("Couldn't load NodeType(${file.name}: ${e.message}")
-        }
-    }
-
 }
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt
new file mode 100644 (file)
index 0000000..1428c81
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.validator
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+
+class ModelTypeValidator {
+    companion object {
+        /**
+         * This is a validateModelTypeDefinition
+         *
+         * @param definitionType definitionType
+         * @param definitionContent definitionContent
+         * @return boolean
+         */
+        fun validateModelTypeDefinition(definitionType: String, definitionContent: JsonNode): Boolean {
+
+            when (definitionType) {
+                BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> {
+                    JacksonUtils.readValue(definitionContent, DataType::class.java)
+                            ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent")
+                }
+                BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> {
+                    JacksonUtils.readValue(definitionContent, NodeType::class.java)
+                            ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent")
+                }
+                BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> {
+                    JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
+                            ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent")
+                }
+                BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> {
+                    JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java)
+                            ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent")
+                }
+                BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> {
+                    JacksonUtils.readValue(definitionContent, RelationshipType::class.java)
+                            ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent")
+                }
+            }
+            return true
+        }
+
+        /**
+         * This is a validateModelType method
+         *
+         * @param modelType modelType
+         * @return boolean
+         */
+        fun validateModelType(modelType: ModelType?): Boolean {
+            checkNotNull(modelType) { "Model Type Information is missing." }
+
+            val validRootTypes = BluePrintTypes.validModelTypes()
+
+            check(validRootTypes.contains(modelType.definitionType)) {
+                "Not Valid Model Root Type(${modelType.definitionType}), It should be $validRootTypes"
+            }
+
+            validateModelTypeDefinition(modelType.definitionType, modelType.definition)
+            return true
+        }
+    }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
deleted file mode 100644 (file)
index 23e5294..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService;
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext;
-import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService;
-import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.nio.file.Paths;
-
-@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = {TestApplication.class})
-@TestPropertySource(locations = {"classpath:application.properties"})
-public class BluePrintEnhancerServiceImplTest {
-
-    @Autowired
-    private ModelTypeLoadService modelTypeLoadService;
-
-    @Autowired
-    private ResourceDictionaryLoadService resourceDictionaryLoadService;
-
-    @Autowired
-    private BluePrintEnhancerService bluePrintEnhancerService;
-
-    @Autowired
-    private BluePrintValidatorService bluePrintValidatorService;
-
-    @Before
-    public void init() {
-        modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type");
-        resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary");
-    }
-
-    @Test
-    public void testEnhancementAndValidation() throws Exception {
-
-        String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
-
-        String targetPath = Paths.get("target", "bp-enhance").toUri().getPath();
-
-        BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath);
-        Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext);
-
-        // Validate the Generated BluePrints
-        Boolean valid = bluePrintValidatorService.validateBluePrints(targetPath);
-        Assert.assertTrue("blueprint validation failed ", valid);
-    }
-}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java
deleted file mode 100644 (file)
index 16b2bc8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.validator;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-
-public class ModelTypeValidatorTest {
-
-    @Before
-    public void setup(){
-        ModelTypeValidator modelTypeValidator;
-    }
-
-    @Test
-    public void testGetValidModelDefinitionType_definitionContentNULL() throws Exception{
-        String definitionType=null;
-        JsonNode definitionContent=null;
-        boolean valid= ModelTypeValidator.validateModelTypeDefinition(definitionType, definitionContent);
-        Assert.assertTrue(valid);
-
-    }
-
-    @Test(expected=BluePrintException.class)
-    public void testvalidateModelType() throws Exception{
-        ModelType modelType = new ModelType();
-        modelType.setDefinitionType("");
-        modelType.setDerivedFrom("");
-        modelType.setDescription("");
-        JsonNode definitionContent=null;
-        modelType.setDefinition(definitionContent);
-        modelType.setModelName("");
-        modelType.setVersion("");
-        modelType.setTags("");
-        modelType.setUpdatedBy("");
-        ModelTypeValidator.validateModelType(modelType);
-    }
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
new file mode 100644 (file)
index 0000000..4ab6708
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService
+import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import java.nio.file.Paths
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = arrayOf(TestApplication::class))
+@TestPropertySource(locations = arrayOf("classpath:application.properties"))
+class BluePrintEnhancerServiceImplTest {
+
+    @Autowired
+    private val modelTypeLoadService: ModelTypeLoadService? = null
+
+    @Autowired
+    private val resourceDictionaryLoadService: ResourceDictionaryLoadService? = null
+
+    @Autowired
+    private val bluePrintEnhancerService: BluePrintEnhancerService? = null
+
+    @Autowired
+    private val bluePrintValidatorService: BluePrintValidatorService? = null
+
+    @Before
+    fun init() {
+        runBlocking {
+            modelTypeLoadService!!.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
+            resourceDictionaryLoadService!!.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
+        }
+    }
+
+    @Test
+    @Throws(Exception::class)
+    fun testEnhancementAndValidation() {
+
+        val basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+
+        val targetPath = Paths.get("target", "bp-enhance").toUri().path
+
+        val bluePrintContext = bluePrintEnhancerService!!.enhance(basePath, targetPath)
+        Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
+
+        // Validate the Generated BluePrints
+        val valid = bluePrintValidatorService!!.validateBluePrints(targetPath)
+        Assert.assertTrue("blueprint validation failed ", valid)
+    }
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt
new file mode 100644 (file)
index 0000000..db4ee5c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.validator
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+
+class ModelTypeValidatorTest {
+
+    @Test(expected = IllegalStateException::class)
+    @Throws(Exception::class)
+    fun testvalidateModelType() {
+        val modelType = ModelType()
+        modelType.definitionType = ""
+        modelType.derivedFrom = ""
+        modelType.description = ""
+        val definitionContent: JsonNode? = null
+        modelType.definition = definitionContent
+        modelType.modelName = ""
+        modelType.version = ""
+        modelType.tags = ""
+        modelType.updatedBy = ""
+        ModelTypeValidator.validateModelType(modelType)
+    }
+}