Merge "Generate dependency list"
authorKAPIL SINGAL <ks220y@att.com>
Thu, 12 Dec 2019 16:18:21 +0000 (16:18 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 12 Dec 2019 16:18:21 +0000 (16:18 +0000)
45 files changed:
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta
components/model-catalog/blueprint-model/test-blueprint/capability_cli/TOSCA-Metadata/TOSCA.meta
components/model-catalog/blueprint-model/test-blueprint/resource-audit/TOSCA-Metadata/TOSCA.meta
components/model-catalog/blueprint-model/uat-blueprints/echo/TOSCA-Metadata/TOSCA.meta
ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutorTest.kt
ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintJythonServiceImpl.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHost.kt [moved from ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt with 94% similarity]
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonInterpreterProxy.kt [moved from ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt with 92% similarity]
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/PythonExecutorConfiguration.kt [moved from ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt with 89% similarity]
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintJythonServiceTest.kt [moved from ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt with 59% similarity]
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHostTest.kt [moved from ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt with 96% similarity]
ms/blueprintsprocessor/functions/python-executor/src/test/resources/PythonTestScript.py [moved from ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/PythonTestScript.py with 100% similarity]
ms/blueprintsprocessor/functions/python-executor/src/test/resources/scripts/SamplePythonComponentNode.py [moved from ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/scripts/SamplePythonComponentNode.py with 100% similarity]
ms/blueprintsprocessor/functions/resource-resolution/pom.xml
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta
ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip [deleted file]
ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt
ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip [deleted file]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip [deleted file]
ms/blueprintsprocessor/modules/services/execution-service/pom.xml
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt

index 854c20b..7d3d919 100644 (file)
@@ -2,7 +2,8 @@ TOSCA-Meta-File-Version: 1.0.0
 CSAR-Version: 1.0
 Created-By: Brinda Santh <brindasanth@in.ibm.com>
 Entry-Definitions: Definitions/activation-blueprint.json
-Template-Tags: Brinda Santh, activation-blueprint
 Template-Name: baseconfiguration
 Template-Version: 1.0.0
+Template-Type: DEFAULT
+Template-Tags: Brinda Santh, activation-blueprint
 
index 6c4bb36..178034b 100644 (file)
@@ -4,4 +4,5 @@ Created-By: Brinda Santh
 Entry-Definitions: Definitions/capability-cli-blueprint.json
 Template-Name: capability-cli
 Template-Version: 1.0.0
+Template-Type: DEFAULT
 Template-Tags: capability-cli-blueprint
index d2f533c..ed032d5 100644 (file)
@@ -4,4 +4,5 @@ Created-By: Brinda Santh
 Entry-Definitions: cba.resource.audit.ResourceAuditDefinitions.kt
 Template-Name: resource-audit
 Template-Version: 1.0.0
+Template-Type: KOTLIN_DSL
 Template-Tags: resource-audit
\ No newline at end of file
index 83fffa4..fe425c1 100644 (file)
@@ -2,6 +2,6 @@ TOSCA-Meta-File-Version: 1.0.0
 CSAR-Version: 1.0
 Created-By: Rodrigo Ottero
 Entry-Definitions: Definitions/echo-test.json
-Template-Name: echo-test
+Template-Name: echo_test
 Template-Version: 1.0.0
 Template-Tags: echo-test
index 262563d..db71283 100644 (file)
@@ -194,7 +194,7 @@ class ComponentRemoteAnsibleExecutorTest {
         awxRemoteExecutor: ComponentRemoteAnsibleExecutor,
         executionServiceInput: ExecutionServiceInput
     ): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
-        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+        val bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime(
             "123456-1000",
             "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_ansible"
         )
index 450da1c..c6166eb 100644 (file)
@@ -55,7 +55,7 @@ class ComponentConfigSnapshotsExecutorTest {
     @Autowired
     lateinit var cfgSnapshotService: ResourceConfigSnapshotService
     lateinit var cfgSnapshotComponent: ComponentConfigSnapshotsExecutor
-    private var bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+    private var bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime(
         "123456-1000",
         "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
     )
index b0dcc63..99e6c6c 100644 (file)
@@ -21,9 +21,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor
 import com.fasterxml.jackson.databind.node.ArrayNode
 import org.apache.commons.io.FilenameUtils
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts.BlueprintJythonServiceImpl
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts.PythonExecutorConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
@@ -38,7 +38,7 @@ import org.springframework.stereotype.Component
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class ComponentJythonExecutor(
     private var applicationContext: ApplicationContext,
-    private val blueprintJythonService: BlueprintJythonService
+    private val blueprintJythonService: BlueprintJythonServiceImpl
 ) : AbstractComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
@@ -57,22 +57,22 @@ open class ComponentJythonExecutor(
 
     override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
         bluePrintRuntimeService.getBluePrintError()
-            .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
+                .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
     }
 
     private fun populateJythonComponentInstance() {
         val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
 
         val operationAssignment: OperationAssignment = bluePrintContext
-            .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+                .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
 
         val artifactName: String = operationAssignment.implementation?.primary
-            ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+                ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
 
         val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
 
         val pythonFileName = artifactDefinition.file
-            ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+                ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
 
         val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
 
@@ -81,7 +81,7 @@ open class ComponentJythonExecutor(
         checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
 
         val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
-            ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+                ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
 
         val jythonInstance: MutableMap<String, Any> = hashMapOf()
         jythonInstance["log"] = LoggerFactory.getLogger(pythonClassName)
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintJythonServiceImpl.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintJythonServiceImpl.kt
new file mode 100644 (file)
index 0000000..7f4afe6
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright Â© 2018-2019 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.cds.blueprintsprocessor.functions.python.executor.scripts
+
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.apache.commons.io.FilenameUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Deprecated("CDS won't support JythonService")
+@Service("blueprintJythonService")
+class BlueprintJythonServiceImpl(
+    val pythonExecutorProperty: PythonExecutorProperty,
+    private val applicationContext: ApplicationContext
+) : BlueprintJythonService {
+
+    val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java)
+
+    inline fun <reified T> jythonInstance(
+        blueprintContext: BluePrintContext,
+        pythonClassName: String,
+        content: String,
+        dependencyInstanceNames: MutableMap<String, Any>?
+    ): T {
+
+        val blueprintBasePath: String = blueprintContext.rootPath
+        val pythonPath: MutableList<String> = arrayListOf()
+        pythonPath.add(blueprintBasePath)
+        pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+        val blueprintPythonConfigurations =
+            BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
+
+        val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
+        val pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
+
+        log.info("Component Object {}", pyObject)
+
+        return pyObject.__tojava__(T::class.java) as T
+    }
+
+    override fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
+        BlueprintFunctionNode<*, *> {
+
+        val pythonFileName = bluePrintContext.rootPath
+            .plus(File.separator)
+            .plus(scriptClassReference)
+
+        val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
+        log.info("Getting Jython Script Class($pythonClassName)")
+
+        val content: String = JacksonUtils.getContent(pythonFileName)
+
+        val jythonInstances: MutableMap<String, Any> = hashMapOf()
+        jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
+
+        return jythonInstance<BlueprintFunctionNode<*, *>>(
+            bluePrintContext, pythonClassName,
+            content, jythonInstances
+        )
+    }
+
+    fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
+
+        val bluePrintRuntimeService = abstractComponentFunction.bluePrintRuntimeService
+        val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+        val nodeTemplateName: String = abstractComponentFunction.nodeTemplateName
+        val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs
+
+        val operationAssignment: OperationAssignment = bluePrintContext
+            .nodeTemplateInterfaceOperation(
+                abstractComponentFunction.nodeTemplateName,
+                abstractComponentFunction.interfaceName, abstractComponentFunction.operationName
+            )
+
+        val blueprintBasePath: String = bluePrintContext.rootPath
+
+        val artifactName: String = operationAssignment.implementation?.primary
+            ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+
+        val artifactDefinition =
+            bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+
+        val pythonFileName = artifactDefinition.file
+            ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+
+        val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
+        log.info("Getting Jython Script Class($pythonClassName)")
+
+        val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
+
+        checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
+
+        val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
+        pythonPath.add(blueprintBasePath)
+        pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+        val jythonInstances: MutableMap<String, Any> = hashMapOf()
+        jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
+
+        val instanceDependenciesNode: ArrayNode =
+            operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
+                ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+
+        instanceDependenciesNode.forEach { instanceName ->
+            jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
+        }
+
+        val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(
+            bluePrintContext, pythonClassName,
+            content!!, jythonInstances
+        )
+
+        return scriptComponentFunction
+    }
+}
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
 
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.python.core.PyObject
 import org.python.util.PythonInterpreter
 
+@Deprecated("CDS won't support JythonService")
 open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython) {
     private val blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
 
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
 
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.python.core.PyObject
 import org.python.core.PySyntaxError
 import org.python.util.PythonInterpreter
 
+@Deprecated("CDS won't support JythonService")
 open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrintPython) : PythonInterpreter() {
 
     fun getPythonInstance(properties: MutableMap<String, Any>?): PyObject {
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
 
 import org.springframework.beans.factory.annotation.Value
 import org.springframework.boot.context.properties.EnableConfigurationProperties
@@ -25,11 +25,13 @@ import org.springframework.context.annotation.Configuration
 import java.io.File
 import java.util.Properties
 
+@Deprecated("CDS won't support JythonService")
 @Configuration
 @ComponentScan
 @EnableConfigurationProperties
 open class PythonExecutorConfiguration
 
+@Deprecated("CDS won't support JythonService")
 @Configuration
 open class PythonExecutorProperty {
 
@@ -39,12 +41,14 @@ open class PythonExecutorProperty {
     lateinit var modulePaths: List<String>
 }
 
+@Deprecated("CDS won't support JythonService")
 class PythonExecutorConstants {
     companion object {
         const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
     }
 }
 
+@Deprecated("CDS won't support JythonService")
 open class BluePrintPython(
     executablePath: String,
     blueprintPythonPlatform: MutableList<String>,
index 4e91927..784c6b7 100644 (file)
@@ -24,8 +24,8 @@ import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.mock.MockInstanceConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts.PythonExecutorConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts.PythonExecutorProperty
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
index 847b080..3d58afa 100644 (file)
@@ -102,7 +102,7 @@ class ComponentRemotePythonExecutorTest {
      * Mocked input information for remote python executor.
      */
     fun getMockedOutput(svc: DefaultBluePrintRuntimeService):
-            ExecutionServiceInput {
+        ExecutionServiceInput {
         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
 
         stepMetaData.putJsonElement(
@@ -165,13 +165,12 @@ class ComponentRemotePythonExecutorTest {
                 "ComponentRemotePythonExecutor", "process"
             )
         } returns operationOutputs
-        val bluePrintRuntimeService = BluePrintMetadataUtils
-            .getBluePrintRuntime(
-                "123456-1000",
-                "./../../../../components/model-" +
-                        "catalog/blueprint-model/test-blueprint/" +
-                        "remote_scripts"
-            )
+        val bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime(
+            "123456-1000",
+            "./../../../../components/model-" +
+                "catalog/blueprint-model/test-blueprint/" +
+                "remote_scripts"
+        )
         every {
             svc.resolveNodeTemplateArtifactDefinition(
                 "execute-remote-python", "component-script"
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
 
 import io.mockk.every
 import io.mockk.mockk
@@ -32,17 +32,15 @@ import kotlin.test.BeforeTest
 import kotlin.test.assertNotNull
 
 @RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
-@TestPropertySource(
-    properties =
-    ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
-        "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"]
-)
+@ContextConfiguration(classes = [BlueprintJythonServiceImpl::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+    "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
 class BlueprintJythonServiceTest {
 
     lateinit var blueprintContext: BluePrintContext
     @Autowired
-    private lateinit var blueprintJythonService: BlueprintJythonService
+    private lateinit var blueprintJythonService: BlueprintJythonServiceImpl
 
     @BeforeTest
     fun init() {
@@ -52,24 +50,22 @@ class BlueprintJythonServiceTest {
 
     @Test
     fun testGetAbstractPythonPlugin() {
-        val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
-        val dependencies: MutableMap<String, Any> = hashMapOf()
+            val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
+            val dependencies: MutableMap<String, Any> = hashMapOf()
 
-        val abstractPythonPlugin = blueprintJythonService
-            .jythonInstance<AbstractComponentFunction>(
-                blueprintContext, "SamplePythonComponentNode",
-                content, dependencies
-            )
+            val abstractPythonPlugin = blueprintJythonService
+                    .jythonInstance<AbstractComponentFunction>(blueprintContext, "SamplePythonComponentNode",
+                            content, dependencies)
 
-        assertNotNull(abstractPythonPlugin, "failed to get python component")
+            assertNotNull(abstractPythonPlugin, "failed to get python component")
     }
 
     @Test
     fun testGetAbstractJythonComponent() {
-        val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
+            val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
 
-        val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+            val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
 
-        assertNotNull(abstractJythonComponent, "failed to get Jython component")
+            assertNotNull(abstractJythonComponent, "failed to get Jython component")
     }
 }
index e8116b1..2af7c6e 100644 (file)
             <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
             <artifactId>db-lib</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
-            <artifactId>python-executor</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
index 774c402..2219f23 100644 (file)
@@ -15,7 +15,7 @@
  */
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock
 
-import io.mockk.every
+import io.mockk.coEvery
 import io.mockk.mockk
 import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
@@ -38,8 +38,8 @@ open class MockBlueprintProcessorCatalogServiceImpl {
     @Bean(name = ["bluePrintRuntimeValidatorService"])
     open fun bluePrintRuntimeValidatorService(): BluePrintValidatorService {
         val bluePrintValidatorService = mockk<BluePrintValidatorService>()
-        every { bluePrintValidatorService.validateBluePrints(any<String>()) } returns true
-        every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
+        coEvery { bluePrintValidatorService.validateBluePrints(any<String>()) } returns true
+        coEvery { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
         return bluePrintValidatorService
     }
 }
index 8f6ac9f..d84488d 100644 (file)
@@ -24,46 +24,25 @@ import io.mockk.every
 import io.mockk.mockk
 import kotlinx.coroutines.runBlocking
 import org.junit.Test
-import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceAssignment
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
 import org.onap.ccsdk.cds.controllerblueprints.core.logger
-import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
-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 kotlin.test.assertEquals
 import kotlin.test.assertNotNull
 import kotlin.test.assertTrue
 
-@RunWith(SpringRunner::class)
-@ContextConfiguration(
-    classes = [CapabilityResourceResolutionProcessor::class, ComponentFunctionScriptingService::class,
-        BluePrintScriptsServiceImpl::class,
-        BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class]
-)
-@TestPropertySource(
-    properties =
-    ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
-        "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"]
-)
 class CapabilityResourceResolutionProcessorTest {
 
-    @Autowired
-    lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor
-
     @Test
     fun `test kotlin capability`() {
         runBlocking {
@@ -111,8 +90,17 @@ class CapabilityResourceResolutionProcessorTest {
                 "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python"
             )
 
+            val componentFunctionScriptingService = mockk<ComponentFunctionScriptingService>()
+            coEvery {
+                componentFunctionScriptingService
+                    .scriptInstance<ResourceAssignmentProcessor>(any(), BluePrintConstants.SCRIPT_JYTHON, any())
+            } returns MockCapabilityScriptRA()
+
             val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
 
+            val capabilityResourceResolutionProcessor =
+                CapabilityResourceResolutionProcessor(componentFunctionScriptingService)
+
             capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
 
             val resourceDefinition = JacksonUtils
@@ -154,6 +142,11 @@ open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
         executionRequest.property!!.value = "assigned-data".asJsonPrimitive()
     }
 
+    override fun process(executionRequest: ResourceAssignment) {
+        log.info("executing RA mock capability : ${executionRequest.name}")
+        executionRequest.property!!.value = "assigned-data".asJsonPrimitive()
+    }
+
     override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
         TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
     }
index c564d33..a358f6a 100644 (file)
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.TextNode
 import io.mockk.every
 import io.mockk.spyk
+import kotlinx.coroutines.runBlocking
 import org.junit.Before
 import org.junit.Test
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
@@ -63,9 +64,11 @@ class ResourceAssignmentUtilsTest {
     @Before
     fun setup() {
 
-        val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
-            "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
-        )
+        val bluePrintContext = runBlocking {
+            BluePrintMetadataUtils.getBluePrintContext(
+                "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+            )
+        }
 
         resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
 
@@ -94,11 +97,11 @@ class ResourceAssignmentUtilsTest {
             id = "ipAddress"
         }
 
-        var mapOfPropertiesIpAddress = mutableMapOf<String, PropertyDefinition>()
+        val mapOfPropertiesIpAddress = mutableMapOf<String, PropertyDefinition>()
         mapOfPropertiesIpAddress["port"] = propertiesDefinition1
         mapOfPropertiesIpAddress["ip"] = propertiesDefinition2
 
-        var mapOfPropertiesHost = mutableMapOf<String, PropertyDefinition>()
+        val mapOfPropertiesHost = mutableMapOf<String, PropertyDefinition>()
         mapOfPropertiesHost["name"] = propertiesDefinition3
         mapOfPropertiesHost["ipAddress"] = propertiesDefinition4
 
index 3016228..fcc921c 100644 (file)
@@ -59,6 +59,10 @@ object BluePrintConstants {
     const val DATA_TYPE_MAP: String = "map"
     const val DATA_TYPE_JSON: String = "json"
 
+    const val BLUEPRINT_TYPE_DEFAULT = "DEFAULT"
+    const val BLUEPRINT_TYPE_KOTLIN_DSL = "KOTLIN_DSL"
+    const val BLUEPRINT_TYPE_GENERIC_SCRIPT = "GENERIC_SCRIPT"
+
     const val SCRIPT_KOTLIN = "kotlin"
     const val SCRIPT_JYTHON = "jython"
     const val SCRIPT_INTERNAL = "internal"
@@ -183,6 +187,7 @@ object BluePrintConstants {
 
     const val METADATA_TEMPLATE_NAME = "template_name"
     const val METADATA_TEMPLATE_VERSION = "template_version"
+    const val METADATA_TEMPLATE_TYPE = "template_type"
     const val METADATA_TEMPLATE_AUTHOR = "template_author"
     const val METADATA_TEMPLATE_TAGS = "template_tags"
     const val METADATA_WORKFLOW_NAME = "workflow_name"
index 71a31dc..67a0623 100644 (file)
@@ -646,7 +646,8 @@ class ToscaMetaData {
     lateinit var csarVersion: String
     lateinit var createdBy: String
     lateinit var entityDefinitions: String
-    var templateName: String? = null
-    var templateVersion: String? = null
-    var templateTags: String? = null
+    lateinit var templateName: String
+    lateinit var templateVersion: String
+    lateinit var templateTags: String
+    var templateType: String = BluePrintConstants.BLUEPRINT_TYPE_DEFAULT
 }
index c6339f4..0d9876b 100644 (file)
@@ -61,10 +61,10 @@ interface BluePrintAttributeDefinitionValidator : BluePrintValidator<AttributeDe
 interface BluePrintValidatorService {
 
     @Throws(BluePrintException::class)
-    fun validateBluePrints(basePath: String): Boolean
+    suspend fun validateBluePrints(basePath: String): Boolean
 
     @Throws(BluePrintException::class)
-    fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean
+    suspend fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean
 }
 
 interface BluePrintTypeValidatorService {
index 9e10473..60d26a7 100755 (executable)
@@ -232,7 +232,8 @@ class BluePrintFileUtils {
                     "\nCreated-By: <AUTHOR NAME>" +
                     "\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
                     "\nTemplate-Name: <BLUEPRINT_NAME>" +
-                    "\nTemplate-Tags: <BLUEPRINT_VERSION>" +
+                    "\nTemplate-Version: <BLUEPRINT_VERSION>" +
+                    "\nTemplate-Type: <BLUEPRINT_TYPE>" +
                     "\nTemplate-Tags: <TAGS>"
         }
 
index 4d7647f..64be589 100644 (file)
@@ -20,8 +20,10 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
 import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
@@ -91,6 +93,7 @@ class BluePrintMetadataUtils {
                             "Template-Name" -> toscaMetaData.templateName = value
                             "Template-Version" -> toscaMetaData.templateVersion = value
                             "Template-Tags" -> toscaMetaData.templateTags = value
+                            "Template-Type" -> toscaMetaData.templateType = value
                         }
                     }
                 }
@@ -98,37 +101,58 @@ class BluePrintMetadataUtils {
             return toscaMetaData
         }
 
-        fun getBluePrintRuntime(id: String, blueprintBasePath: String):
-                BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+        /** Get the default blueprint runtime for [id] and [blueprintBasePath] */
+        suspend fun getBluePrintRuntime(id: String, blueprintBasePath: String):
+            BluePrintRuntimeService<MutableMap<String, JsonNode>> {
             val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
             return getBluePrintRuntime(id, bluePrintContext)
         }
 
+        /** Get the default blocking blueprint runtime api for [id] and [blueprintBasePath] used in testing */
+        fun bluePrintRuntime(id: String, blueprintBasePath: String):
+            BluePrintRuntimeService<MutableMap<String, JsonNode>> = runBlocking {
+            val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
+            getBluePrintRuntime(id, bluePrintContext)
+        }
+
+        /** Get the default blueprint runtime from [bluePrintContext] */
         fun getBluePrintRuntime(id: String, bluePrintContext: BluePrintContext):
-                BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+            BluePrintRuntimeService<MutableMap<String, JsonNode>> {
             checkNotEmpty(bluePrintContext.rootPath) { "blueprint context root path is missing." }
             checkNotEmpty(bluePrintContext.entryDefinition) { "blueprint context entry definition is missing." }
             val blueprintBasePath = bluePrintContext.rootPath
             val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
-            bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive())
+            bluePrintRuntimeService.put(
+                BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH,
+                blueprintBasePath.asJsonPrimitive()
+            )
             bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive())
             return bluePrintRuntimeService
         }
 
+        /** Get the blueprint runtime for enhancement start for [id] and [blueprintBasePath] */
         suspend fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String):
-                BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+            BluePrintRuntimeService<MutableMap<String, JsonNode>> {
 
             val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath)
 
             val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
-            bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive())
+            bluePrintRuntimeService.put(
+                BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH,
+                blueprintBasePath.asJsonPrimitive()
+            )
             bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive())
 
             return bluePrintRuntimeService
         }
 
-        fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode>):
-                BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+        /** Get the default blueprint runtime for enhancement start for [id],  [blueprintBasePath] and [executionContext] */
+        suspend fun getBluePrintRuntime(
+            id: String,
+            blueprintBasePath: String,
+            executionContext: MutableMap<String, JsonNode>
+        ):
+            BluePrintRuntimeService<MutableMap<String, JsonNode>> {
             val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
             val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
             executionContext.forEach {
@@ -139,27 +163,55 @@ class BluePrintMetadataUtils {
             return bluePrintRuntimeService
         }
 
-        fun getBluePrintContext(blueprintBasePath: String): BluePrintContext = runBlocking {
+        /** Get the default blueprint context for [blueprintBasePath]*/
+        suspend fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
 
             val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
 
-            log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+            log.info(
+                "Reading blueprint type(${toscaMetaData.templateType}) path($blueprintBasePath) " +
+                    "and entry definition file (${toscaMetaData.entityDefinitions})"
+            )
 
             // If the EntryDefinition is Kotlin file, compile and get Service Template
-            if (toscaMetaData.entityDefinitions.endsWith("kt")) {
-                readBlueprintKotlinFile(toscaMetaData, blueprintBasePath)
-            } else {
-                readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+            val bluePrintContext = when (toscaMetaData.templateType.toUpperCase()) {
+                BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL -> readBlueprintKotlinFile(
+                    toscaMetaData,
+                    blueprintBasePath
+                )
+                BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT -> readBlueprintGenericScript(
+                    toscaMetaData,
+                    blueprintBasePath
+                )
+                BluePrintConstants.BLUEPRINT_TYPE_DEFAULT -> readBlueprintFile(
+                    toscaMetaData.entityDefinitions,
+                    blueprintBasePath
+                )
+                else ->
+                    throw BluePrintException(
+                        "Unknown blueprint type(${toscaMetaData.templateType}), " +
+                            "It should be any one of these types[${BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL}," +
+                            "${BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT}, " +
+                            "${BluePrintConstants.BLUEPRINT_TYPE_DEFAULT}]"
+                    )
             }
+            // Copy the metadata info
+            copyMetaInfoToServiceTemplate(toscaMetaData, bluePrintContext.serviceTemplate)
+
+            return bluePrintContext
         }
 
         private suspend fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext {
             val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+
             // Clean Type files
             BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath)
             val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions)
             val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
 
+            // Copy the metadata info
+            copyMetaInfoToServiceTemplate(toscaMetaData, rootServiceTemplate)
+
             // Clean the Import Definitions
             BluePrintFileUtils.cleanImportTypes(rootServiceTemplate)
 
@@ -169,10 +221,22 @@ class BluePrintMetadataUtils {
             return blueprintContext
         }
 
+        /** copy metadata defined in [toscaMetaData] to [serviceTemplate] */
+        private fun copyMetaInfoToServiceTemplate(toscaMetaData: ToscaMetaData, serviceTemplate: ServiceTemplate) {
+            if (serviceTemplate.metadata == null) serviceTemplate.metadata = mutableMapOf()
+            val metadata = serviceTemplate.metadata!!
+            metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] = toscaMetaData.createdBy
+            metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = toscaMetaData.templateName
+            metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] = toscaMetaData.templateVersion
+            metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS] = toscaMetaData.templateTags
+            metadata[BluePrintConstants.METADATA_TEMPLATE_TYPE] = toscaMetaData.templateType
+        }
+
         private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
             val normalizedBasePath = normalizedPathName(basePath)
             val rootFilePath = normalizedPathName(normalizedBasePath, entityDefinitions)
             val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
+
             // Recursively Import Template files
             val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, normalizedBasePath)
             val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()
@@ -185,17 +249,14 @@ class BluePrintMetadataUtils {
         /** Reade the Service Template Definitions from the Kotlin file */
         private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext {
 
-            checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" }
-            checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" }
-
             val definitionClassName = toscaMetaData.entityDefinitions.removeSuffix(".kt")
             val normalizedBasePath = normalizedPathName(basePath)
 
             val bluePrintScriptsService = BluePrintScriptsServiceImpl()
             val bluePrintDefinitions = bluePrintScriptsService
                 .scriptInstance<BluePrintDefinitions>(
-                    normalizedBasePath, toscaMetaData.templateName!!,
-                    toscaMetaData.templateVersion!!, definitionClassName, false
+                    normalizedBasePath, toscaMetaData.templateName,
+                    toscaMetaData.templateVersion, definitionClassName, false
                 )
             // Get the Service Template
             val serviceTemplate = bluePrintDefinitions.serviceTemplate()
@@ -209,5 +270,10 @@ class BluePrintMetadataUtils {
             blueprintContext.otherDefinitions = bluePrintDefinitions.otherDefinitions()
             return blueprintContext
         }
+
+        /** Reade the Service Template Definitions from the generic script types */
+        private fun readBlueprintGenericScript(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext {
+            return BluePrintContext(ServiceTemplate())
+        }
     }
 }
index 597194c..38f6ea2 100644 (file)
@@ -18,6 +18,7 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
 import com.fasterxml.jackson.databind.ObjectMapper
+import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
@@ -58,16 +59,20 @@ class BluePrintContextTest {
 
     @Test
     fun testBluePrintContextCreation() {
-        val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
-        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
+        runBlocking {
+            val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
+            assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
+        }
     }
 
     @Test
     fun testChainedProperty() {
-        val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
-        val nodeType = bluePrintContext.nodeTypeChained("component-resource-resolution")
-        assertNotNull(nodeType, "Failed to get chained node type")
-        log.trace("Properties {}", JacksonUtils.getJson(nodeType, true))
+        runBlocking {
+            val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
+            val nodeType = bluePrintContext.nodeTypeChained("component-resource-resolution")
+            assertNotNull(nodeType, "Failed to get chained node type")
+            log.trace("Properties {}", JacksonUtils.getJson(nodeType, true))
+        }
     }
 
     @Test
index dea4622..b079d42 100644 (file)
@@ -70,9 +70,9 @@ class BluePrintRuntimeServiceTest {
         )
 
         val assignmentParams = "{\n" +
-                "            \"ipAddress\": \"127.0.0.1\",\n" +
-                "            \"hostName\": \"vnf-host\"\n" +
-                "          }"
+            "            \"ipAddress\": \"127.0.0.1\",\n" +
+            "            \"hostName\": \"vnf-host\"\n" +
+            "          }"
 
         bluePrintRuntimeService.setNodeTemplateAttributeValue(
             "resource-assignment", "assignment-params",
@@ -84,8 +84,16 @@ class BluePrintRuntimeServiceTest {
             "netconf"
         )
         assertNotNull(capProperties, "Failed to populate capability property values")
-        assertEquals(capProperties["target-ip-address"], "127.0.0.1".asJsonPrimitive(), "Failed to populate parameter target-ip-address")
-        assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number")
+        assertEquals(
+            capProperties["target-ip-address"],
+            "127.0.0.1".asJsonPrimitive(),
+            "Failed to populate parameter target-ip-address"
+        )
+        assertEquals(
+            capProperties["port-number"],
+            JacksonUtils.jsonNodeFromObject(830),
+            "Failed to populate parameter port-number"
+        )
     }
 
     @Test
@@ -108,8 +116,16 @@ class BluePrintRuntimeServiceTest {
             )
 
         assertNotNull(inContext, "Failed to populate interface input property values")
-        assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
-        assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+        assertEquals(
+            inContext["action-name"],
+            JacksonUtils.jsonNodeFromObject("sample-action"),
+            "Failed to populate parameter action-name"
+        )
+        assertEquals(
+            inContext["request-id"],
+            JacksonUtils.jsonNodeFromObject("12345"),
+            "Failed to populate parameter action-name"
+        )
     }
 
     @Test
@@ -118,7 +134,11 @@ class BluePrintRuntimeServiceTest {
 
         val bluePrintRuntimeService = getBluePrintRuntimeService()
 
-        bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance())
+        bluePrintRuntimeService.setNodeTemplateAttributeValue(
+            "resource-assignment",
+            "assignment-params",
+            NullNode.getInstance()
+        )
 
         bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs(
             "resource-assignment",
@@ -135,7 +155,11 @@ class BluePrintRuntimeServiceTest {
             "resource-assignment",
             "ResourceResolutionComponent", "process", "resource-assignment-params"
         )
-        assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params")
+        assertEquals(
+            NullNode.getInstance(),
+            outputParams,
+            "Failed to get operation property resource-assignment-params"
+        )
     }
 
     @Test
@@ -154,7 +178,8 @@ class BluePrintRuntimeServiceTest {
 
         val keys = listOf("context1", "context2")
 
-        val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys)
+        val jsonValueNode =
+            bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys)
         assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties")
         log.info("JSON Prepared Value Context {}", jsonValueNode)
     }
@@ -189,7 +214,7 @@ class BluePrintRuntimeServiceTest {
 
     private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
         val blueprintBasePath = normalizedPathName(TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG)
-        val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+        val blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath)
         val checkProcessId = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID)
         val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
 
index e525bfc..0e93ccf 100644 (file)
@@ -34,7 +34,7 @@ class BluePrintTemplateServiceTest {
     @BeforeTest
     fun setup() {
         val blueprintBasePath = TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG
-        blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+        blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath)
     }
 
     @Test
index 302daf6..6ccfe1e 100644 (file)
@@ -48,20 +48,22 @@ class BluePrintMetadataUtilsTest {
 
     @Test
     fun testKotlinBluePrintContext() {
-        val path = normalizedPathName("src/test/resources/compile")
-        val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path)
-        assertNotNull(blueprintContext, "failed to get blueprint context")
-        assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
-        assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
-        assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions")
+        runBlocking {
+            val path = normalizedPathName("src/test/resources/compile")
+            val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path)
+            assertNotNull(blueprintContext, "failed to get blueprint context")
+            assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+            assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+            assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions")
 
-        var cachePresent = BluePrintCompileCache.hasClassLoader(path)
-        assertTrue(cachePresent, "failed to generate cache key ($path)")
+            var cachePresent = BluePrintCompileCache.hasClassLoader(path)
+            assertTrue(cachePresent, "failed to generate cache key ($path)")
 
-        /** Cleaning Cache */
-        BluePrintCompileCache.cleanClassLoader(path)
-        cachePresent = BluePrintCompileCache.hasClassLoader(path)
-        assertTrue(!cachePresent, "failed to remove cache key ($path)")
+            /** Cleaning Cache */
+            BluePrintCompileCache.cleanClassLoader(path)
+            cachePresent = BluePrintCompileCache.hasClassLoader(path)
+            assertTrue(!cachePresent, "failed to remove cache key ($path)")
+        }
     }
 
     @Test
index b1ffabd..d139c2d 100644 (file)
@@ -2,6 +2,7 @@ TOSCA-Meta-File-Version: 1.0.0
 CSAR-Version: 1.0
 Created-By: Brinda Santh <brindasanth@in.ibm.com>
 Entry-Definitions: cba.scripts.ActivateBlueprintDefinitions.kt
-Template-Tags: Brinda Santh, activation-blueprint
 Template-Name: activate-blueprint
 Template-Version: 1.0.0
+Template-Type: KOTLIN_DSL
+Template-Tags: Brinda Santh, activation-blueprint
index 5df2dec..67bdd03 100644 (file)
@@ -41,13 +41,13 @@ open class BluePrintDesignTimeValidatorService(
 
     private val log = LoggerFactory.getLogger(BluePrintDesignTimeValidatorService::class.toString())
 
-    override fun validateBluePrints(basePath: String): Boolean {
+    override suspend fun validateBluePrints(basePath: String): Boolean {
 
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
         return validateBluePrints(bluePrintRuntimeService)
     }
 
-    override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+    override suspend fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
 
         bluePrintTypeValidatorService.validateServiceTemplate(
             bluePrintRuntimeService, "service_template",
@@ -76,7 +76,7 @@ open class BluePrintDesignTimeValidatorService(
         if (resourceDefinitionFile.exists()) {
             val resourceDefinitionMap = JacksonUtils.getMapFromFile(resourceDefinitionFile, ResourceDefinition::class.java)
 
-            resourceDefinitionMap?.forEach { resourceDefinitionName, resourceDefinition ->
+            resourceDefinitionMap.forEach { resourceDefinitionName, resourceDefinition ->
                 resourceDefinitionValidator.validate(bluePrintRuntimeService, resourceDefinitionName, resourceDefinition)
             }
         }
index 19d1ef0..dcf3529 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
 
 import io.mockk.every
 import io.mockk.mockk
+import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
@@ -35,18 +36,21 @@ import kotlin.test.assertTrue
 class BluePrintDesignTimeValidatorServiceTest {
 
     private val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
-    private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+    private val bluePrintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath)
     private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
     private val resourceDefinitionValidator = mockk<ResourceDefinitionValidator>()
-    private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService, resourceDefinitionValidator)
+    private val defaultBluePrintValidatorService =
+        BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService, resourceDefinitionValidator)
     private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
 
     @Test
     fun testValidateOfType() {
-        every { resourceDefinitionValidator.validate(bluePrintRuntime, any(), any()) } returns Unit
+        runBlocking {
+            every { resourceDefinitionValidator.validate(bluePrintRuntime, any(), any()) } returns Unit
 
-        val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
-        assertTrue(valid, "failed in blueprint Validation")
+            val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+            assertTrue(valid, "failed in blueprint Validation")
+        }
     }
 
     @Test
@@ -95,14 +99,19 @@ class BluePrintDesignTimeValidatorServiceTest {
         assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
         assertEquals(
             "Failed to validate Workflow(resource-assignment)'s step(test)'s definition : " +
-                    "resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', " +
-                    "Expected 'tosca.nodes.Workflow' or 'tosca.nodes.Component'", bluePrintRuntime.getBluePrintError().errors[0]
+                "resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', " +
+                "Expected 'tosca.nodes.Workflow' or 'tosca.nodes.Component'",
+            bluePrintRuntime.getBluePrintError().errors[0]
         )
     }
 
     @Test
     fun testValidateWorkflowSuccess() {
         val workflowName = "resource-assignment"
-        workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName))
+        workflowValidator.validate(
+            bluePrintRuntime,
+            workflowName,
+            bluePrintRuntime.bluePrintContext().workflowByName(workflowName)
+        )
     }
 }
index e86dfab..5d546c2 100644 (file)
@@ -25,6 +25,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCata
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintCatalogServiceImpl
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.service.BlueprintProcessorCatalogServiceImpl
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
@@ -62,8 +63,14 @@ class BlueprintProcessorCatalogServiceImplTest {
 
     @BeforeTest
     fun setup() {
+
         deleteDir("target", "blueprints")
-        bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+
+        // Create sample CBA zip
+        normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+            .compress(normalizedFile("./target/blueprints/generated-cba.zip"))
+
+        bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime(
             blueprintId,
             "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
         )
@@ -76,11 +83,9 @@ class BlueprintProcessorCatalogServiceImplTest {
 
     @Test
     fun `test catalog service`() {
-        // TODO: I thing this test function should be remve and replace by the other one.
-        runBlocking {
-            // FIXME("Create ZIP from test blueprints")
 
-            val file = normalizedFile("./src/test/resources/test-cba.zip")
+        runBlocking {
+            val file = normalizedFile("./target/blueprints/generated-cba.zip")
             assertTrue(file.exists(), "couldn't get file ${file.absolutePath}")
 
             blueprintsProcessorCatalogService.saveToDatabase("1234", file)
@@ -93,7 +98,7 @@ class BlueprintProcessorCatalogServiceImplTest {
     @Test
     fun `test save function`() {
         runBlocking {
-            val file = normalizedFile("./src/test/resources/test-cba.zip")
+            val file = normalizedFile("./target/blueprints/generated-cba.zip")
             assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
             val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
             metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId
@@ -105,7 +110,7 @@ class BlueprintProcessorCatalogServiceImplTest {
     @Test
     fun `test get function`() {
         runBlocking {
-            val file = normalizedFile("./src/test/resources/test-cba.zip")
+            val file = normalizedFile("./target/blueprints/generated-cba.zip")
             assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
             val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
             metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId
@@ -117,10 +122,10 @@ class BlueprintProcessorCatalogServiceImplTest {
         assertTrue(
             File(
                 blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath +
-                        "/baseconfiguration"
+                    "/baseconfiguration"
             ).deleteRecursively(), "Couldn't get blueprint archive " +
-                    "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " +
-                    "from data base."
+                "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " +
+                "from data base."
         )
     }
 
index 8dcf426..248181f 100644 (file)
@@ -15,7 +15,7 @@
  */
 package org.onap.ccsdk.cds.blueprintsprocessor.db.mock
 
-import io.mockk.every
+import io.mockk.coEvery
 import io.mockk.mockk
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
@@ -28,8 +28,8 @@ open class MockBlueprintProcessorCatalogServiceImpl {
     @Bean(name = ["bluePrintRuntimeValidatorService"])
     open fun bluePrintRuntimeValidatorService(): BluePrintValidatorService {
         val bluePrintValidatorService = mockk<BluePrintValidatorService>()
-        every { bluePrintValidatorService.validateBluePrints(any<String>()) } returns true
-        every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
+        coEvery { bluePrintValidatorService.validateBluePrints(any<String>()) } returns true
+        coEvery { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
         return bluePrintValidatorService
     }
 }
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
deleted file mode 100644 (file)
index 785ec6c..0000000
Binary files a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip and /dev/null differ
index 582fd9a..35e4405 100644 (file)
@@ -30,6 +30,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.TokenAuthGrpcClientSe
 import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers
 import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintBootstrapInput
@@ -66,9 +67,15 @@ class BluePrintManagementGRPCHandlerTest {
 
     @BeforeTest
     fun init() {
+
+        deleteDir("target", "blueprints")
+
+        // Create sample CBA zip
+        normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+            .compress(normalizedFile("./target/blueprints/generated-cba.zip"))
+
         // Create a server, add service, start, and register for automatic graceful shutdown.
         grpcServerRule.serviceRegistry.addService(bluePrintManagementGRPCHandler)
-        deleteDir("target", "blueprints")
     }
 
     @AfterTest
@@ -84,7 +91,7 @@ class BluePrintManagementGRPCHandlerTest {
         val bootstrapOutput = blockingStub.bootstrapBlueprint(req)
         assertEquals(200, bootstrapOutput.status.code)
         assertTrue(
-            bootstrapOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+            bootstrapOutput.status.message!!.contentEquals(BluePrintConstants.STATUS_SUCCESS),
             "failed to get success status"
         )
         assertEquals(id, bootstrapOutput.commonHeader.requestId)
@@ -99,7 +106,7 @@ class BluePrintManagementGRPCHandlerTest {
 
         assertEquals(200, output.status.code)
         assertTrue(
-            output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+            output.status.message!!.contentEquals(BluePrintConstants.STATUS_SUCCESS),
             "failed to get success status"
         )
         assertEquals(id, output.commonHeader.requestId)
@@ -110,7 +117,7 @@ class BluePrintManagementGRPCHandlerTest {
         val downloadOutput = blockingStub.downloadBlueprint(downloadReq)
         assertEquals(200, downloadOutput.status.code)
         assertTrue(
-            downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+            downloadOutput.status.message!!.contentEquals(BluePrintConstants.STATUS_SUCCESS),
             "failed to get success status"
         )
         assertNotNull(downloadOutput.fileChunk?.chunk, "failed to get cba file chunks")
@@ -126,7 +133,7 @@ class BluePrintManagementGRPCHandlerTest {
         var output = blockingStub.uploadBlueprint(req)
         assertEquals(200, output.status.code)
         assertTrue(
-            output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS),
+            output.status.message!!.contentEquals(BluePrintConstants.STATUS_SUCCESS),
             "failed to get success status"
         )
         assertEquals(id, output.commonHeader.requestId)
@@ -174,7 +181,7 @@ class BluePrintManagementGRPCHandlerTest {
     }
 
     private fun createUploadInputRequest(id: String, action: String): BluePrintUploadInput {
-        val file = normalizedFile("./src/test/resources/test-cba.zip")
+        val file = normalizedFile("./target/blueprints/generated-cba.zip")
         assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
 
         val commonHeader = CommonHeader
index 2762725..a866dca 100644 (file)
@@ -65,34 +65,28 @@ class BluePrintEnhancerServiceImplTest {
             resourceDictionaryLoadService.loadPathsResourceDictionary(dictPaths)
 
             testBaseConfigEnhancementAndValidation()
-            testVFWEnhancementAndValidation()
             testGoldenEnhancementAndValidation()
             testRemoteScriptsEnhancementAndValidation()
             testCapabilityCliEnhancementAndValidation()
         }
     }
 
-    fun testBaseConfigEnhancementAndValidation() {
+    private fun testBaseConfigEnhancementAndValidation() {
         val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
         testComponentInvokeEnhancementAndValidation(basePath, "base-enhance")
     }
 
-    fun testVFWEnhancementAndValidation() {
-        val basePath = "./../../../../../components/model-catalog/blueprint-model/service-blueprint/vFW"
-        testComponentInvokeEnhancementAndValidation(basePath, "vFW-enhance")
-    }
-
-    fun testGoldenEnhancementAndValidation() {
+    private fun testGoldenEnhancementAndValidation() {
         val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/golden"
         testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance")
     }
 
-    fun testRemoteScriptsEnhancementAndValidation() {
+    private fun testRemoteScriptsEnhancementAndValidation() {
         val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
         testComponentInvokeEnhancementAndValidation(basePath, "remote_scripts-enhance")
     }
 
-    fun testCapabilityCliEnhancementAndValidation() {
+    private fun testCapabilityCliEnhancementAndValidation() {
         val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/capability_cli"
         testComponentInvokeEnhancementAndValidation(basePath, "capability_cli-enhance")
     }
@@ -111,8 +105,8 @@ class BluePrintEnhancerServiceImplTest {
             Assert.assertTrue("blueprint($basePath) validation failed ", valid)
 
             // Enable this to get the enhanced zip file
-            //            val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip")
-            //            normalizedFile(targetPath).compress(compressFile)
+            // val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip")
+            // normalizedFile(targetPath).compress(compressFile)
 
             deleteDir(targetPath)
         }
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip
deleted file mode 100644 (file)
index 785ec6c..0000000
Binary files a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/test-cba.zip and /dev/null differ
index a6ebe9c..3119b80 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.controllerblueprints.core.compress
 import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
@@ -62,6 +63,10 @@ class ExecutionServiceControllerTest {
     @BeforeTest
     fun init() {
         deleteDir("target", "blueprints")
+
+        // Create sample CBA zip
+        normalizedFile("./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+            .compress(normalizedFile("./target/blueprints/generated-cba.zip"))
     }
 
     @AfterTest
@@ -110,7 +115,7 @@ class ExecutionServiceControllerTest {
     }
 
     private fun loadTestCbaFile(): File {
-        val testCbaFile = normalizedFile("./src/test/resources/test-cba.zip")
+        val testCbaFile = normalizedFile("./target/blueprints/generated-cba.zip")
         assertTrue(testCbaFile.exists(), "couldn't get file ${testCbaFile.absolutePath}")
         return testCbaFile
     }
index 75d9f48..a367c8d 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.validation
 
+import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.mock.MockResourceSource
@@ -37,10 +38,12 @@ class BluePrintRuntimeValidatorServiceTest {
 
     @Test
     fun testBlueprintRuntimeValidation() {
-        val blueprintBasePath =
-            "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
-        assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService")
+        runBlocking {
+            val blueprintBasePath =
+                "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+            assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService")
 
-        bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath)
+            bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath)
+        }
     }
 }
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
deleted file mode 100644 (file)
index 785ec6c..0000000
Binary files a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip and /dev/null differ
index 6ca0bbc..4517a3f 100644 (file)
     <description>Blueprints Processor Execution Service</description>
 
     <dependencies>
-        <dependency>
-            <groupId>org.python</groupId>
-            <artifactId>jython-standalone</artifactId>
-        </dependency>
         <dependency>
            <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
            <artifactId>blueprint-core</artifactId>
index dd4c0ec..3b8c296 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
 
-import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.ArrayNode
-import org.apache.commons.io.FilenameUtils
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
-import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-import org.springframework.context.ApplicationContext
 import org.springframework.stereotype.Service
-import java.io.File
-
-@Service
-class BlueprintJythonService(
-    val pythonExecutorProperty: PythonExecutorProperty,
-    private val applicationContext: ApplicationContext
-) {
-
-    val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java)
-
-    inline fun <reified T> jythonInstance(
-        blueprintContext: BluePrintContext,
-        pythonClassName: String,
-        content: String,
-        dependencyInstanceNames: MutableMap<String, Any>?
-    ): T {
-
-        val blueprintBasePath: String = blueprintContext.rootPath
-        val pythonPath: MutableList<String> = arrayListOf()
-        pythonPath.add(blueprintBasePath)
-        pythonPath.addAll(pythonExecutorProperty.modulePaths)
-
-        val blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
-
-        val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations)
-        val pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames)
 
-        log.info("Component Object {}", pyObject)
+// TODO("After Jython depreciation, this interface will be removed")
 
-        return pyObject.__tojava__(T::class.java) as T
-    }
+@Deprecated("CDS won's support Jython services")
+interface BlueprintJythonService {
 
     fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
-            BlueprintFunctionNode<*, *> {
-
-        val pythonFileName = bluePrintContext.rootPath
-            .plus(File.separator)
-            .plus(scriptClassReference)
-
-        val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
-        log.info("Getting Jython Script Class($pythonClassName)")
-
-        val content: String = JacksonUtils.getContent(pythonFileName)
-
-        val jythonInstances: MutableMap<String, Any> = hashMapOf()
-        jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
-
-        return jythonInstance<BlueprintFunctionNode<*, *>>(
-            bluePrintContext, pythonClassName,
-            content, jythonInstances
-        )
-    }
-
-    fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
-
-        val bluePrintRuntimeService = abstractComponentFunction.bluePrintRuntimeService
-        val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
-        val nodeTemplateName: String = abstractComponentFunction.nodeTemplateName
-        val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs
-
-        val operationAssignment: OperationAssignment = bluePrintContext
-            .nodeTemplateInterfaceOperation(
-                abstractComponentFunction.nodeTemplateName,
-                abstractComponentFunction.interfaceName, abstractComponentFunction.operationName
-            )
-
-        val blueprintBasePath: String = bluePrintContext.rootPath
-
-        val artifactName: String = operationAssignment.implementation?.primary
-            ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
-
-        val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
-
-        val pythonFileName = artifactDefinition.file
-            ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
-
-        val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
-        log.info("Getting Jython Script Class($pythonClassName)")
-
-        val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
-
-        checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
-
-        val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
-        pythonPath.add(blueprintBasePath)
-        pythonPath.addAll(pythonExecutorProperty.modulePaths)
-
-        val jythonInstances: MutableMap<String, Any> = hashMapOf()
-        jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
-
-        val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
-            ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
-
-        instanceDependenciesNode.forEach { instanceName ->
-            jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
-        }
+        BlueprintFunctionNode<*, *>
+}
 
-        val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(
-            bluePrintContext, pythonClassName,
-            content!!, jythonInstances
-        )
+@Service
+open class DeprecatedBlueprintJythonService : BlueprintJythonService {
 
-        return scriptComponentFunction
+    override fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
+        BlueprintFunctionNode<*, *> {
+        throw BluePrintProcessorException("Include python-executor module for Jython support")
     }
 }
index e013fa8..3caa061 100644 (file)
@@ -57,8 +57,7 @@ import kotlin.test.assertNotNull
 @RunWith(SpringRunner::class)
 @ContextConfiguration(
     classes = [ComponentFunctionScriptingService::class,
-        BluePrintScriptsServiceImpl::class, PythonExecutorProperty::class,
-        BlueprintJythonService::class]
+        BluePrintScriptsServiceImpl::class, DeprecatedBlueprintJythonService::class]
 )
 class AbstractComponentFunctionTest {