summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/test
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-05-28 13:57:06 -0400
committerKAPIL SINGAL <ks220y@att.com>2020-06-09 14:19:14 +0000
commit8a3d5215f2424bbea855ac1b86dfefb98f349496 (patch)
treed32c53b0936e73c7336e514964b3492b150d945d /ms/blueprintsprocessor/functions/resource-resolution/src/test
parent7999215bcb96bfca2111014c47c9e8766936b254 (diff)
Add ResourceResolutionResult to ResourceResolutionService
In order to ensure consistent behavior for assignment-map, supporting occurences and multiple artifact-prefixes, ResourceResolutionService needs to return assignment-map alongside generated template content. Issue-ID: CCSDK-2389 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: I54c1991d23d65217f3492b08a2170a6d41b6482d
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/ResourceResolutionComponentTest.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt29
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt15
3 files changed, 23 insertions, 23 deletions
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 83dd0ce34..ab1efcdc8 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
@@ -147,7 +147,7 @@ class ResourceResolutionComponentTest {
any<List<String>>(),
any<MutableMap<String, Any>>()
)
- } returns mutableMapOf()
+ } returns ResourceResolutionResult(mutableMapOf(), mutableMapOf())
runBlocking {
resourceResolutionComponent.processNB(executionRequest)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index d5c43184e..d6fc52230 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -33,6 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -135,12 +136,22 @@ class ResourceResolutionServiceTest {
"baseconfig",
props
)
+ }.let { (templateMap, assignmentMap) ->
+ assertEquals("This is Sample Velocity Template", templateMap)
+
+ val expectedAssignmentMap = hashMapOf(
+ "service-instance-id" to "siid_1234",
+ "vnf-id" to "vnf_1234",
+ "vnf_name" to "temp_vnf"
+ ).asJsonType()
+ assertEquals(expectedAssignmentMap, assignmentMap)
}
}
@Test
@Throws(Exception::class)
fun testResolveResources() {
+ val artifactNames = listOf("baseconfig", "another")
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
@@ -155,8 +166,6 @@ class ResourceResolutionServiceTest {
ExecutionServiceInput::class.java
)!!
- val artefactNames = listOf("baseconfig", "another")
-
// Prepare Inputs
PayloadUtils.prepareInputsFromWorkflowPayload(
bluePrintRuntimeService,
@@ -167,9 +176,15 @@ class ResourceResolutionServiceTest {
resourceResolutionService.resolveResources(
bluePrintRuntimeService,
"resource-assignment",
- artefactNames,
+ artifactNames,
props
)
+ }.let {
+ assertEquals(artifactNames.toSet(), it.templateMap.keys)
+ assertEquals(artifactNames.toSet(), it.assignmentMap.keys)
+
+ assertEquals("This is Sample Velocity Template", it.templateMap["another"])
+ assertEquals("vnf_1234", it.assignmentMap["another"]!!["vnf-id"]!!.asText())
}
}
@@ -256,7 +271,7 @@ class ResourceResolutionServiceTest {
props
)
}.let {
- val summaries = JacksonUtils.jsonNode(it)["resolution-summary"]
+ val summaries = JacksonUtils.jsonNode(it.first)["resolution-summary"]
val list = JacksonUtils.getListFromJsonNode(summaries, ResolutionSummary::class.java)
assertEquals(list.size, 3)
}
@@ -265,6 +280,7 @@ class ResourceResolutionServiceTest {
@Test
@Throws(Exception::class)
fun testResolveResourcesWithoutTemplate() {
+ val artifactPrefix = "notemplate"
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
@@ -285,8 +301,6 @@ class ResourceResolutionServiceTest {
"testResolveResourcesWithMappingAndTemplate"
)
- val artifactPrefix = "notemplate"
-
// Prepare Inputs
PayloadUtils.prepareInputsFromWorkflowPayload(
bluePrintRuntimeService,
@@ -307,7 +321,8 @@ class ResourceResolutionServiceTest {
"vnf-id" : "vnf_1234",
"vnf_name" : "temp_vnf"
}
- """.trimIndent(), it)
+ """.trimIndent(), it.first)
+ assertEquals("siid_1234", it.second["service-instance-id"].asText())
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
index 6734613fc..59be79568 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
@@ -22,7 +22,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
import io.mockk.every
import io.mockk.spyk
@@ -207,20 +206,6 @@ class ResourceAssignmentUtilsTest {
""".replace("\n|\\s".toRegex(), ""), result)
}
- @Test
- fun generateAssignmentMapTest() {
- val artifactPrefix = "vdns"
- val resourceAssignments = mutableListOf(
- createResourceAssignmentForTest("abc-123", "vnf-id"),
- createResourceAssignmentForTest(null, "vf-module-name")
- )
-
- val result: ObjectNode = ResourceAssignmentUtils.generateAssignmentMap(artifactPrefix, resourceAssignments)
-
- assertEquals("abc-123", result["vdns"]["vnf-id"].textValue())
- assertEquals(JacksonUtils.getJsonNode(null), result["vdns"]["vf-module-name"])
- }
-
private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
val resourceAssignmentForTest = ResourceAssignment().apply {