From 40072d3dcc1d0193bba1ea9432c13ac24857be55 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 27 Mar 2019 13:22:51 -0400 Subject: Improve function interfaces Change-Id: I24f45d39ac05491a4217101e00bcbf8d122e4e1a Issue-ID: CCSDK-1137 Signed-off-by: Muthuramalingam, Brinda Santh --- .../resolution/ResourceResolutionComponentTest.kt | 31 ++++---- .../CapabilityResourceResolutionProcessorTest.kt | 89 ++++++++++++---------- 2 files changed, 64 insertions(+), 56 deletions(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt index 8a5ffac76..feec74058 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution import com.fasterxml.jackson.databind.JsonNode +import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties @@ -56,24 +57,26 @@ class ResourceResolutionComponentTest { @Test fun testProcess() { + runBlocking { - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json", - ExecutionServiceInput::class.java)!! + val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json", + ExecutionServiceInput::class.java)!! - // Prepare Inputs - PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment") + // Prepare Inputs + PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment") - val stepMetaData: MutableMap = hashMapOf() - stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment") - stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceResolutionComponent") - stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") - bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode()) + val stepMetaData: MutableMap = hashMapOf() + stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment") + stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceResolutionComponent") + stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode()) - resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService - resourceResolutionComponent.stepName = "resource-assignment" - resourceResolutionComponent.apply(executionServiceInput) + resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService + resourceResolutionComponent.stepName = "resource-assignment" + resourceResolutionComponent.applyNB(executionServiceInput) + } } } \ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt index 8ab47b910..489d971a5 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor +import kotlinx.coroutines.runBlocking import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith @@ -52,70 +53,74 @@ class CapabilityResourceResolutionProcessorTest { @Ignore @Test fun `test kotlin capability`() { + runBlocking { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( - "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) - capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService - capabilityResourceResolutionProcessor.resourceDictionaries = hashMapOf() + capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService + capabilityResourceResolutionProcessor.resourceDictionaries = hashMapOf() - val scriptPropertyInstances: MutableMap = mutableMapOf() - scriptPropertyInstances["mock-service1"] = MockCapabilityService() - scriptPropertyInstances["mock-service2"] = MockCapabilityService() + val scriptPropertyInstances: MutableMap = mutableMapOf() + scriptPropertyInstances["mock-service1"] = MockCapabilityService() + scriptPropertyInstances["mock-service2"] = MockCapabilityService() - val instanceDependencies: List = listOf() + val instanceDependencies: List = listOf() - val resourceAssignmentProcessor = capabilityResourceResolutionProcessor - .scriptInstance("kotlin", - "ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", instanceDependencies) + val resourceAssignmentProcessor = capabilityResourceResolutionProcessor + .scriptInstance("kotlin", + "ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", instanceDependencies) - assertNotNull(resourceAssignmentProcessor, "couldn't get kotlin script resource assignment processor") + assertNotNull(resourceAssignmentProcessor, "couldn't get kotlin script resource assignment processor") - val resourceAssignment = ResourceAssignment().apply { - name = "ra-name" - dictionaryName = "ra-dict-name" - dictionarySource = "capability" - property = PropertyDefinition().apply { - type = "string" + val resourceAssignment = ResourceAssignment().apply { + name = "ra-name" + dictionaryName = "ra-dict-name" + dictionarySource = "capability" + property = PropertyDefinition().apply { + type = "string" + } } - } - val processorName = resourceAssignmentProcessor.apply(resourceAssignment) - assertNotNull(processorName, "couldn't get kotlin script resource assignment processor name") - println(processorName) + val processorName = resourceAssignmentProcessor.applyNB(resourceAssignment) + assertNotNull(processorName, "couldn't get kotlin script resource assignment processor name") + println(processorName) + } } @Test fun `test jython capability`() { + runBlocking { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( - "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python") + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( + "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python") - val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) - capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService + capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService - val resourceDefinition = JacksonUtils - .readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json", - ResourceDefinition::class.java)!! - val resourceDefinitions: MutableMap = mutableMapOf() - resourceDefinitions[resourceDefinition.name] = resourceDefinition - capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions + val resourceDefinition = JacksonUtils + .readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json", + ResourceDefinition::class.java)!! + val resourceDefinitions: MutableMap = mutableMapOf() + resourceDefinitions[resourceDefinition.name] = resourceDefinition + capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions - val resourceAssignment = ResourceAssignment().apply { - name = "service-instance-id" - dictionaryName = "service-instance-id" - dictionarySource = "capability" - property = PropertyDefinition().apply { - type = "string" + val resourceAssignment = ResourceAssignment().apply { + name = "service-instance-id" + dictionaryName = "service-instance-id" + dictionarySource = "capability" + property = PropertyDefinition().apply { + type = "string" + } } - } - val processorName = capabilityResourceResolutionProcessor.apply(resourceAssignment) - assertNotNull(processorName, "couldn't get Jython script resource assignment processor name") + val processorName = capabilityResourceResolutionProcessor.processNB(resourceAssignment) + assertNotNull(processorName, "couldn't get Jython script resource assignment processor name") + } } -- cgit 1.2.3-korg