2 * Copyright © 2018-2019 AT&T Intellectual Property.
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.blueprintsprocessor.db
20 import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
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
26 class DatabasePropertiesDSLTest {
29 fun testDatabasePropertiesDSL() {
30 val serviceTemplate = serviceTemplate("database-properties-test", "1.0.0", "xxx.@xx.com", "database") {
32 relationshipTemplateDb("sample-maria-db", "Database Server") {
34 url("jdbc://mariadb:3600")
36 password("credential")
37 hibernateDDLAuto("hibernateDDLAuto")
38 hibernateHbm2ddlAuto("hibernateHbm2ddlAuto")
39 hibernateDDLAuto("hibernateDDLAuto")
40 hibernateNamingStrategy("hibernateNamingStrategy")
43 relationshipTemplateDb("sample-mysql-db", "Database Server") {
45 url("jdbc://mysql:3600")
47 password("credential")
48 hibernateDDLAuto("hibernateDDLAuto")
49 hibernateHbm2ddlAuto("hibernateHbm2ddlAuto")
50 hibernateDDLAuto("hibernateDDLAuto")
51 hibernateNamingStrategy("hibernateNamingStrategy")
55 relationshipTypeConnectsToDb()
56 relationshipTypeConnectsTo()
59 // println(serviceTemplate.asJsonString(true))
60 assertNotNull(serviceTemplate, "failed to create service template")
61 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
62 assertNotNull(relationshipTemplates, "failed to get relationship templates")
63 assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
64 assertNotNull(relationshipTemplates["sample-maria-db"], "failed to get sample-maria-db")
65 assertNotNull(relationshipTemplates["sample-mysql-db"], "failed to get sample-mysql-db")
67 val relationshipTypes = serviceTemplate.relationshipTypes
68 assertNotNull(relationshipTypes, "failed to get relationship types")
69 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
71 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
72 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
75 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB],
76 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB}"