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.controllerblueprints.core.annotations
19 import com.fasterxml.jackson.databind.JsonNode
20 import org.onap.ccsdk.cds.controllerblueprints.core.asBluePrintsDataTypes
21 import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap
22 import kotlin.test.Test
23 import kotlin.test.assertNotNull
25 class BluePrintsAnnotationsTest {
28 fun testBluePrintWorkflowData() {
29 val wfInput = TestBluePrintsWorkflowInput::class.asPropertyDefinitionMap()
30 //println(wfInput.asJsonString(true))
31 assertNotNull(wfInput, "failed to generate wfInput property map")
33 val wfOutput = TestBluePrintsWorkflowOutput::class.asPropertyDefinitionMap()
34 //println(wfOutput.asJsonString(true))
35 assertNotNull(wfInput, "failed to generate wfOutput property map")
39 fun testBluePrintDataType() {
40 val dataTypes = TestBluePrintsDataType::class.asBluePrintsDataTypes()
41 //println(dataTypes.asJsonString(true))
42 assertNotNull(dataTypes, "failed to generate dataTypes definition")
46 @BluePrintsDataType(name = "dt-test-datatype", description = "I am test",
47 version = "1.0.0", derivedFrom = "tosca.datatypes.root")
48 data class TestBluePrintsDataType(
49 @BluePrintsProperty(description = "this stringData")
50 var stringData: String,
51 @BluePrintsProperty(description = "this stringDataWithValue")
52 @PropertyDefaultValue(value = "USA")
53 val stringDataWithValue: String,
54 @BluePrintsProperty(description = "this intDataWithValue")
55 @PropertyDefaultValue(value = "30")
56 val intDataWithValue: Int,
57 @BluePrintsProperty(description = "this booleanDataWithValue")
58 @PropertyDefaultValue(value = "true")
59 val booleanDataWithValue: Boolean,
60 @BluePrintsProperty(description = "this anyData")
62 @BluePrintsProperty(description = "this jsonDataWithValue")
63 @PropertyDefaultValue(value = """{"data" : "1234"}""")
64 val jsonDataWithValue: JsonNode?,
65 @BluePrintsProperty(description = "listData")
66 val listData: MutableList<String>,
67 @BluePrintsProperty(description = "this mapData")
68 val mapData: MutableMap<String, String> = hashMapOf(),
69 @BluePrintsProperty(description = "this complexData")
70 val complexData: TestBluePrintsChildDataType?,
71 @BluePrintsProperty(description = "this complexDataList")
72 val complexDataList: MutableList<TestBluePrintsChildDataType>
75 data class TestBluePrintsChildDataType(val name: String)
78 @BluePrintsWorkflowInput
79 data class TestBluePrintsWorkflowInput(
80 @BluePrintsProperty(description = "this sample name")
81 @PropertyDefaultValue(value = "Brinda")
83 @BluePrintsProperty(description = "this sample name")
87 @BluePrintsWorkflowOutput
88 data class TestBluePrintsWorkflowOutput(
89 @BluePrintsProperty(description = "this is dslExpression")
90 @DSLExpression("field1")
91 var dslExpression: String,
93 @BluePrintsProperty(description = "this is withNodeAttributeExpression")
94 @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data")
95 var withNodeAttributeExpression: String,
97 @BluePrintsProperty(description = "this is withNodeAttributeExpressionSubAttribute")
98 @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data",
99 subAttributeName = ".\$field1")
100 var withNodeAttributeExpressionSubAttribute: String,
102 @BluePrintsProperty(description = "this is withAttributeExpressionSubAttribute")
103 @AttributeExpression(attributeName = "response-data", subAttributeName = ".\$field1")
104 var withAttributeExpressionSubAttribute: String,
106 @BluePrintsProperty(description = "this is withAttributeExpression")
107 @AttributeExpression(attributeName = "response-data")
108 var withAttributeExpression: String,
110 @BluePrintsProperty(description = "this is withAArtifactExpression")
111 @ArtifactExpression(modelableEntityName = "test-node", artifactName = "content-template")
112 var withAArtifactExpression: String,
114 @BluePrintsProperty(description = "this status")
115 val status: String = "success"