2 * Copyright © 2019 IBM.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
19 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
20 import kotlin.test.Test
21 import kotlin.test.assertNotNull
23 class ResourceSourceDSLTest {
26 fun testNodeTypeSourceInput() {
27 val nodeType = BluePrintTypes.nodeTypeSourceInput()
28 //println(nodeType.asJsonString(true))
29 assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
33 fun testNodeTypeSourceDefault() {
34 val nodeType = BluePrintTypes.nodeTypeSourceDefault()
35 //println(nodeType.asJsonString(true))
36 assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
40 fun testNodeTypeSourceDb() {
41 val nodeType = BluePrintTypes.nodeTypeSourceDb()
42 //println(nodeType.asJsonString(true))
43 assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
47 fun testNodeTypeSourceRest() {
48 val nodeType = BluePrintTypes.nodeTypeSourceRest()
49 //println(nodeType.asJsonString(true))
50 assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
54 fun testNodeTypeSourceCapability() {
55 val nodeType = BluePrintTypes.nodeTypeSourceCapability()
56 //println(nodeType.asJsonString(true))
57 assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
61 fun testNodeTemplateSourceInput() {
62 val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
65 //println(nodeTemplate.asJsonString(true))
66 assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
70 fun testNodeTemplateSourceDefault() {
71 val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
74 //println(nodeTemplate.asJsonString(true))
75 assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
79 fun testNodeTemplateSourceDb() {
80 val nodeTemplate = BluePrintTypes.nodeTemplateSourceDb("DbSystem", "") {
83 query("SELECT * FROM DB WHERE name = \$name")
84 endpointSelector("db-source-endpoint")
89 map("field_name", "\$fieldValue")
91 keyDependencies(arrayListOf("name"))
94 //println(nodeTemplate.asJsonString(true))
95 assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
99 fun testNodeTemplateSourceRest() {
100 val nodeTemplate = BluePrintTypes.nodeTemplateSourceRest("restSystem", "") {
103 endpointSelector("rest-source-endpoint")
104 expressionType("JSON_PATH")
108 payload("sample payload")
110 map("name", "\$name")
113 map("field_name", "\$fieldValue")
115 keyDependencies(arrayListOf("name"))
118 //println(nodeTemplate.asJsonString(true))
119 assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
123 fun testNodeTemplateSourceCapability() {
124 val nodeTemplate = BluePrintTypes.nodeTemplateSourceCapability("capabiltySystem", "") {
127 scriptClassReference("Scripts/Sample.kt")
128 keyDependencies(arrayListOf("name"))
131 //println(nodeTemplate.asJsonString(true))
132 assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")