diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-11 17:41:48 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-11 17:41:48 -0500 |
commit | 3aea511293d7c5a61ad5895012b057bd589528b9 (patch) | |
tree | 63b5d8ce7a8d7597771b91bc2e723500df644b97 /components/core/src/test | |
parent | 9a85b3d441c11813d3dbe7ed487d475993c2e0a3 (diff) |
Controller Blueprints Component Core
Implement Blueprint context, run time service, metadata utils.
Change-Id: Ifc3aa1e1b04b326778e431e972e5d997275c013b
Issue-ID: CCSDK-670
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core/src/test')
4 files changed, 56 insertions, 71 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 f1980d27..68031d29 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 @@ -17,16 +17,16 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
-import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -37,13 +37,6 @@ import kotlin.test.assertNotNull */
class BluePrintRuntimeServiceTest {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- val basepath = "load/blueprints"
-
-
- @Before
- fun setUp(): Unit {
-
- }
@Test
fun testResolveNodeTemplateProperties() {
@@ -56,40 +49,32 @@ class BluePrintRuntimeServiceTest { val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)
bluePrintRuntimeService.assignInputs(inputNode)
- val propContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action")
- log.info("Context {}", bluePrintRuntimeService.context)
+ val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action")
assertNotNull(propContext, "Failed to populate interface property values")
- assertEquals(propContext.get("mode"), jsonNodeFromObject("sync"), "Failed to populate parameter process-name")
- assertEquals(propContext.get("version"), jsonNodeFromObject("1.0.0"), "Failed to populate parameter version")
+ assertEquals(propContext.get("mode"), "sync".asJsonPrimitive(), "Failed to populate parameter process-name")
+ assertEquals(propContext.get("version"), "1.0.0".asJsonPrimitive(), "Failed to populate parameter version")
}
@Test
fun testResolveNodeTemplateInterfaceOperationInputs() {
log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")
- 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 inputDataPath = "src/test/resources/data/default-context.json"
- BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context)
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
- val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)
+ val executionContext = bluePrintRuntimeService.getExecutionContext()
- log.info("Prepared Context {}", context)
+ BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),
+ "data/default-context.json", executionContext)
- val inContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component",
+ val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component",
"org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")
log.info("In Context {}", inContext)
assertNotNull(inContext, "Failed to populate interface input property values")
- assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
- assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ assertEquals(inContext.get("action-name"), "sample-action".asJsonPrimitive(), "Failed to populate parameter action-name")
+ assertEquals(inContext.get("request-id"), "12345".asJsonPrimitive(), "Failed to populate parameter action-name")
}
@Test
@@ -129,8 +114,6 @@ class BluePrintRuntimeServiceTest { 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)
@@ -139,15 +122,14 @@ class BluePrintRuntimeServiceTest { }
- 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")
+ private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val blueprintBasePath: String = ("load/blueprints/baseconfiguration")
+ val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
- val context: MutableMap<String, Any> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
+ assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation")
- return BluePrintRuntimeService(bluePrintContext, context)
+ return blueprintRuntime
}
}
\ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index d13caa52..c5f451ea 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -35,7 +35,7 @@ class JacksonReactorUtilsTest { assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
- val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block()
+ val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block()
assertNotNull(jsonContent, "Failed to get json content")
val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt index a5a630e3..c3718b27 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -44,7 +44,7 @@ class JacksonUtilsTest { assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
- val jsonContent = JacksonUtils.getJson(serviceTemplate!!, true)
+ val jsonContent = JacksonUtils.getJson(serviceTemplate, true)
assertNotNull(jsonContent, "Failed to get json content")
}
diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json index af79915f..966b0253 100644 --- a/components/core/src/test/resources/properties/convert.json +++ b/components/core/src/test/resources/properties/convert.json @@ -1,33 +1,36 @@ {
- "type": "sdnc-component-getResourceAssignment",
- "interfaces": {
- "ResourceAssignmentService": {
- "operations": {
- "getResourceAssignment": {
- "inputs": {
- "assignment-mappings": [
- {
- "name": "service-name",
- "mapping-field": "service",
- "mapping-category": "SDN",
- "required": true
- },
- {
- "name": "region-name",
- "mapping-field": "region",
- "mapping-category": "SDN",
- "required": true
- }
- ],
- "pre-data": { "get_input" : "get-resource-assignment.config-params" },
- "prifix": "get-resource-assignment"
- },
- "outputs": {
- "resource-assignment-status": "success",
- "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" }
- }
- }
- }
- }
- }
+ "type": "sdnc-component-getResourceAssignment",
+ "interfaces": {
+ "ResourceAssignmentService": {
+ "operations": {
+ "getResourceAssignment": {
+ "inputs": {
+ "assignment-mappings": [
+ {
+ "name": "service-name",
+ "mapping-field": "service",
+ "mapping-category": "SDN",
+ "required": true
+ },
+ {
+ "name": "region-name",
+ "mapping-field": "region",
+ "mapping-category": "SDN",
+ "required": true
+ }
+ ],
+ "pre-data": {
+ "get_input": "get-resource-assignment.config-params"
+ },
+ "prifix": "get-resource-assignment"
+ },
+ "outputs": {
+ "resource-assignment-status": "success",
+ "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params"
+ }
+ }
+ }
+ }
+ }
}
+
|