Fix sub-attribute parsing for accessing resolved values
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / resource-resolution / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / resource / resolution / utils / ResourceAssignmentUtilsTest.kt
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * Modifications Copyright (c) 2019 IBM, Bell Canada.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils
23
24 import com.fasterxml.jackson.databind.JsonNode
25 import com.fasterxml.jackson.databind.node.ObjectNode
26 import com.fasterxml.jackson.databind.node.TextNode
27 import io.mockk.every
28 import io.mockk.spyk
29 import kotlinx.coroutines.runBlocking
30 import org.junit.Before
31 import org.junit.Test
32 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
33 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE
34 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
35 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
36 import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
37 import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
38 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
39 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
40 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
41 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
42 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
43 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
44 import kotlin.test.assertEquals
45
46 data class IpAddress(val port: String, val ip: String)
47 data class Host(val name: String, val ipAddress: IpAddress)
48 data class ExpectedResponseIp(val ip: String)
49 data class ExpectedResponseIpAddress(val ipAddress: IpAddress)
50
51 class ResourceAssignmentUtilsTest {
52     private lateinit var resourceAssignmentRuntimeService: ResourceAssignmentRuntimeService
53     private lateinit var resourceAssignment: ResourceAssignment
54
55     private lateinit var inputMapToTestPrimitiveTypeWithValue: JsonNode
56     private lateinit var inputMapToTestPrimitiveTypeWithKeyValue: JsonNode
57     private lateinit var inputMapToTestCollectionOfPrimitiveType: JsonNode
58     private lateinit var inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping: JsonNode
59     private lateinit var inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping: JsonNode
60     private lateinit var inputMapToTestComplexTypeWithOneOutputKeyMapping: JsonNode
61     private lateinit var inputMapToTestComplexTypeWithAllOutputKeyMapping: JsonNode
62     private lateinit var expectedValueToTestPrimitiveType: JsonNode
63     private lateinit var expectedValueToTesCollectionOfPrimitiveType: JsonNode
64     private lateinit var expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping: JsonNode
65     private lateinit var expectedValueToTestComplexTypeWithOneOutputKeyMapping: JsonNode
66     private lateinit var expectedValueToTestComplexTypeWithAllOutputKeyMapping: JsonNode
67     private lateinit var expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping: JsonNode
68
69     @Before
70     fun setup() {
71
72         val bluePrintContext = runBlocking {
73             BluePrintMetadataUtils.getBluePrintContext(
74                 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
75             )
76         }
77
78         resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
79
80         // Init input map and expected values for tests
81         initInputMapAndExpectedValuesForPrimitiveType()
82         initInputMapAndExpectedValuesForCollection()
83         initInputMapAndExpectedValuesForComplexType()
84
85         val propertiesDefinition1 = PropertyDefinition().apply {
86             type = "string"
87             id = "port"
88         }
89
90         val propertiesDefinition2 = PropertyDefinition().apply {
91             type = "string"
92             id = "ip"
93         }
94
95         val propertiesDefinition3 = PropertyDefinition().apply {
96             type = "string"
97             id = "name"
98         }
99
100         val propertiesDefinition4 = PropertyDefinition().apply {
101             type = "ip-address"
102             id = "ipAddress"
103         }
104
105         val mapOfPropertiesIpAddress = mutableMapOf<String, PropertyDefinition>()
106         mapOfPropertiesIpAddress["port"] = propertiesDefinition1
107         mapOfPropertiesIpAddress["ip"] = propertiesDefinition2
108
109         val mapOfPropertiesHost = mutableMapOf<String, PropertyDefinition>()
110         mapOfPropertiesHost["name"] = propertiesDefinition3
111         mapOfPropertiesHost["ipAddress"] = propertiesDefinition4
112
113         val myDataTypeIpaddress = DataType().apply {
114             id = "ip-address"
115             properties = mapOfPropertiesIpAddress
116         }
117
118         val myDataTypeHost = DataType().apply {
119             id = "host"
120             properties = mapOfPropertiesHost
121         }
122
123         every {
124             resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("ip-address")
125         } returns myDataTypeIpaddress
126
127         every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("host") } returns myDataTypeHost
128
129         every { resourceAssignmentRuntimeService.setNodeTemplateAttributeValue(any(), any(), any()) } returns Unit
130     }
131
132     @Test
133     fun `generateResourceDataForAssignments - positive test`() {
134         // given a valid resource assignment
135         val validResourceAssignment1 = createResourceAssignmentForTest("valid_value", "pnf-id")
136         val validResourceAssignment2 = createResourceAssignmentForTest("also_valid", "a1")
137
138         // and a list containing that resource assignment
139         val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment1, validResourceAssignment2)
140
141         // when the values of the resources are evaluated
142         val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
143
144         // then the assignment should produce a valid result
145         val expected = """
146             {
147               "a1" : "also_valid",
148               "pnf-id" : "valid_value"
149             }
150         """.trimIndent()
151         assertEquals(expected, outcome.trimIndent(), "unexpected outcome generated")
152     }
153
154     @Test
155     fun `generateResourceDataForAssignments - resource without value is not resolved as null`() {
156         // given a valid resource assignment
157         val resourceAssignmentWithNullValue = createResourceAssignmentForTest(null)
158
159         // and a list containing that resource assignment
160         val resourceAssignmentList = listOf<ResourceAssignment>(resourceAssignmentWithNullValue)
161
162         // when the values of the resources are evaluated
163         val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
164
165         // then the assignment should produce a valid result
166         val expected = "{\n" + "  \"pnf-id\" : \"\${pnf-id}\"\n" + "}"
167         assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
168     }
169
170     @Test
171     fun generateResolutionSummaryDataTest() {
172         val resourceAssignment = createResourceAssignmentForTest(null)
173         val resourceDefinition = ResourceDefinition()
174         val nodeTemplate = NodeTemplate().apply {
175             properties = mutableMapOf("resolved-payload" to JacksonUtils.jsonNode("{\"mock\": true}"))
176         }
177         resourceDefinition.sources = mutableMapOf("input" to nodeTemplate)
178         resourceDefinition.property = PropertyDefinition().apply {
179             this.description = "pnf-id"
180             this.metadata = mutableMapOf("aai-path" to "//path/in/aai")
181         }
182
183         val result = ResourceAssignmentUtils.generateResolutionSummaryData(
184                 listOf(resourceAssignment), mapOf("pnf-id" to resourceDefinition))
185
186         assertEquals("""
187             {
188                 "resolution-summary":[
189                     {
190                         "name":"pnf-id",
191                         "value":"",
192                         "required":false,
193                         "type":"string",
194                         "key-identifiers":[],
195                         "dictionary-description":"pnf-id",
196                         "dictionary-metadata":[
197                             {"name":"aai-path","value":"//path/in/aai"}
198                         ],
199                         "dictionary-name":"pnf-id",
200                         "dictionary-source":"input",
201                         "request-payload":{"mock":true},
202                         "status":"",
203                         "message":""
204                     }
205                 ]
206             }
207         """.replace("\n|\\s".toRegex(), ""), result)
208     }
209
210     @Test
211     fun generateAssignmentMapTest() {
212         val artifactPrefix = "vdns"
213         val resourceAssignments = mutableListOf(
214             createResourceAssignmentForTest("abc-123", "vnf-id"),
215             createResourceAssignmentForTest(null, "vf-module-name")
216         )
217
218         val result: ObjectNode = ResourceAssignmentUtils.generateAssignmentMap(artifactPrefix, resourceAssignments)
219
220         assertEquals("abc-123", result["vdns"]["vnf-id"].textValue())
221         assertEquals(JacksonUtils.getJsonNode(null), result["vdns"]["vf-module-name"])
222     }
223
224     private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
225         val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
226         val resourceAssignmentForTest = ResourceAssignment().apply {
227             name = resourceName
228             dictionaryName = "pnf-id"
229             dictionarySource = "input"
230             property = PropertyDefinition().apply {
231                 type = "string"
232                 value = valueForTest
233             }
234         }
235         return resourceAssignmentForTest
236     }
237
238     @Test
239     fun parseResponseNodeTestForPrimitivesTypes() {
240         var outcome = prepareResponseNodeForTest(
241             "sample-value", "string", "",
242             inputMapToTestPrimitiveTypeWithValue
243         )
244         assertEquals(
245             expectedValueToTestPrimitiveType,
246             outcome,
247             "Unexpected outcome returned for primitive type of simple String"
248         )
249         assertEquals(0, resourceAssignment.keyIdentifiers.size)
250
251         outcome = prepareResponseNodeForTest(
252             "sample-key-value", "string", "",
253             inputMapToTestPrimitiveTypeWithKeyValue
254         )
255         assertEquals(
256             expectedValueToTestPrimitiveType,
257             outcome,
258             "Unexpected outcome returned for primitive type of key-value String"
259         )
260         assertEquals(
261                 expectedValueToTestPrimitiveType,
262                 resourceAssignment.keyIdentifiers[0].value
263         )
264     }
265
266     @Test
267     fun parseResponseNodeTestForCollectionsOfString() {
268         var outcome = prepareResponseNodeForTest(
269             "listOfString", "list",
270             "string", inputMapToTestCollectionOfPrimitiveType
271         )
272         assertEquals(
273             expectedValueToTesCollectionOfPrimitiveType,
274             outcome,
275             "unexpected outcome returned for list of String"
276         )
277
278         val expectedKeyIdentifierValue = JacksonUtils.getJsonNode(outcome.map { it["ip"] })
279         assertEquals(
280                 expectedKeyIdentifierValue,
281                 resourceAssignment.keyIdentifiers[0].value
282         )
283
284         // FIXME("Map is not collection type, It is known complex type")
285         // outcome = prepareResponseNodeForTest(
286         //     "mapOfString", "map", "string",
287         //     inputMapToTestCollectionOfPrimitiveType
288         // )
289         // assertEquals(
290         //     expectedValueToTesCollectionOfPrimitiveType,
291         //     outcome,
292         //     "unexpected outcome returned for map of String"
293         // )
294     }
295
296     @Test
297     fun parseResponseNodeTestForCollectionsOfComplexType() {
298         var outcome = prepareResponseNodeForTest(
299             "listOfMyDataTypeWithOneOutputKeyMapping", "list",
300             "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
301         )
302         assertEquals(
303             expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping,
304             outcome,
305             "unexpected outcome returned for list of String"
306         )
307
308         outcome = prepareResponseNodeForTest(
309             "listOfMyDataTypeWithAllOutputKeyMapping", "list",
310             "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
311         )
312         assertEquals(
313             expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping,
314             outcome,
315             "unexpected outcome returned for list of String"
316         )
317     }
318
319     @Test
320     fun `parseResponseNodeTestForComplexType find one output key mapping`() {
321         val outcome = prepareResponseNodeForTest(
322             "complexTypeOneKeys", "host",
323             "", inputMapToTestComplexTypeWithOneOutputKeyMapping
324         )
325         assertEquals(
326             expectedValueToTestComplexTypeWithOneOutputKeyMapping,
327             outcome,
328             "Unexpected outcome returned for complex type"
329         )
330         assertEquals(
331                 expectedValueToTestComplexTypeWithOneOutputKeyMapping["host"],
332                 resourceAssignment.keyIdentifiers[0].value)
333     }
334
335     @Test
336     fun `parseResponseNodeTestForComplexType find all output key mapping`() {
337         val outcome = prepareResponseNodeForTest(
338             "complexTypeAllKeys", "host",
339             "", inputMapToTestComplexTypeWithAllOutputKeyMapping
340         )
341         assertEquals(
342             expectedValueToTestComplexTypeWithAllOutputKeyMapping,
343             outcome,
344             "Unexpected outcome returned for complex type"
345         )
346         assertEquals(2, resourceAssignment.keyIdentifiers.size)
347         assertEquals(
348                 expectedValueToTestComplexTypeWithAllOutputKeyMapping["name"],
349                 resourceAssignment.keyIdentifiers[0].value
350         )
351
352         assertEquals(
353                 expectedValueToTestComplexTypeWithAllOutputKeyMapping["ipAddress"],
354                 resourceAssignment.keyIdentifiers[1].value
355         )
356     }
357
358     @Test
359     fun `transform resolved value with inline template`() {
360         resourceAssignmentRuntimeService.putResolutionStore("vnf_name", "abc-vnf".asJsonType())
361         resourceAssignment = ResourceAssignment()
362         resourceAssignment.name = "int_pktgen_private_net_id"
363         resourceAssignment.property = PropertyDefinition()
364         resourceAssignment.property!!.type = "string"
365         val value = "".asJsonType()
366
367         // Enable transform template
368         resourceAssignment.property!!.metadata =
369                 mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_name}_private2")
370
371         ResourceAssignmentUtils
372                 .setResourceDataValue(resourceAssignment, resourceAssignmentRuntimeService, value)
373
374         assertEquals("abc-vnf_private2",
375                 resourceAssignment.property!!.value!!.asText())
376     }
377
378     private fun initInputMapAndExpectedValuesForPrimitiveType() {
379         inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
380         val keyValue = mutableMapOf<String, String>()
381         keyValue["value"] = "1.2.3.1"
382         inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
383         expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
384     }
385
386     private fun initInputMapAndExpectedValuesForCollection() {
387         val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
388         val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
389         listOfIps.forEach {
390             val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
391             arrayChildNode.set<JsonNode>("value", it.asJsonPrimitive())
392             arrayNodeForList1.add(arrayChildNode)
393         }
394         inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1
395
396         expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
397             ExpectedResponseIp("1.2.3.1"),
398             ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
399         ).asJsonType()
400
401         val listOfIpAddresses = arrayListOf(
402             IpAddress("1111", "1.2.3.1").asJsonType(),
403             IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
404         )
405         val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
406         listOfIpAddresses.forEach {
407             val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
408             arrayChildNode.set<JsonNode>("value", it.asJsonType())
409             arrayNodeForList2.add(arrayChildNode)
410         }
411         inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayNodeForList2
412
413         val arrayNodeForList3 = JacksonUtils.objectMapper.createArrayNode()
414         var childNode = JacksonUtils.objectMapper.createObjectNode()
415         childNode.set<JsonNode>("port", "1111".asJsonPrimitive())
416         childNode.set<JsonNode>("ip", "1.2.3.1".asJsonPrimitive())
417         arrayNodeForList3.add(childNode)
418         childNode = JacksonUtils.objectMapper.createObjectNode()
419         childNode.set<JsonNode>("port", "2222".asJsonPrimitive())
420         childNode.set<JsonNode>("ip", "1.2.3.2".asJsonPrimitive())
421         arrayNodeForList3.add(childNode)
422         childNode = JacksonUtils.objectMapper.createObjectNode()
423         childNode.set<JsonNode>("port", "3333".asJsonPrimitive())
424         childNode.set<JsonNode>("ip", "1.2.3.3".asJsonPrimitive())
425         arrayNodeForList3.add(childNode)
426         inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3
427
428         expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
429             ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
430             ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
431                 IpAddress("3333", "1.2.3.3")
432             )
433         ).asJsonType()
434         expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
435             IpAddress("1111", "1.2.3.1"),
436             IpAddress("2222", "1.2.3.2"),
437             IpAddress("3333", "1.2.3.3")
438         ).asJsonType()
439     }
440
441     private fun initInputMapAndExpectedValuesForComplexType() {
442         val mapOfComplexType = mutableMapOf<String, JsonNode>()
443         mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
444         mapOfComplexType["port"] = "8888".asJsonType()
445         mapOfComplexType["something"] = "1.2.3.2".asJsonType()
446         inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()
447
448         val objectNode = JacksonUtils.objectMapper.createObjectNode()
449         expectedValueToTestComplexTypeWithOneOutputKeyMapping =
450             objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
451
452         val childNode1 = JacksonUtils.objectMapper.createObjectNode()
453         childNode1.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
454         childNode1.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
455         childNode1.set<JsonNode>("port", "8888".asJsonType())
456         childNode1.set<JsonNode>("something", IpAddress("2222", "1.2.3.1").asJsonType())
457         inputMapToTestComplexTypeWithAllOutputKeyMapping = childNode1
458
459         val childNode2 = JacksonUtils.objectMapper.createObjectNode()
460         childNode2.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
461         childNode2.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
462         expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
463     }
464
465     private fun prepareResponseNodeForTest(
466         dictionary_source: String,
467         sourceType: String,
468         entrySchema: String,
469         response: Any
470     ): JsonNode {
471
472         resourceAssignment = when (sourceType) {
473             "list" -> {
474                 prepareRADataDictionaryCollection(dictionary_source, sourceType, entrySchema)
475             }
476             "string" -> {
477                 prepareRADataDictionaryOfPrimaryType(dictionary_source)
478             }
479             else -> {
480                 prepareRADataDictionaryComplexType(dictionary_source, sourceType, entrySchema)
481             }
482         }
483
484         val responseNode = checkNotNull(JacksonUtils.getJsonNode(response)) {
485             "Failed to get database query result into Json node."
486         }
487
488         val outputKeyMapping = prepareOutputKeyMapping(dictionary_source)
489
490         return ResourceAssignmentUtils.parseResponseNode(
491             responseNode,
492             resourceAssignment,
493             resourceAssignmentRuntimeService,
494             outputKeyMapping
495         )
496     }
497
498     private fun prepareRADataDictionaryOfPrimaryType(dictionary_source: String): ResourceAssignment {
499         return ResourceAssignment().apply {
500             name = "ipAddress"
501             dictionaryName = "sample-ip"
502             dictionarySource = "$dictionary_source"
503             property = PropertyDefinition().apply {
504                 type = "string"
505             }
506         }
507     }
508
509     private fun prepareRADataDictionaryCollection(
510         dictionary_source: String,
511         sourceType: String,
512         schema: String
513     ): ResourceAssignment {
514         return ResourceAssignment().apply {
515             name = "ipAddress-list"
516             dictionaryName = "sample-licenses"
517             dictionarySource = "$dictionary_source"
518             property = PropertyDefinition().apply {
519                 type = "$sourceType"
520                 entrySchema = EntrySchema().apply {
521                     type = "$schema"
522                 }
523             }
524         }
525     }
526
527     private fun prepareRADataDictionaryComplexType(
528         dictionary_source: String,
529         sourceType: String,
530         schema: String
531     ): ResourceAssignment {
532         return ResourceAssignment().apply {
533             name = "ipAddress-complexType"
534             dictionaryName = "sample-licenses"
535             dictionarySource = "$dictionary_source"
536             property = PropertyDefinition().apply {
537                 type = "$sourceType"
538             }
539         }
540     }
541
542     private fun prepareOutputKeyMapping(dictionary_source: String): MutableMap<String, String> {
543         val outputMapping = mutableMapOf<String, String>()
544
545         when (dictionary_source) {
546             "sample-key-value", "sample-value" -> {
547                 // Primary Type
548                 if (dictionary_source == "sample-key-value")
549                     outputMapping["sample-ip"] = "value"
550             }
551             "listOfString", "mapOfString" -> {
552                 // List of string
553                 outputMapping["ip"] = "value"
554             }
555             "listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
556                 // List or map of complex Type
557                 if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
558                     outputMapping["ipAddress"] = "value"
559                 else {
560                     outputMapping["port"] = "port"
561                     outputMapping["ip"] = "ip"
562                 }
563             }
564             else -> {
565                 // Complex Type
566                 if (dictionary_source == "complexTypeOneKeys")
567                     outputMapping["host"] = "value"
568                 else {
569                     outputMapping["name"] = "name"
570                     outputMapping["ipAddress"] = "ipAddress"
571                 }
572             }
573         }
574         return outputMapping
575     }
576 }