From b21540f1211a039aa6907f60d7621c8d331ec94f Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Mon, 10 Sep 2018 23:15:31 -0400 Subject: Controller Blueprints Microservice Add Attribute function implementation for Operation output properties. Change-Id: I8fd116ad7def07d208f9c3c1bfe7b75deae667d4 Issue-ID: CCSDK-524 Signed-off-by: Brinda Santh --- .../core/service/BluePrintRuntimeServiceTest.kt | 70 +++++++++++++++------- 1 file changed, 47 insertions(+), 23 deletions(-) (limited to 'components/core/src/test') 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 277ec3ac9..f1980d279 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 = 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 = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") - val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + val bluePrintRuntimeService = getBluePrintRuntimeService() - val componentContext: MutableMap = 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 = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + + return BluePrintRuntimeService(bluePrintContext, context) + } + } \ No newline at end of file -- cgit 1.2.3-korg