Migrate ccsdk/apps to ccsdk/cds
[ccsdk/cds.git] / ms / controllerblueprints / modules / blueprint-core / src / test / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / utils / BluePrintMetadataUtilsTest.kt
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2018 IBM.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.controllerblueprints.core.utils
19
20
21 import org.junit.Test
22 import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
23 import kotlin.test.assertEquals
24 import kotlin.test.assertNotNull
25 import kotlin.test.assertNull
26
27 class BluePrintMetadataUtilsTest {
28
29     @Test
30     fun testToscaMetaData() {
31
32         val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
33
34         val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
35         assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
36         assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
37         assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
38         assertNotNull(toscaMetaData.createdBy, "Missing Created by")
39         assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition")
40         assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
41
42     }
43
44     @Test
45     fun environmentDataTest() {
46         val environmentPath = "./src/test/resources/environments"
47
48         val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath)
49
50         assertNotNull(properties, "Could not read the properties")
51         assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1")
52         assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.password"), "password1", "failed 2")
53         assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.username"), "username2", "failed 3")
54         assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4")
55         assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5")
56     }
57 }