aboutsummaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/SampleResourceResolutionTest.kt
blob: 74e17618de23aca9a67365258e4844686692d1a7 (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
package org.onap.ccsdk.cds.blueprintsprocessor.uat

import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.uat.base.BaseUatResourceResolutionTest
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.nio.file.Path
import kotlin.test.Ignore
import kotlin.test.assertEquals


/**
 * This is a sample implementation of a test class using {@see BaseUatResourceResolutionTest}
 * Please find "TODO" comments, where you need to make your changes
 */
class SampleResourceResolutionTest : BaseUatResourceResolutionTest() {

    companion object {
        val log: Logger = LoggerFactory.getLogger(SampleResourceResolutionTest::class.java)
        private val cwd: String = Path.of("").toAbsolutePath().toString()
        val blueprintBasePath : String = cwd
        // TODO: exchange here the real path to the request json
        val fileNameExecutionServiceInput : String = "$cwd/Tests/sample-resourceresolution-request.json"
    }

    // TODO: remove @Ignore to activate the test
    @Ignore
    @Test
    @Throws(Exception::class)
    fun `test resolveResource for nodeTemplate fetch-nf-config-process`() {
        runBlocking {
            callResolveResources(
                blueprintBasePath,

                // TODO: replace the following parameters with yours
                fileNameExecutionServiceInput,
                "workflowName",
                "nodeTemplateName",
                "artifactPrefixName"
            )
        }.let { (templateMap, assignmentList) ->
            // list of pairs
            val expectedAssignmentList = mutableListOf(
                // TODO: only samples
                "service-instance-id" to "fb84c76d-676e-4a36-9237-52089594292b",
                "service-instance-name" to "cucp-1",
                "vnf-id" to "de59d80e-cbce-4898-9e3c-3a917e89d834"
                // TODO: add your key value pairs here
            )

            // assert size of list
            assertEquals(expectedAssignmentList.size, assignmentList.size)

            val list = expectedAssignmentList.zip(assignmentList)
            list.forEach {
                    (expected, actual) ->
                run {

                    // do individual assertions here

                    // names must be equal
                    assertEquals(expected.first, actual.name)
                    when (expected.first) {
                        // TODO: fill in here your concrete ObjectNode names
                        "objectNodeName1", "objectNodeName2" -> {
                            // ObjectNodes
                            log.info("expected name[${expected.first}] actual name[${actual.name}] " +
                                    "-> expected value[${expected.second}] actual value[${actual.property?.value.toString()}]")

                            // values must be equal
                            assertEquals(expected.second, actual.property?.value.toString())
                        }
                        else -> {
                            // TextNodes. This is the default case
                            log.info("expected name[${expected.first}] actual name[${actual.name}] " +
                                    "-> expected value[${expected.second}] actual value[${actual.property?.value?.asText()}]")
                            // values must be equal
                            assertEquals(expected.second, actual.property?.value?.asText())
                        }
                    }
                }
            }
        }
    }
}