aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
blob: d9e93150c09ed66b73d12d5e43f37bcb5438bcc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/*-
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019 Nordix Foundation.
 * Modifications Copyright (c) 2019 IBM, Bell Canada.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 * ============LICENSE_END=========================================================
 */

package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.TextNode
import io.mockk.every
import io.mockk.spyk
import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import kotlin.test.assertEquals

data class IpAddress(val port: String, val ip: String)
data class Host(val name: String, val ipAddress: IpAddress)
data class ExpectedResponseIp(val ip: String)
data class ExpectedResponseIpAddress(val ipAddress: IpAddress)

class ResourceAssignmentUtilsTest {

    private lateinit var resourceAssignmentRuntimeService: ResourceAssignmentRuntimeService
    private lateinit var resourceAssignment: ResourceAssignment

    private lateinit var inputMapToTestPrimitiveTypeWithValue: JsonNode
    private lateinit var inputMapToTestPrimitiveTypeWithKeyValue: JsonNode
    private lateinit var inputMapToTestCollectionOfPrimitiveType: JsonNode
    private lateinit var inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping: JsonNode
    private lateinit var inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping: JsonNode
    private lateinit var inputMapToTestComplexTypeWithOneOutputKeyMapping: JsonNode
    private lateinit var inputMapToTestComplexTypeWithAllOutputKeyMapping: JsonNode
    private lateinit var expectedValueToTestPrimitiveType: JsonNode
    private lateinit var expectedValueToTesCollectionOfPrimitiveType: JsonNode
    private lateinit var expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping: JsonNode
    private lateinit var expectedValueToTestComplexTypeWithOneOutputKeyMapping: JsonNode
    private lateinit var expectedValueToTestComplexTypeWithAllOutputKeyMapping: JsonNode
    private lateinit var expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping: JsonNode

    @Before
    fun setup() {

        val bluePrintContext = runBlocking {
            BlueprintMetadataUtils.getBlueprintContext(
                "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
            )
        }

        resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))

        // Init input map and expected values for tests
        initInputMapAndExpectedValuesForPrimitiveType()
        initInputMapAndExpectedValuesForCollection()
        initInputMapAndExpectedValuesForComplexType()

        val propertiesDefinition1 = PropertyDefinition().apply {
            type = "string"
            id = "port"
        }

        val propertiesDefinition2 = PropertyDefinition().apply {
            type = "string"
            id = "ip"
        }

        val propertiesDefinition3 = PropertyDefinition().apply {
            type = "string"
            id = "name"
        }

        val propertiesDefinition4 = PropertyDefinition().apply {
            type = "ip-address"
            id = "ipAddress"
        }

        val mapOfPropertiesIpAddress = mutableMapOf<String, PropertyDefinition>()
        mapOfPropertiesIpAddress["port"] = propertiesDefinition1
        mapOfPropertiesIpAddress["ip"] = propertiesDefinition2

        val mapOfPropertiesHost = mutableMapOf<String, PropertyDefinition>()
        mapOfPropertiesHost["name"] = propertiesDefinition3
        mapOfPropertiesHost["ipAddress"] = propertiesDefinition4

        val myDataTypeIpaddress = DataType().apply {
            id = "ip-address"
            properties = mapOfPropertiesIpAddress
        }

        val myDataTypeHost = DataType().apply {
            id = "host"
            properties = mapOfPropertiesHost
        }

        every {
            resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("ip-address")
        } returns myDataTypeIpaddress

        every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("host") } returns myDataTypeHost

        every { resourceAssignmentRuntimeService.setNodeTemplateAttributeValue(any(), any(), any()) } returns Unit
    }

    @Test
    fun `generateResourceDataForAssignments - positive test`() {
        // given a valid resource assignment
        val validResourceAssignment1 = createResourceAssignmentForTest("valid_value", "pnf-id")
        val validResourceAssignment2 = createResourceAssignmentForTest("also_valid", "a1")

        // and a list containing that resource assignment
        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 = """
            {
              "a1" : "also_valid",
              "pnf-id" : "valid_value"
            }
        """.trimIndent()
        assertEquals(expected, outcome.trimIndent(), "unexpected outcome generated")
    }

    @Test
    fun `generateResourceDataForAssignments - resource without value is not resolved as null`() {
        // given a valid resource assignment
        val resourceAssignmentWithNullValue = createResourceAssignmentForTest(null)

        // and a list containing that resource assignment
        val resourceAssignmentList = listOf<ResourceAssignment>(resourceAssignmentWithNullValue)

        // 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\" : \"\${pnf-id}\"\n" + "}"
        assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
    }

    @Test
    fun generateResolutionSummaryDataTest() {
        val resourceAssignment = createResourceAssignmentForTest(null)
        val resourceDefinition = ResourceDefinition()
        val nodeTemplate = NodeTemplate().apply {
            properties = mutableMapOf("resolved-payload" to JacksonUtils.jsonNode("{\"mock\": true}"))
        }
        resourceDefinition.sources = mutableMapOf("input" to nodeTemplate)
        resourceDefinition.property = PropertyDefinition().apply {
            this.description = "pnf-id"
            this.metadata = mutableMapOf("aai-path" to "//path/in/aai")
        }

        val result = ResourceAssignmentUtils.generateResolutionSummaryData(
            listOf(resourceAssignment), mapOf("pnf-id" to resourceDefinition)
        )

        assertEquals(
            """
            {
                "resolution-summary":[
                    {
                        "name":"pnf-id",
                        "value":"",
                        "required":false,
                        "type":"string",
                        "key-identifiers":[],
                        "dictionary-description":"pnf-id",
                        "dictionary-metadata":[
                            {"name":"aai-path","value":"//path/in/aai"}
                        ],
                        "dictionary-name":"pnf-id",
                        "dictionary-source":"input",
                        "request-payload":{"mock":true},
                        "status":"",
                        "message":""
                    }
                ]
            }
        """.replace("\n|\\s".toRegex(), ""),
            result
        )
    }

    private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment {
        val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
        val resourceAssignmentForTest = ResourceAssignment().apply {
            name = resourceName
            dictionaryName = "pnf-id"
            dictionarySource = "input"
            property = PropertyDefinition().apply {
                type = "string"
                value = valueForTest
            }
        }
        return resourceAssignmentForTest
    }

    @Test
    fun parseResponseNodeTestForPrimitivesTypes() {
        var outcome = prepareResponseNodeForTest(
            "sample-value", "string", "",
            inputMapToTestPrimitiveTypeWithValue
        )
        assertEquals(
            expectedValueToTestPrimitiveType,
            outcome,
            "Unexpected outcome returned for primitive type of simple String"
        )
        assertEquals(0, resourceAssignment.keyIdentifiers.size)

        outcome = prepareResponseNodeForTest(
            "sample-key-value", "string", "",
            inputMapToTestPrimitiveTypeWithKeyValue
        )
        assertEquals(
            expectedValueToTestPrimitiveType,
            outcome,
            "Unexpected outcome returned for primitive type of key-value String"
        )
        assertEquals(
            expectedValueToTestPrimitiveType,
            resourceAssignment.keyIdentifiers[0].value
        )
    }

    @Test
    fun parseResponseNodeTestForCollectionsOfString() {
        var outcome = prepareResponseNodeForTest(
            "listOfString", "list",
            "string", inputMapToTestCollectionOfPrimitiveType
        )
        assertEquals(
            expectedValueToTesCollectionOfPrimitiveType,
            outcome,
            "unexpected outcome returned for list of String"
        )

        val expectedKeyIdentifierValue = JacksonUtils.getJsonNode(outcome.map { it["ip"] })
        assertEquals(
            expectedKeyIdentifierValue,
            resourceAssignment.keyIdentifiers[0].value
        )

        // FIXME("Map is not collection type, It is known complex type")
        // outcome = prepareResponseNodeForTest(
        //     "mapOfString", "map", "string",
        //     inputMapToTestCollectionOfPrimitiveType
        // )
        // assertEquals(
        //     expectedValueToTesCollectionOfPrimitiveType,
        //     outcome,
        //     "unexpected outcome returned for map of String"
        // )
    }

    @Test
    fun parseResponseNodeTestForCollectionsOfComplexType() {
        var outcome = prepareResponseNodeForTest(
            "listOfMyDataTypeWithOneOutputKeyMapping", "list",
            "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
        )
        assertEquals(
            expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping,
            outcome,
            "unexpected outcome returned for list of String"
        )

        outcome = prepareResponseNodeForTest(
            "listOfMyDataTypeWithAllOutputKeyMapping", "list",
            "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
        )
        assertEquals(
            expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping,
            outcome,
            "unexpected outcome returned for list of String"
        )
    }

    @Test
    fun `parseResponseNodeTestForComplexType find one output key mapping`() {
        val outcome = prepareResponseNodeForTest(
            "complexTypeOneKeys", "host",
            "", inputMapToTestComplexTypeWithOneOutputKeyMapping
        )
        assertEquals(
            expectedValueToTestComplexTypeWithOneOutputKeyMapping,
            outcome,
            "Unexpected outcome returned for complex type"
        )
        assertEquals(
            expectedValueToTestComplexTypeWithOneOutputKeyMapping["host"],
            resourceAssignment.keyIdentifiers[0].value
        )
    }

    @Test
    fun `parseResponseNodeTestForComplexType find all output key mapping`() {
        val outcome = prepareResponseNodeForTest(
            "complexTypeAllKeys", "host",
            "", inputMapToTestComplexTypeWithAllOutputKeyMapping
        )
        assertEquals(
            expectedValueToTestComplexTypeWithAllOutputKeyMapping,
            outcome,
            "Unexpected outcome returned for complex type"
        )
        assertEquals(2, resourceAssignment.keyIdentifiers.size)
        assertEquals(
            expectedValueToTestComplexTypeWithAllOutputKeyMapping["name"],
            resourceAssignment.keyIdentifiers[0].value
        )

        assertEquals(
            expectedValueToTestComplexTypeWithAllOutputKeyMapping["ipAddress"],
            resourceAssignment.keyIdentifiers[1].value
        )
    }

    @Test
    fun `transform resolved value with inline template`() {
        resourceAssignmentRuntimeService.putResolutionStore("vnf_name", "abc-vnf".asJsonType())
        resourceAssignment = ResourceAssignment()
        resourceAssignment.name = "int_pktgen_private_net_id"
        resourceAssignment.property = PropertyDefinition()
        resourceAssignment.property!!.type = "string"
        val value = "".asJsonType()

        // Enable transform template
        resourceAssignment.property!!.metadata =
            mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_name}_private2")

        ResourceAssignmentUtils
            .setResourceDataValue(resourceAssignment, resourceAssignmentRuntimeService, value)

        assertEquals(
            "abc-vnf_private2",
            resourceAssignment.property!!.value!!.asText()
        )
    }

    private fun initInputMapAndExpectedValuesForPrimitiveType() {
        inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
        val keyValue = mutableMapOf<String, String>()
        keyValue["value"] = "1.2.3.1"
        inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
        expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
    }

    private fun initInputMapAndExpectedValuesForCollection() {
        val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
        val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
        listOfIps.forEach {
            val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
            arrayChildNode.set<JsonNode>("value", it.asJsonPrimitive())
            arrayNodeForList1.add(arrayChildNode)
        }
        inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1

        expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
            ExpectedResponseIp("1.2.3.1"),
            ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
        ).asJsonType()

        val listOfIpAddresses = arrayListOf(
            IpAddress("1111", "1.2.3.1").asJsonType(),
            IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
        )
        val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
        listOfIpAddresses.forEach {
            val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
            arrayChildNode.set<JsonNode>("value", it.asJsonType())
            arrayNodeForList2.add(arrayChildNode)
        }
        inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayNodeForList2

        val arrayNodeForList3 = JacksonUtils.objectMapper.createArrayNode()
        var childNode = JacksonUtils.objectMapper.createObjectNode()
        childNode.set<JsonNode>("port", "1111".asJsonPrimitive())
        childNode.set<JsonNode>("ip", "1.2.3.1".asJsonPrimitive())
        arrayNodeForList3.add(childNode)
        childNode = JacksonUtils.objectMapper.createObjectNode()
        childNode.set<JsonNode>("port", "2222".asJsonPrimitive())
        childNode.set<JsonNode>("ip", "1.2.3.2".asJsonPrimitive())
        arrayNodeForList3.add(childNode)
        childNode = JacksonUtils.objectMapper.createObjectNode()
        childNode.set<JsonNode>("port", "3333".asJsonPrimitive())
        childNode.set<JsonNode>("ip", "1.2.3.3".asJsonPrimitive())
        arrayNodeForList3.add(childNode)
        inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3

        expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
            ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
            ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")),
            ExpectedResponseIpAddress(
                IpAddress("3333", "1.2.3.3")
            )
        ).asJsonType()
        expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
            IpAddress("1111", "1.2.3.1"),
            IpAddress("2222", "1.2.3.2"),
            IpAddress("3333", "1.2.3.3")
        ).asJsonType()
    }

    private fun initInputMapAndExpectedValuesForComplexType() {
        val mapOfComplexType = mutableMapOf<String, JsonNode>()
        mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
        mapOfComplexType["port"] = "8888".asJsonType()
        mapOfComplexType["something"] = "1.2.3.2".asJsonType()
        inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()

        val objectNode = JacksonUtils.objectMapper.createObjectNode()
        expectedValueToTestComplexTypeWithOneOutputKeyMapping =
            objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())

        val childNode1 = JacksonUtils.objectMapper.createObjectNode()
        childNode1.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
        childNode1.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
        childNode1.set<JsonNode>("port", "8888".asJsonType())
        childNode1.set<JsonNode>("something", IpAddress("2222", "1.2.3.1").asJsonType())
        inputMapToTestComplexTypeWithAllOutputKeyMapping = childNode1

        val childNode2 = JacksonUtils.objectMapper.createObjectNode()
        childNode2.set<JsonNode>("name", "my-ipAddress".asJsonPrimitive())
        childNode2.set<JsonNode>("ipAddress", IpAddress("1111", "1.2.3.1").asJsonType())
        expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
    }

    private fun prepareResponseNodeForTest(
        dictionary_source: String,
        sourceType: String,
        entrySchema: String,
        response: Any
    ): JsonNode {

        resourceAssignment = when (sourceType) {
            "list" -> {
                prepareRADataDictionaryCollection(dictionary_source, sourceType, entrySchema)
            }
            "string" -> {
                prepareRADataDictionaryOfPrimaryType(dictionary_source)
            }
            else -> {
                prepareRADataDictionaryComplexType(dictionary_source, sourceType, entrySchema)
            }
        }

        val responseNode = checkNotNull(JacksonUtils.getJsonNode(response)) {
            "Failed to get database query result into Json node."
        }

        val outputKeyMapping = prepareOutputKeyMapping(dictionary_source)

        return ResourceAssignmentUtils.parseResponseNode(
            responseNode,
            resourceAssignment,
            resourceAssignmentRuntimeService,
            outputKeyMapping
        )
    }

    private fun prepareRADataDictionaryOfPrimaryType(dictionary_source: String): ResourceAssignment {
        return ResourceAssignment().apply {
            name = "ipAddress"
            dictionaryName = "sample-ip"
            dictionarySource = "$dictionary_source"
            property = PropertyDefinition().apply {
                type = "string"
            }
        }
    }

    private fun prepareRADataDictionaryCollection(
        dictionary_source: String,
        sourceType: String,
        schema: String
    ): ResourceAssignment {
        return ResourceAssignment().apply {
            name = "ipAddress-list"
            dictionaryName = "sample-licenses"
            dictionarySource = "$dictionary_source"
            property = PropertyDefinition().apply {
                type = "$sourceType"
                entrySchema = EntrySchema().apply {
                    type = "$schema"
                }
            }
        }
    }

    private fun prepareRADataDictionaryComplexType(
        dictionary_source: String,
        sourceType: String,
        schema: String
    ): ResourceAssignment {
        return ResourceAssignment().apply {
            name = "ipAddress-complexType"
            dictionaryName = "sample-licenses"
            dictionarySource = "$dictionary_source"
            property = PropertyDefinition().apply {
                type = "$sourceType"
            }
        }
    }

    private fun prepareOutputKeyMapping(dictionary_source: String): MutableMap<String, String> {
        val outputMapping = mutableMapOf<String, String>()

        when (dictionary_source) {
            "sample-key-value", "sample-value" -> {
                // Primary Type
                if (dictionary_source == "sample-key-value")
                    outputMapping["sample-ip"] = "value"
            }
            "listOfString", "mapOfString" -> {
                // List of string
                outputMapping["ip"] = "value"
            }
            "listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
                // List or map of complex Type
                if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
                    outputMapping["ipAddress"] = "value"
                else {
                    outputMapping["port"] = "port"
                    outputMapping["ip"] = "ip"
                }
            }
            else -> {
                // Complex Type
                if (dictionary_source == "complexTypeOneKeys")
                    outputMapping["host"] = "value"
                else {
                    outputMapping["name"] = "name"
                    outputMapping["ipAddress"] = "ipAddress"
                }
            }
        }
        return outputMapping
    }
}