summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt43
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json18
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py13
4 files changed, 80 insertions, 2 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
index c9d1c77df..3dda79553 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
@@ -1,6 +1,8 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
*
+ * Modifications Copyright © 2019 IBM, Bell Canada.
+ *
* 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
@@ -18,19 +20,27 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintPythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
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.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
- MockCapabilityService::class])
+ BlueprintPythonService::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 CapabilityResourceAssignmentProcessorTest {
@Autowired
@@ -72,6 +82,37 @@ class CapabilityResourceAssignmentProcessorTest {
println(processorName)
}
+ @Test
+ fun `test jython capability`() {
+
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
+
+ capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+
+ val resourceDefinition = JacksonUtils
+ .readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json",
+ ResourceDefinition::class.java)!!
+ val resourceDefinitions: MutableMap<String, ResourceDefinition> = mutableMapOf()
+ resourceDefinitions[resourceDefinition.name] = resourceDefinition
+ capabilityResourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+
+ val resourceAssignment = ResourceAssignment().apply {
+ name = "country"
+ dictionaryName = "country"
+ dictionarySource = "capability"
+ property = PropertyDefinition().apply {
+ type = "string"
+ }
+ }
+
+ val processorName = capabilityResourceAssignmentProcessor.apply(resourceAssignment)
+ assertNotNull(processorName, "couldn't get Jython script resource assignment processor name")
+
+ }
+
}
open class MockCapabilityService {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
index aed61c466..e2785c8a3 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
@@ -2,6 +2,8 @@
#
# Copyright © 2017-2018 AT&T Intellectual Property.
#
+# Modifications Copyright © 2019 IBM, Bell Canada.
+#
# 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
@@ -29,4 +31,8 @@ blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
blueprintsprocessor.restclient.primary-config-data.type=basic-auth
blueprintsprocessor.restclient.primary-config-data.url=http://127.0.0.1:9111
blueprintsprocessor.restclient.primary-config-data.userId=sampleuser
-blueprintsprocessor.restclient.primary-config-data.token=sampletoken \ No newline at end of file
+blueprintsprocessor.restclient.primary-config-data.token=sampletoken
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
new file mode 100644
index 000000000..9d8344339
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
@@ -0,0 +1,18 @@
+{
+ "tags": "country",
+ "name": "country",
+ "updated-by": "brindasanth@onap.com",
+ "property": {
+ "description": "description",
+ "type": "string"
+ },
+ "sources": {
+ "capability": {
+ "properties": {
+ "type": "JYTHON-COMPONENT",
+ "instance-name": "SampleRAProcessor",
+ "instance-dependencies": []
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py
new file mode 100644
index 000000000..bcf450e81
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py
@@ -0,0 +1,13 @@
+from resource_assignment_processor_function import AbstractJythonComponentFunction
+from blueprint_constants import *
+
+
+class SampleJythonComponentNode(AbstractJythonComponentFunction):
+
+ def process(self, execution_request):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None