summaryrefslogtreecommitdiffstats
path: root/components/core/src/test
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2018-09-10 23:15:31 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2018-09-10 23:15:31 -0400
commit68778581d3d82dc6adfcf55c2163bc13da76d7b6 (patch)
tree7dde49ca6df4ad2fc6e10046b048ba54a5d03500 /components/core/src/test
parent812bd02e844b4a518e5f02506b8fd7cb3a306636 (diff)
Controller Blueprints Microservice
Add Attribute function implementation for Operation output properties. Change-Id: I8fd116ad7def07d208f9c3c1bfe7b75deae667d4 Issue-ID: CCSDK-524 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'components/core/src/test')
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt70
1 files changed, 47 insertions, 23 deletions
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 277ec3ac..f1980d27 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.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.
@@ -17,7 +18,6 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.NullNode
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
@@ -48,12 +48,8 @@ class BluePrintRuntimeServiceTest {
@Test
fun testResolveNodeTemplateProperties() {
log.info("************************ testResolveNodeTemplateProperties **********************")
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- val context: MutableMap<String, Any> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
- val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
val inputDataPath = "src/test/resources/data/default-context.json"
@@ -99,31 +95,59 @@ class BluePrintRuntimeServiceTest {
@Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************")
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
-
- val context: MutableMap<String, Any> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
- val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
- val componentContext: MutableMap<String, Any?> = hashMapOf()
val successValue: JsonNode = jsonNodeFromObject("Success")
- componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue
- componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null
+ val paramValue: JsonNode = jsonNodeFromObject("param-content")
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "params", paramValue)
bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", componentContext)
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")
- assertEquals(NullNode.instance,
- context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"),
- "Failed to get operation property resource-assignment-params")
+ val resourceAssignmentParamsNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "resource-assignment-params")
- assertEquals(successValue,
- context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"),
- "Failed to get operation property status")
+ val statusNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "status")
+
+ assertEquals(paramValue, resourceAssignmentParamsNode, "Failed to get operation property resource-assignment-params")
+
+ assertEquals(successValue, statusNode, "Failed to get operation property status")
}
+
+ @Test
+ fun testNodeTemplateContextProperty() {
+ log.info("************************ testNodeTemplateContextProperty **********************")
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
+ jsonNodeFromObject("context1-value"))
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
+ jsonNodeFromObject("context2-value"))
+
+ log.info("Context {}", bluePrintRuntimeService.context)
+
+ val keys = listOf("context1", "context2")
+
+ 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)
+
+ }
+
+ private fun getBluePrintRuntimeService(): BluePrintRuntimeService {
+ val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
+ .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
+ assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
+
+ val context: MutableMap<String, Any> = hashMapOf()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
+
+ return BluePrintRuntimeService(bluePrintContext, context)
+ }
+
} \ No newline at end of file