summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt4
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py13
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml18
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt1
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt34
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt60
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt33
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json6
12 files changed, 143 insertions, 53 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt
index 8e52a9f4..f6103a4d 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt
@@ -44,9 +44,9 @@ class BlueprintJythonServiceTest {
val dependencies: MutableMap<String, Any> = hashMapOf()
- val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
+ val content = JacksonUtils.getContent("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py")
- val abstractComponentFunction = blueprintJythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SampleBlueprintComponent", content, dependencies)
+ val abstractComponentFunction = blueprintJythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SamplePythonComponentNode", content, dependencies)
assertNotNull(abstractComponentFunction, "failed to get python component")
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 f884456e..64281264 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
@@ -86,7 +86,7 @@ class CapabilityResourceAssignmentProcessorTest {
fun `test jython capability`() {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python")
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
@@ -100,8 +100,8 @@ class CapabilityResourceAssignmentProcessorTest {
capabilityResourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
val resourceAssignment = ResourceAssignment().apply {
- name = "country"
- dictionaryName = "country"
+ name = "service-instance-id"
+ dictionaryName = "service-instance-id"
dictionarySource = "capability"
property = PropertyDefinition().apply {
type = "string"
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
index 9d834433..d3780e0a 100644
--- 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
@@ -1,13 +1,14 @@
{
- "tags": "country",
- "name": "country",
- "updated-by": "brindasanth@onap.com",
+ "tags": "service-instance-id, tosca.datatypes.Root, data_type",
+ "name": "service-instance-id",
"property": {
- "description": "description",
+ "description": "To be provided",
"type": "string"
},
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
"sources": {
"capability": {
+ "type": "source-capability",
"properties": {
"type": "JYTHON-COMPONENT",
"instance-name": "SampleRAProcessor",
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
deleted file mode 100644
index bcf450e8..00000000
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/python/SampleResourceAssignmentProcessorScript.py
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml
index 44ec746c..56ea7bb5 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml
@@ -1,17 +1,17 @@
<!--
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
+ ~ 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
+ ~ 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.
+ ~ 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.
-->
<configuration>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index a2101251..0c8209f4 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -44,6 +44,7 @@ object BluePrintConstants {
const val DATA_TYPE_NULL: String = "null"
const val DATA_TYPE_LIST: String = "list"
const val DATA_TYPE_MAP: String = "map"
+ const val DATA_TYPE_JSON: String = "json"
const val USER_SYSTEM: String = "System"
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
index 4509cccf..0889fddc 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,6 +110,7 @@ object BluePrintTypes {
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
validTypes.add(BluePrintConstants.DATA_TYPE_MAP)
+ validTypes.add(BluePrintConstants.DATA_TYPE_JSON)
return validTypes
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
index 81b7acb5..cb75e2c2 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -27,6 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JsonParserUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils
/**
@@ -95,11 +96,11 @@ If Property Assignment is Expression.
}
/*
- get_property: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>,
+ get_attribute: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>,
<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ]
*/
fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode {
- val valueNode: JsonNode
+ var valueNode: JsonNode
val attributeName = attributeExpression.attributeName
val subAttributeName: String? = attributeExpression.subAttributeName
@@ -114,24 +115,20 @@ If Property Assignment is Expression.
if (!attributeExpression.modelableEntityName.equals("SELF", true)) {
attributeNodeTemplateName = attributeExpression.modelableEntityName
}
- /* Enable in ONAP Dublin Release
- val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName)
- ?: throw BluePrintException(format("failed to get attribute definitions for node template " +
- "({})'s property name ({}) ", nodeTemplateName, attributeName))
-
- var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!!
- log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)
- */
+ var attributeDefinition: AttributeDefinition = bluePrintContext
+ .nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)
+ ?: throw BluePrintException("failed to get attribute definitions for node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName)
- ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName))
+ ?: throw BluePrintException("failed to get node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
}
}
-// subPropertyName?.let {
-// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName))
-// }
+ if (subAttributeName != null) {
+ if (valueNode.isObject || valueNode.isArray)
+ valueNode = JsonParserUtils.parse(valueNode, subAttributeName)
+ }
return valueNode
}
@@ -140,7 +137,7 @@ If Property Assignment is Expression.
<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ]
*/
fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode {
- val valueNode: JsonNode
+ var valueNode: JsonNode
val propertyName = propertyExpression.propertyName
val subPropertyName: String? = propertyExpression.subPropertyName
@@ -160,9 +157,10 @@ If Property Assignment is Expression.
// Check it it is a nested expression
valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
-// subPropertyName?.let {
-// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName))
-// }
+ if (subPropertyName != null) {
+ if (valueNode.isObject || valueNode.isArray)
+ valueNode = JsonParserUtils.parse(valueNode, subPropertyName)
+ }
return valueNode
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt
new file mode 100644
index 00000000..4bdaaa56
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.utils
+
+
+import com.fasterxml.jackson.databind.JsonNode
+import com.jayway.jsonpath.Configuration
+import com.jayway.jsonpath.JsonPath
+import com.jayway.jsonpath.Option
+import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider
+import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider
+
+class JsonParserUtils {
+ companion object {
+
+ //TODO("Optimise this")
+ val JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder()
+ .mappingProvider(JacksonMappingProvider()).jsonProvider(JacksonJsonNodeJsonProvider()).build()
+
+ val PATH_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST).build()
+
+ fun paths(jsonContent: String, expression: String): List<String> {
+ return JsonPath.using(PATH_CONFIGURATION).parse(jsonContent).read(expression)
+ }
+
+ fun paths(jsonNode: JsonNode, expression: String): List<String> {
+ return paths(jsonNode.toString(), expression)
+ }
+
+ fun parse(jsonContent: String, expression: String): JsonNode {
+ return JsonPath.using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).read(expression)
+ }
+
+ fun parse(jsonNode: JsonNode, expression: String): JsonNode {
+ return parse(jsonNode.toString(), expression)
+ }
+
+ fun parseNSet(jsonContent: String, expression: String, value: JsonNode): JsonNode {
+ return JsonPath.using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).set(expression, value).json()
+ }
+
+ fun parseNSet(jsonNode: JsonNode, expression: String, valueNode: JsonNode): JsonNode {
+ return parseNSet(jsonNode.toString(), expression, valueNode)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index d0bd3cf3..92e9247a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -65,10 +65,18 @@ class BluePrintRuntimeServiceTest {
BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),
"data/default-context.json", executionContext)
+ val assignmentParams = "{\n" +
+ " \"ipAddress\": \"127.0.0.1\",\n" +
+ " \"hostName\": \"vnf-host\"\n" +
+ " }"
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params",
+ JacksonUtils.jsonNode(assignmentParams))
+
val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device",
"netconf")
assertNotNull(capProperties, "Failed to populate capability property values")
- assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address")
+ 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")
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt
new file mode 100644
index 00000000..1f003999
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.utils
+
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import kotlin.test.assertEquals
+
+class JsonParserUtilsTest {
+
+ @Test
+ fun `test parse Node`() {
+ val dataNode = JacksonUtils.jsonNodeFromClassPathFile("data/default-context.json")
+
+ val parsedNode = JsonParserUtils.parse(dataNode, "$.request-id")
+
+ assertEquals(parsedNode, "12345".asJsonPrimitive(), "failed to parse json request-id")
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json
index 3968626b..9f733f0f 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json
@@ -1,7 +1,7 @@
{
- "request-id" : "12345",
- "hostname" : "localhost",
+ "request-id": "12345",
+ "hostname": "localhost",
"template_name": "baseconfiguration",
"template_version": "1.0.0",
- "action-name" : "sample-action"
+ "action-name": "sample-action"
} \ No newline at end of file