Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / blueprints / blueprint-core / src / test / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / annotations / BluePrintsAnnotationsTest.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.annotations
18
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
24
25 class BluePrintsAnnotationsTest {
26
27     @Test
28     fun testBluePrintWorkflowData() {
29         val wfInput = TestBluePrintsWorkflowInput::class.asPropertyDefinitionMap()
30         // println(wfInput.asJsonString(true))
31         assertNotNull(wfInput, "failed to generate wfInput property map")
32
33         val wfOutput = TestBluePrintsWorkflowOutput::class.asPropertyDefinitionMap()
34         // println(wfOutput.asJsonString(true))
35         assertNotNull(wfInput, "failed to generate wfOutput property map")
36     }
37
38     @Test
39     fun testBluePrintDataType() {
40         val dataTypes = TestBluePrintsDataType::class.asBluePrintsDataTypes()
41         // println(dataTypes.asJsonString(true))
42         assertNotNull(dataTypes, "failed to generate dataTypes definition")
43     }
44 }
45
46 @BluePrintsDataType(
47     name = "dt-test-datatype", description = "I am test",
48     version = "1.0.0", derivedFrom = "tosca.datatypes.root"
49 )
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")
63     val anyData: Any,
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>
75 )
76
77 data class TestBluePrintsChildDataType(val name: String)
78
79 @BluePrintsWorkflowInput
80 data class TestBluePrintsWorkflowInput(
81     @BluePrintsProperty(description = "this sample name")
82     @PropertyDefaultValue(value = "Brinda")
83     var name: String,
84     @BluePrintsProperty(description = "this sample name")
85     val place: String
86 )
87
88 @BluePrintsWorkflowOutput
89 data class TestBluePrintsWorkflowOutput(
90     @BluePrintsProperty(description = "this is dslExpression")
91     @DSLExpression("field1")
92     var dslExpression: String,
93
94     @BluePrintsProperty(description = "this is withNodeAttributeExpression")
95     @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data")
96     var withNodeAttributeExpression: String,
97
98     @BluePrintsProperty(description = "this is withNodeAttributeExpressionSubAttribute")
99     @AttributeExpression(
100         modelableEntityName = "sample-node", attributeName = "response-data",
101         subAttributeName = ".\$field1"
102     )
103     var withNodeAttributeExpressionSubAttribute: String,
104
105     @BluePrintsProperty(description = "this is withAttributeExpressionSubAttribute")
106     @AttributeExpression(attributeName = "response-data", subAttributeName = ".\$field1")
107     var withAttributeExpressionSubAttribute: String,
108
109     @BluePrintsProperty(description = "this is withAttributeExpression")
110     @AttributeExpression(attributeName = "response-data")
111     var withAttributeExpression: String,
112
113     @BluePrintsProperty(description = "this is withAArtifactExpression")
114     @ArtifactExpression(modelableEntityName = "test-node", artifactName = "content-template")
115     var withAArtifactExpression: String,
116
117     @BluePrintsProperty(description = "this status")
118     val status: String = "success"
119 )