Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / resource-resolution / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / resource / resolution / ResourceSourceDSLTest.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
18
19 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
20 import kotlin.test.Test
21 import kotlin.test.assertNotNull
22
23 class ResourceSourceDSLTest {
24
25     @Test
26     fun testNodeTypeSourceInput() {
27         val nodeType = BluePrintTypes.nodeTypeSourceInput()
28         // println(nodeType.asJsonString(true))
29         assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
30     }
31
32     @Test
33     fun testNodeTypeSourceDefault() {
34         val nodeType = BluePrintTypes.nodeTypeSourceDefault()
35         // println(nodeType.asJsonString(true))
36         assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
37     }
38
39     @Test
40     fun testNodeTypeSourceDb() {
41         val nodeType = BluePrintTypes.nodeTypeSourceDb()
42         // println(nodeType.asJsonString(true))
43         assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
44     }
45
46     @Test
47     fun testNodeTypeSourceRest() {
48         val nodeType = BluePrintTypes.nodeTypeSourceRest()
49         // println(nodeType.asJsonString(true))
50         assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
51     }
52
53     @Test
54     fun testNodeTypeSourceCapability() {
55         val nodeType = BluePrintTypes.nodeTypeSourceCapability()
56         // println(nodeType.asJsonString(true))
57         assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
58     }
59
60     @Test
61     fun testNodeTemplateSourceInput() {
62         val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
63         }
64         // println(nodeTemplate.asJsonString(true))
65         assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
66     }
67
68     @Test
69     fun testNodeTemplateSourceDefault() {
70         val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
71         }
72         // println(nodeTemplate.asJsonString(true))
73         assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
74     }
75
76     @Test
77     fun testNodeTemplateSourceDb() {
78         val nodeTemplate = BluePrintTypes.nodeTemplateSourceDb("DbSystem", "") {
79             definedProperties {
80                 type("SQL")
81                 query("SELECT * FROM DB WHERE name = \$name")
82                 endpointSelector("db-source-endpoint")
83                 inputKeyMapping {
84                     map("name", "\$name")
85                 }
86                 outputKeyMapping {
87                     map("field_name", "\$fieldValue")
88                 }
89                 keyDependencies(arrayListOf("name"))
90             }
91         }
92         // println(nodeTemplate.asJsonString(true))
93         assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
94     }
95
96     @Test
97     fun testNodeTemplateSourceRest() {
98         val nodeTemplate = BluePrintTypes.nodeTemplateSourceRest("restSystem", "") {
99             definedProperties {
100                 type("JSON")
101                 endpointSelector("rest-source-endpoint")
102                 expressionType("JSON_PATH")
103                 urlPath("/location")
104                 path(".\$name")
105                 verb("GET")
106                 payload("sample payload")
107                 inputKeyMapping {
108                     map("name", "\$name")
109                 }
110                 outputKeyMapping {
111                     map("field_name", "\$fieldValue")
112                 }
113                 keyDependencies(arrayListOf("name"))
114             }
115         }
116         // println(nodeTemplate.asJsonString(true))
117         assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
118     }
119
120     @Test
121     fun testNodeTemplateSourceCapability() {
122         val nodeTemplate = BluePrintTypes.nodeTemplateSourceCapability("capabiltySystem", "") {
123             definedProperties {
124                 type("kotlin")
125                 scriptClassReference("Scripts/Sample.kt")
126                 keyDependencies(arrayListOf("name"))
127             }
128         }
129         // println(nodeTemplate.asJsonString(true))
130         assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")
131     }
132 }