aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-05-20 17:58:39 +0000
committerGerrit Code Review <gerrit@onap.org>2020-05-20 17:58:39 +0000
commitd7fffebc00a236147e67ffa877016c5e6d1d911f (patch)
tree40d91ca6e939a796d4adf67bcc1147c934f23d4c /ms/blueprintsprocessor/functions/resource-resolution
parentb6b14696838ca0589b6b8dc9bae2cf3d2cd1d72c (diff)
parent79d6af1baefdafd0cef5d32aa87b509b76070ebc (diff)
Merge "Improve logging for ResourceAssingmentUtils"
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt18
2 files changed, 16 insertions, 7 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 497b26803..1be9649b9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.uti
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
@@ -181,6 +182,7 @@ class ResourceAssignmentUtils {
val result: String
try {
val mapper = ObjectMapper()
+ mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
val root: ObjectNode = mapper.createObjectNode()
var containsLogProtected = false
@@ -196,7 +198,8 @@ class ResourceAssignmentUtils {
root.set<JsonNode>(rName, value)
}
}
- result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
+ result = mapper.writerWithDefaultPrettyPrinter()
+ .writeValueAsString(mapper.treeToValue(root, Object::class.java))
if (!containsLogProtected) {
logger.info("Generated Resource Param Data ($result)")
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 7746b5c41..b4befc26d 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
@@ -131,17 +131,23 @@ class ResourceAssignmentUtilsTest {
@Test
fun `generateResourceDataForAssignments - positive test`() {
// given a valid resource assignment
- val validResourceAssignment = createResourceAssignmentForTest("valid_value")
+ val validResourceAssignment1 = createResourceAssignmentForTest("valid_value", "pnf-id")
+ val validResourceAssignment2 = createResourceAssignmentForTest("also_valid", "a1")
// and a list containing that resource assignment
- val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment)
+ val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment1, validResourceAssignment2)
// when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
// then the assignment should produce a valid result
- val expected = "{\n" + " \"pnf-id\" : \"valid_value\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
+ val expected = """
+ {
+ "a1" : "also_valid",
+ "pnf-id" : "valid_value"
+ }
+ """.trimIndent()
+ assertEquals(expected, outcome.trimIndent(), "unexpected outcome generated")
}
@Test
@@ -200,10 +206,10 @@ class ResourceAssignmentUtilsTest {
""".replace("\n|\\s".toRegex(), ""), result)
}
- private fun createResourceAssignmentForTest(resourceValue: String?): ResourceAssignment {
+ private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
val resourceAssignmentForTest = ResourceAssignment().apply {
- name = "pnf-id"
+ name = resourceName
dictionaryName = "pnf-id"
dictionarySource = "input"
property = PropertyDefinition().apply {