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")
47 name = "dt-test-datatype", description = "I am test",
48 version = "1.0.0", derivedFrom = "tosca.datatypes.root"
50 data class TestBluePrintsDataType(
51 @BluePrintsProperty(description = "this stringData")
52 var stringData: String,
53 @BluePrintsProperty(description = "this stringDataWithValue")
54 @PropertyDefaultValue(value = "USA")
55 val stringDataWithValue: String,
56 @BluePrintsProperty(description = "this intDataWithValue")
57 @PropertyDefaultValue(value = "30")
58 val intDataWithValue: Int,
59 @BluePrintsProperty(description = "this booleanDataWithValue")
60 @PropertyDefaultValue(value = "true")
61 val booleanDataWithValue: Boolean,
62 @BluePrintsProperty(description = "this anyData")
64 @BluePrintsProperty(description = "this jsonDataWithValue")
65 @PropertyDefaultValue(value = """{"data" : "1234"}""")
66 val jsonDataWithValue: JsonNode?,
67 @BluePrintsProperty(description = "listData")
68 val listData: MutableList<String>,
69 @BluePrintsProperty(description = "this mapData")
70 val mapData: MutableMap<String, String> = hashMapOf(),
71 @BluePrintsProperty(description = "this complexData")
72 val complexData: TestBluePrintsChildDataType?,
73 @BluePrintsProperty(description = "this complexDataList")
74 val complexDataList: MutableList<TestBluePrintsChildDataType>
77 data class TestBluePrintsChildDataType(val name: String)
79 @BluePrintsWorkflowInput
80 data class TestBluePrintsWorkflowInput(
81 @BluePrintsProperty(description = "this sample name")
82 @PropertyDefaultValue(value = "Brinda")
84 @BluePrintsProperty(description = "this sample name")
88 @BluePrintsWorkflowOutput
89 data class TestBluePrintsWorkflowOutput(
90 @BluePrintsProperty(description = "this is dslExpression")
91 @DSLExpression("field1")
92 var dslExpression: String,
94 @BluePrintsProperty(description = "this is withNodeAttributeExpression")
95 @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data")
96 var withNodeAttributeExpression: String,
98 @BluePrintsProperty(description = "this is withNodeAttributeExpressionSubAttribute")
100 modelableEntityName = "sample-node", attributeName = "response-data",
101 subAttributeName = ".\$field1"
103 var withNodeAttributeExpressionSubAttribute: String,
105 @BluePrintsProperty(description = "this is withAttributeExpressionSubAttribute")
106 @AttributeExpression(attributeName = "response-data", subAttributeName = ".\$field1")
107 var withAttributeExpressionSubAttribute: String,
109 @BluePrintsProperty(description = "this is withAttributeExpression")
110 @AttributeExpression(attributeName = "response-data")
111 var withAttributeExpression: String,
113 @BluePrintsProperty(description = "this is withAArtifactExpression")
114 @ArtifactExpression(modelableEntityName = "test-node", artifactName = "content-template")
115 var withAArtifactExpression: String,
117 @BluePrintsProperty(description = "this status")
118 val status: String = "success"