Renaming Files having BluePrint to have Blueprint
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / ssh-lib / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / ssh / SshPropertiesDSLTest.kt
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.ssh
18
19 import org.junit.Test
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
25
26 class SshPropertiesDSLTest {
27
28     @Test
29     fun testSshPropertiesDSL() {
30         val serviceTemplate = serviceTemplate("ssh-properties-test", "1.0.0", "xxx.@xx.com", "ssh") {
31             topologyTemplate {
32                 relationshipTemplateSshClient("sample-basic-auth", "SSH Connection") {
33                     basicAuth {
34                         username("sample-user")
35                         password("sample-password")
36                         host("sample-host")
37                         connectionTimeOut(30)
38                     }
39                 }
40             }
41             relationshipTypeConnectsToSshClient()
42             relationshipTypeConnectsTo()
43         }
44
45         // println(serviceTemplate.asJsonString(true))
46         assertNotNull(serviceTemplate, "failed to create service template")
47         val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
48         assertNotNull(relationshipTemplates, "failed to get relationship templates")
49         assertEquals(1, relationshipTemplates.size, "relationshipTemplates doesn't match")
50         assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
51
52         val relationshipTypes = serviceTemplate.relationshipTypes
53         assertNotNull(relationshipTypes, "failed to get relationship types")
54         assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
55         assertNotNull(
56             relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
57             "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
58         )
59         assertNotNull(
60             relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_SSH_CLIENT],
61             "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_SSH_CLIENT}"
62         )
63     }
64 }