Make UatExecutor accessible inside a CBA JUnit test
[ccsdk/cds.git] / components / model-catalog / blueprint-model / archetype-blueprint / src / main / resources / archetype-resources / Tests / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / SampleResourceResolutionTest.kt
1 package org.onap.ccsdk.cds.blueprintsprocessor.uat
2
3 import kotlinx.coroutines.runBlocking
4 import org.junit.Test
5 import org.onap.ccsdk.cds.blueprintsprocessor.uat.base.BaseUatResourceResolutionTest
6 import org.slf4j.Logger
7 import org.slf4j.LoggerFactory
8 import java.nio.file.Path
9 import kotlin.test.Ignore
10 import kotlin.test.assertEquals
11
12
13 /**
14  * This is a sample implementation of a test class using {@see BaseUatResourceResolutionTest}
15  * Please find "TODO" comments, where you need to make your changes
16  */
17 class SampleResourceResolutionTest : BaseUatResourceResolutionTest() {
18
19     companion object {
20         val log: Logger = LoggerFactory.getLogger(SampleResourceResolutionTest::class.java)
21         private val cwd: String = Path.of("").toAbsolutePath().toString()
22         val blueprintBasePath : String = cwd
23         // TODO: exchange here the real path to the request json
24         val fileNameExecutionServiceInput : String = "$cwd/Tests/sample-resourceresolution-request.json"
25     }
26
27     // TODO: remove @Ignore to activate the test
28     @Ignore
29     @Test
30     @Throws(Exception::class)
31     fun `test resolveResource for nodeTemplate fetch-nf-config-process`() {
32         runBlocking {
33             callResolveResources(
34                 blueprintBasePath,
35
36                 // TODO: replace the following parameters with yours
37                 fileNameExecutionServiceInput,
38                 "workflowName",
39                 "nodeTemplateName",
40                 "artifactPrefixName"
41             )
42         }.let { (templateMap, assignmentList) ->
43             // list of pairs
44             val expectedAssignmentList = mutableListOf(
45                 // TODO: only samples
46                 "service-instance-id" to "fb84c76d-676e-4a36-9237-52089594292b",
47                 "service-instance-name" to "cucp-1",
48                 "vnf-id" to "de59d80e-cbce-4898-9e3c-3a917e89d834"
49                 // TODO: add your key value pairs here
50             )
51
52             // assert size of list
53             assertEquals(expectedAssignmentList.size, assignmentList.size)
54
55             val list = expectedAssignmentList.zip(assignmentList)
56             list.forEach {
57                     (expected, actual) ->
58                 run {
59
60                     // do individual assertions here
61
62                     // names must be equal
63                     assertEquals(expected.first, actual.name)
64                     when (expected.first) {
65                         // TODO: fill in here your concrete ObjectNode names
66                         "objectNodeName1", "objectNodeName2" -> {
67                             // ObjectNodes
68                             log.info("expected name[${expected.first}] actual name[${actual.name}] " +
69                                     "-> expected value[${expected.second}] actual value[${actual.property?.value.toString()}]")
70
71                             // values must be equal
72                             assertEquals(expected.second, actual.property?.value.toString())
73                         }
74                         else -> {
75                             // TextNodes. This is the default case
76                             log.info("expected name[${expected.first}] actual name[${actual.name}] " +
77                                     "-> expected value[${expected.second}] actual value[${actual.property?.value?.asText()}]")
78                             // values must be equal
79                             assertEquals(expected.second, actual.property?.value?.asText())
80                         }
81                     }
82                 }
83             }
84         }
85     }
86 }