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 ResourceDefinitionSDLTest {
26 fun testResourceDefinitionDSL() {
27 val resourceDefinition = BluePrintTypes.resourceDefinition("service-instance-id") {
28 tags("service-instance-name, vfw, resources")
29 updatedBy("brindasanth@onap.com")
30 property("service-instance-name", "string", true, "VFW Service Instance Name")
32 sourceInput("input", "") {}
33 sourceDefault("default", "") {}
34 sourceDb("sdnctl", "") {
37 query("SELECT name FROM SERVICE_INSTANCE WHERE id = \$id")
38 endpointSelector("db-source-endpoint")
40 map("id", "\$service-instance-id")
43 map("service-instance-name", "\$name")
45 keyDependencies(arrayListOf("service-instance-id"))
48 sourceRest("odl-mdsal", "") {
51 endpointSelector("rest-source-endpoint")
52 expressionType("JSON_PATH")
53 urlPath("/service-instance/\$id")
56 payload("sample payload")
58 map("id", "\$service-instance-id")
61 map("service-instance-name", "\$name")
63 keyDependencies(arrayListOf("service-instance-id"))
66 sourceCapability("custom-component", "") {
69 scriptClassReference("Scripts/ServiceInstance.kt")
70 keyDependencies(arrayListOf("service-instance-id"))
75 //println(resourceDefinition.asJsonString(true))
76 assertNotNull(resourceDefinition, "failed to generate resourceDefinition")