aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt21
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt44
2 files changed, 39 insertions, 26 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
index e80663094..203b7ea30 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
@@ -17,7 +17,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.moc
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
-import com.fasterxml.jackson.databind.node.MissingNode
import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.RestResourceSource
@@ -55,8 +54,7 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
override suspend fun processNB(executionRequest: ResourceAssignment) {
try {
// Check if It has Input
- val value = getFromInput(executionRequest)
- if (value == null || value is MissingNode) {
+ if (!setFromInput(executionRequest)) {
val dName = executionRequest.dictionaryName
val dSource = executionRequest.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
@@ -66,7 +64,7 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
val resourceSourceProperties = resourceSource!!.properties
val sourceProperties =
- JacksonUtils.getInstanceFromMap(resourceSourceProperties!!, RestResourceSource::class.java)
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties!!, RestResourceSource::class.java)
val path = nullToEmpty(sourceProperties.path)
val inputKeyMapping = sourceProperties.inputKeyMapping
@@ -76,7 +74,7 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
// Resolving content Variables
val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping)
val urlPath =
- resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
+ resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
@@ -98,8 +96,7 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
}
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message)
- throw BluePrintProcessorException("Failed in template resolutionKey ($executionRequest) assignments with: ${e.message}",
- e)
+ throw BluePrintProcessorException("Failed in template resolutionKey ($executionRequest) assignments with: ${e.message}", e)
}
}
@@ -139,10 +136,12 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
outputKeyMapping!!.map {
val responseKeyValue = responseSingleJsonNode.get(it.key)
val propertyTypeForDataType = ResourceAssignmentUtils
- .getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ .getPropertyType(raRuntimeService, entrySchemaType, it.key)
- JacksonUtils.populateJsonNodeValues(it.value,
- responseKeyValue, propertyTypeForDataType, arrayChildNode)
+ JacksonUtils.populateJsonNodeValues(
+ it.value,
+ responseKeyValue, propertyTypeForDataType, arrayChildNode
+ )
}
arrayNode.add(arrayChildNode)
}
@@ -157,7 +156,7 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
outputKeyMapping!!.map {
val responseKeyValue = responseNode.get(it.key)
val propertyTypeForDataType = ResourceAssignmentUtils
- .getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ .getPropertyType(raRuntimeService, entrySchemaType, it.key)
JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, objectNode)
}
// Set the List of Complex Values
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 f020f2952..98f68ebaa 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 com.fasterxml.jackson.databind.node.NullNode
import io.mockk.coEvery
import io.mockk.every
import io.mockk.mockk
@@ -48,12 +49,16 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, ComponentFunctionScriptingService::class,
- BluePrintScriptsServiceImpl::class,
- BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+@ContextConfiguration(
+ classes = [CapabilityResourceResolutionProcessor::class, ComponentFunctionScriptingService::class,
+ BluePrintScriptsServiceImpl::class,
+ BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class]
+)
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"]
+)
class CapabilityResourceResolutionProcessorTest {
@Autowired
@@ -65,17 +70,21 @@ class CapabilityResourceResolutionProcessorTest {
val componentFunctionScriptingService = mockk<ComponentFunctionScriptingService>()
coEvery {
componentFunctionScriptingService
- .scriptInstance<ResourceAssignmentProcessor>(any(), any(), any())
+ .scriptInstance<ResourceAssignmentProcessor>(any(), any(), any())
} returns MockCapabilityScriptRA()
val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
+ every { raRuntimeService.getInputValue("test-property") } returns NullNode.getInstance()
- val capabilityResourceResolutionProcessor = CapabilityResourceResolutionProcessor(componentFunctionScriptingService)
+ val capabilityResourceResolutionProcessor =
+ CapabilityResourceResolutionProcessor(componentFunctionScriptingService)
capabilityResourceResolutionProcessor.raRuntimeService = raRuntimeService
- val resourceAssignment = BluePrintTypes.resourceAssignment(name = "test-property", dictionaryName = "ra-dict-name",
- dictionarySource = "capability") {
+ val resourceAssignment = BluePrintTypes.resourceAssignment(
+ name = "test-property", dictionaryName = "ra-dict-name",
+ dictionarySource = "capability"
+ ) {
property("string", true, "")
sourceCapability {
definedProperties {
@@ -87,8 +96,10 @@ class CapabilityResourceResolutionProcessorTest {
}
val status = capabilityResourceResolutionProcessor.applyNB(resourceAssignment)
assertTrue(status, "failed to execute capability source")
- assertEquals("assigned-data".asJsonPrimitive(), resourceAssignment.property!!.value,
- "assigned value miss match")
+ assertEquals(
+ "assigned-data".asJsonPrimitive(), resourceAssignment.property!!.value,
+ "assigned value miss match"
+ )
}
}
@@ -97,15 +108,18 @@ class CapabilityResourceResolutionProcessorTest {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
val resourceDefinition = JacksonUtils
- .readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json",
- ResourceDefinition::class.java)!!
+ .readValueFromClassPathFile(
+ "mapping/capability/jython-resource-definitions.json",
+ ResourceDefinition::class.java
+ )!!
val resourceDefinitions: MutableMap<String, ResourceDefinition> = mutableMapOf()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions