Adding some minor features
[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.TextNode
26 import io.mockk.every
27 import io.mockk.spyk
28 import kotlinx.coroutines.runBlocking
29 import org.junit.Before
30 import org.junit.Test
31 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
32 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE
33 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
34 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
35 import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
36 import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
37 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
38 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
39 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
40 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
41 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
42 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
43 import kotlin.test.assertEquals
44
45 data class IpAddress(val port: String, val ip: String)
46 data class Host(val name: String, val ipAddress: IpAddress)
47 data class ExpectedResponseIp(val ip: String)
48 data class ExpectedResponseIpAddress(val ipAddress: IpAddress)
49
50 class ResourceAssignmentUtilsTest {
51
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
187         assertEquals(
188             """
189             {
190                 "resolution-summary":[
191                     {
192                         "name":"pnf-id",
193                         "value":"",
194                         "required":false,
195                         "type":"string",
196                         "key-identifiers":[],
197                         "dictionary-description":"pnf-id",
198                         "dictionary-metadata":[
199                             {"name":"aai-path","value":"//path/in/aai"}
200                         ],
201                         "dictionary-name":"pnf-id",
202                         "dictionary-source":"input",
203                         "request-payload":{"mock":true},
204                         "status":"",
205                         "message":""
206                     }
207                 ]
208             }
209         """.replace("\n|\\s".toRegex(), ""),
210             result
211         )
212     }
213
214     private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
215         val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
216         val resourceAssignmentForTest = ResourceAssignment().apply {
217             name = resourceName
218             dictionaryName = "pnf-id"
219             dictionarySource = "input"
220             property = PropertyDefinition().apply {
221                 type = "string"
222                 value = valueForTest
223             }
224         }
225         return resourceAssignmentForTest
226     }
227
228     @Test
229     fun parseResponseNodeTestForPrimitivesTypes() {
230         var outcome = prepareResponseNodeForTest(
231             "sample-value", "string", "",
232             inputMapToTestPrimitiveTypeWithValue
233         )
234         assertEquals(
235             expectedValueToTestPrimitiveType,
236             outcome,
237             "Unexpected outcome returned for primitive type of simple String"
238         )
239         assertEquals(0, resourceAssignment.keyIdentifiers.size)
240
241         outcome = prepareResponseNodeForTest(
242             "sample-key-value", "string", "",
243             inputMapToTestPrimitiveTypeWithKeyValue
244         )
245         assertEquals(
246             expectedValueToTestPrimitiveType,
247             outcome,
248             "Unexpected outcome returned for primitive type of key-value String"
249         )
250         assertEquals(
251             expectedValueToTestPrimitiveType,
252             resourceAssignment.keyIdentifiers[0].value
253         )
254     }
255
256     @Test
257     fun parseResponseNodeTestForCollectionsOfString() {
258         var outcome = prepareResponseNodeForTest(
259             "listOfString", "list",
260             "string", inputMapToTestCollectionOfPrimitiveType
261         )
262         assertEquals(
263             expectedValueToTesCollectionOfPrimitiveType,
264             outcome,
265             "unexpected outcome returned for list of String"
266         )
267
268         val expectedKeyIdentifierValue = JacksonUtils.getJsonNode(outcome.map { it["ip"] })
269         assertEquals(
270             expectedKeyIdentifierValue,
271             resourceAssignment.keyIdentifiers[0].value
272         )
273
274         // FIXME("Map is not collection type, It is known complex type")
275         // outcome = prepareResponseNodeForTest(
276         //     "mapOfString", "map", "string",
277         //     inputMapToTestCollectionOfPrimitiveType
278         // )
279         // assertEquals(
280         //     expectedValueToTesCollectionOfPrimitiveType,
281         //     outcome,
282         //     "unexpected outcome returned for map of String"
283         // )
284     }
285
286     @Test
287     fun parseResponseNodeTestForCollectionsOfComplexType() {
288         var outcome = prepareResponseNodeForTest(
289             "listOfMyDataTypeWithOneOutputKeyMapping", "list",
290             "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
291         )
292         assertEquals(
293             expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping,
294             outcome,
295             "unexpected outcome returned for list of String"
296         )
297
298         outcome = prepareResponseNodeForTest(
299             "listOfMyDataTypeWithAllOutputKeyMapping", "list",
300             "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
301         )
302         assertEquals(
303             expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping,
304             outcome,
305             "unexpected outcome returned for list of String"
306         )
307     }
308
309     @Test
310     fun `parseResponseNodeTestForComplexType find one output key mapping`() {
311         val outcome = prepareResponseNodeForTest(
312             "complexTypeOneKeys", "host",
313             "", inputMapToTestComplexTypeWithOneOutputKeyMapping
314         )
315         assertEquals(
316             expectedValueToTestComplexTypeWithOneOutputKeyMapping,
317             outcome,
318             "Unexpected outcome returned for complex type"
319         )
320         assertEquals(
321             expectedValueToTestComplexTypeWithOneOutputKeyMapping["host"],
322             resourceAssignment.keyIdentifiers[0].value
323         )
324     }
325
326     @Test
327     fun `parseResponseNodeTestForComplexType find all output key mapping`() {
328         val outcome = prepareResponseNodeForTest(
329             "complexTypeAllKeys", "host",
330             "", inputMapToTestComplexTypeWithAllOutputKeyMapping
331         )
332         assertEquals(
333             expectedValueToTestComplexTypeWithAllOutputKeyMapping,
334             outcome,
335             "Unexpected outcome returned for complex type"
336         )
337         assertEquals(2, resourceAssignment.keyIdentifiers.size)
338         assertEquals(
339             expectedValueToTestComplexTypeWithAllOutputKeyMapping["name"],
340             resourceAssignment.keyIdentifiers[0].value
341         )
342
343         assertEquals(
344             expectedValueToTestComplexTypeWithAllOutputKeyMapping["ipAddress"],
345             resourceAssignment.keyIdentifiers[1].value
346         )
347     }
348
349     @Test
350     fun `transform resolved value with inline template`() {
351         resourceAssignmentRuntimeService.putResolutionStore("vnf_name", "abc-vnf".asJsonType())
352         resourceAssignment = ResourceAssignment()
353         resourceAssignment.name = "int_pktgen_private_net_id"
354         resourceAssignment.property = PropertyDefinition()
355         resourceAssignment.property!!.type = "string"
356         val value = "".asJsonType()
357
358         // Enable transform template
359         resourceAssignment.property!!.metadata =
360             mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_name}_private2")
361
362         ResourceAssignmentUtils
363             .setResourceDataValue(resourceAssignment, resourceAssignmentRuntimeService, value)
364
365         val valueJson = "{\"config\":{\"parameter\":\"address\",\"value\":\"0.0.0.0\"}}"
366         resourceAssignmentRuntimeService.putResolutionStore("vnf_config", JacksonUtils.objectMapper.readTree(valueJson))
367         val resourceAssignmentJson = ResourceAssignment()
368         resourceAssignmentJson.name = "vendor_vnf_configuration"
369         resourceAssignmentJson.property = PropertyDefinition()
370         resourceAssignmentJson.property!!.type = "json"
371
372         // Enable transform template
373         resourceAssignmentJson.property!!.metadata =
374             mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_config}")
375
376         ResourceAssignmentUtils
377             .setResourceDataValue(resourceAssignmentJson, resourceAssignmentRuntimeService, JacksonUtils.objectMapper.createObjectNode())
378
379         assertEquals(
380             "abc-vnf_private2",
381             resourceAssignment.property!!.value!!.asText()
382         )
383
384         assertEquals(
385             valueJson,
386             resourceAssignmentJson.property!!.value!!.toString()
387         )
388     }
389
390     private fun initInputMapAndExpectedValuesForPrimitiveType() {
391         inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
392         val keyValue = mutableMapOf<String, String>()
393         keyValue["value"] = "1.2.3.1"
394         inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
395         expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
396     }
397
398     private fun initInputMapAndExpectedValuesForCollection() {
399         val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
400         val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
401         listOfIps.forEach {
402             val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
403             arrayChildNode.set<JsonNode>("value", it.asJsonPrimitive())
404             arrayNodeForList1.add(arrayChildNode)
405         }
406         inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1
407
408         expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
409             ExpectedResponseIp("1.2.3.1"),
410             ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
411         ).asJsonType()
412
413         val listOfIpAddresses = arrayListOf(
414             IpAddress("1111", "1.2.3.1").asJsonType(),
415             IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
416         )
417         val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
418         listOfIpAddresses.forEach {
419             val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
420             arrayChildNode.set<JsonNode>("value", it.asJsonType())
421             arrayNodeForList2.add(arrayChildNode)
422         }
423         inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayNodeForList2
424
425         val arrayNodeForList3 = JacksonUtils.objectMapper.createArrayNode()
426         var childNode = JacksonUtils.objectMapper.createObjectNode()
427         childNode.set<JsonNode>("port", "1111".asJsonPrimitive())
428         childNode.set<JsonNode>("ip", "1.2.3.1".asJsonPrimitive())
429         arrayNodeForList3.add(childNode)
430         childNode = JacksonUtils.objectMapper.createObjectNode()
431         childNode.set<JsonNode>("port", "2222".asJsonPrimitive())
432         childNode.set<JsonNode>("ip", "1.2.3.2".asJsonPrimitive())
433         arrayNodeForList3.add(childNode)
434         childNode = JacksonUtils.objectMapper.createObjectNode()
435         childNode.set<JsonNode>("port", "3333".asJsonPrimitive())
436         childNode.set<JsonNode>("ip", "1.2.3.3".asJsonPrimitive())
437         arrayNodeForList3.add(childNode)
438         inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3
439
440         expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
441             ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
442             ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")),
443             ExpectedResponseIpAddress(
444                 IpAddress("3333", "1.2.3.3")
445             )
446         ).asJsonType()
447         expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
448             IpAddress("1111", "1.2.3.1"),
449             IpAddress("2222", "1.2.3.2"),
450             IpAddress("3333", "1.2.3.3")
451         ).asJsonType()
452     }
453
454     private fun initInputMapAndExpectedValuesForComplexType() {
455         val mapOfComplexType = mutableMapOf<String, JsonNode>()
456         mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
457         mapOfComplexType["port"] = "8888".asJsonType()
458         mapOfComplexType["something"] = "1.2.3.2".asJsonType()
459         inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()
460
461         val objectNode = JacksonUtils.objectMapper.createObjectNode()
462         expectedValueToTestComplexTypeWithOneOutputKeyMapping =
463             objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
464
465         val childNode1 = JacksonUtils.objectMapper.createObjectNode()
466         childNode1.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
467         childNode1.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
468         childNode1.set<JsonNode>("port", "8888".asJsonType())
469         childNode1.set<JsonNode>("something", IpAddress("2222", "1.2.3.1").asJsonType())
470         inputMapToTestComplexTypeWithAllOutputKeyMapping = childNode1
471
472         val childNode2 = JacksonUtils.objectMapper.createObjectNode()
473         childNode2.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
474         childNode2.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
475         expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
476     }
477
478     private fun prepareResponseNodeForTest(
479         dictionary_source: String,
480         sourceType: String,
481         entrySchema: String,
482         response: Any
483     ): JsonNode {
484
485         resourceAssignment = when (sourceType) {
486             "list" -> {
487                 prepareRAResourceDictionaryCollection(dictionary_source, sourceType, entrySchema)
488             }
489             "string" -> {
490                 prepareRAResourceDictionaryOfPrimaryType(dictionary_source)
491             }
492             else -> {
493                 prepareRAResourceDictionaryComplexType(dictionary_source, sourceType, entrySchema)
494             }
495         }
496
497         val responseNode = checkNotNull(JacksonUtils.getJsonNode(response)) {
498             "Failed to get database query result into Json node."
499         }
500
501         val outputKeyMapping = prepareOutputKeyMapping(dictionary_source)
502
503         return ResourceAssignmentUtils.parseResponseNode(
504             responseNode,
505             resourceAssignment,
506             resourceAssignmentRuntimeService,
507             outputKeyMapping
508         )
509     }
510
511     private fun prepareRAResourceDictionaryOfPrimaryType(dictionary_source: String): ResourceAssignment {
512         return ResourceAssignment().apply {
513             name = "ipAddress"
514             dictionaryName = "sample-ip"
515             dictionarySource = "$dictionary_source"
516             property = PropertyDefinition().apply {
517                 type = "string"
518             }
519         }
520     }
521
522     private fun prepareRAResourceDictionaryCollection(
523         dictionary_source: String,
524         sourceType: String,
525         schema: String
526     ): ResourceAssignment {
527         return ResourceAssignment().apply {
528             name = "ipAddress-list"
529             dictionaryName = "sample-licenses"
530             dictionarySource = "$dictionary_source"
531             property = PropertyDefinition().apply {
532                 type = "$sourceType"
533                 entrySchema = EntrySchema().apply {
534                     type = "$schema"
535                 }
536             }
537         }
538     }
539
540     private fun prepareRAResourceDictionaryComplexType(
541         dictionary_source: String,
542         sourceType: String,
543         schema: String
544     ): ResourceAssignment {
545         return ResourceAssignment().apply {
546             name = "ipAddress-complexType"
547             dictionaryName = "sample-licenses"
548             dictionarySource = "$dictionary_source"
549             property = PropertyDefinition().apply {
550                 type = "$sourceType"
551             }
552         }
553     }
554
555     private fun prepareOutputKeyMapping(dictionary_source: String): MutableMap<String, String> {
556         val outputMapping = mutableMapOf<String, String>()
557
558         when (dictionary_source) {
559             "sample-key-value", "sample-value" -> {
560                 // Primary Type
561                 if (dictionary_source == "sample-key-value")
562                     outputMapping["sample-ip"] = "value"
563             }
564             "listOfString", "mapOfString" -> {
565                 // List of string
566                 outputMapping["ip"] = "value"
567             }
568             "listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
569                 // List or map of complex Type
570                 if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
571                     outputMapping["ipAddress"] = "value"
572                 else {
573                     outputMapping["port"] = "port"
574                     outputMapping["ip"] = "ip"
575                 }
576             }
577             else -> {
578                 // Complex Type
579                 if (dictionary_source == "complexTypeOneKeys")
580                     outputMapping["host"] = "value"
581                 else {
582                     outputMapping["name"] = "name"
583                     outputMapping["ipAddress"] = "ipAddress"
584                 }
585             }
586         }
587         return outputMapping
588     }
589 }