Merge "Add service template assignments DSL"
[ccsdk/cds.git] / ms / controllerblueprints / modules / blueprint-core / src / test / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / dsl / BluePrintDSLTest.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.controllerblueprints.core.dsl
18
19 import org.junit.Test
20 import kotlin.test.assertNotNull
21
22 class BluePrintDSLTest {
23     @Test
24     fun testServiceTemplate() {
25         val serviceTemplate = serviceTemplate("sample-bp", "1.0.0",
26                 "brindasanth@onap.com", "sample") {
27             metadata("release", "1806")
28             topologyTemplate {
29                 nodeTemplateOperation(nodeTemplateName = "activate", type = "sample-node-type", interfaceName = "RestconfExecutor",
30                         operationName = "process", description = "sample activation") {
31                     inputs {
32                         property("json-content", """{ "name" : "cds"}""")
33                         property("array-content", """["controller", "blueprints"]""")
34                         property("int-value", 234)
35                         property("boolean-value", true)
36                         property("string-value", "sample")
37                         property("input-expression", getInput("key-1"))
38                         property("self-property-expression", getProperty("key-1"))
39                         property("self-attribute-expression", getAttribute("key-1"))
40                         property("self-artifact-expression", getArtifact("key-1"))
41                         property("other-artifact-expression", getNodeTemplateArtifact("node-1", "key-1"))
42                     }
43                 }
44             }
45         }
46
47         assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template")
48         assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates, "failed to get nodeTypes")
49         assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"], "failed to get nodeTypes(activate)")
50         //println(JacksonUtils.getJson(serviceTemplate, true))
51     }
52 }