b0c7d8b3c405d89a96c67c330b54fcd4dcec1ff3
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2018-2019 AT&T Intellectual Property.
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.blueprintsprocessor.db
18
19 import org.junit.Test
20 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
21 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
22 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
23 import kotlin.test.assertEquals
24 import kotlin.test.assertNotNull
25
26 class DatabasePropertiesDSLTest {
27
28     @Test
29     fun testDatabasePropertiesDSL() {
30         val serviceTemplate = serviceTemplate("database-properties-test", "1.0.0", "xxx.@xx.com", "database") {
31             topologyTemplate {
32                 relationshipTemplateDb("sample-maria-db", "Database Server") {
33                     mariaDb {
34                         url("jdbc://mariadb:3600")
35                         username("user")
36                         password("credential")
37                         hibernateDDLAuto("hibernateDDLAuto")
38                         hibernateHbm2ddlAuto("hibernateHbm2ddlAuto")
39                         hibernateDDLAuto("hibernateDDLAuto")
40                         hibernateNamingStrategy("hibernateNamingStrategy")
41                     }
42                 }
43                 relationshipTemplateDb("sample-mysql-db", "Database Server") {
44                     mySqlDb {
45                         url("jdbc://mysql:3600")
46                         username("user")
47                         password("credential")
48                         hibernateDDLAuto("hibernateDDLAuto")
49                         hibernateHbm2ddlAuto("hibernateHbm2ddlAuto")
50                         hibernateDDLAuto("hibernateDDLAuto")
51                         hibernateNamingStrategy("hibernateNamingStrategy")
52                     }
53                 }
54             }
55             relationshipTypes(
56                 arrayListOf(
57                     BluePrintTypes.relationshipTypeConnectsToDb(),
58                     BluePrintTypes.relationshipTypeConnectsTo()
59                 )
60             )
61         }
62         assertNotNull(serviceTemplate, "failed to create service template")
63         val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
64         assertNotNull(relationshipTemplates, "failed to get relationship templates")
65         assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
66         assertNotNull(relationshipTemplates["sample-maria-db"], "failed to get sample-maria-db")
67         assertNotNull(relationshipTemplates["sample-mysql-db"], "failed to get sample-mysql-db")
68         // println(serviceTemplate.asJsonString(true))
69     }
70 }