2 * Copyright © 2019 IBM.
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.rest.service
20 import org.onap.ccsdk.cds.blueprintsprocessor.rest.relationshipTemplateRestClient
21 import org.onap.ccsdk.cds.blueprintsprocessor.rest.relationshipTypeConnectsToRestClient
22 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
23 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
24 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
25 import kotlin.test.assertEquals
26 import kotlin.test.assertNotNull
28 class RestClientPropertiesDSLTest {
31 fun testRestClientProperties() {
33 val serviceTemplate = serviceTemplate("rest-properties-test", "1.0.0", "xxx.@xx.com", "rest") {
35 relationshipTemplateRestClient("sample-basic-auth", "") {
37 url("http://localhost:8080")
42 relationshipTemplateRestClient("sample-token-auth", "") {
44 url("http://localhost:8080")
48 relationshipTemplateRestClient("sample-ssl-auth", "") {
50 url("http://localhost:8080")
51 keyStoreInstance("instance")
52 sslTrust("sample-trust")
53 sslTrustPassword("sample-trust-password")
54 sslKey("sample-sslkey")
55 sslKeyPassword("sample-key-password")
59 relationshipTypeConnectsToRestClient()
60 relationshipTypeConnectsTo()
63 // println(serviceTemplate.asJsonString(true))
64 assertNotNull(serviceTemplate, "failed to create service template")
65 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
66 assertNotNull(relationshipTemplates, "failed to get relationship templates")
67 assertEquals(3, relationshipTemplates.size, "relationshipTemplates doesn't match")
68 assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
69 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
70 assertNotNull(relationshipTemplates["sample-ssl-auth"], "failed to get sample-ssl-auth")
72 val relationshipTypes = serviceTemplate.relationshipTypes
73 assertNotNull(relationshipTypes, "failed to get relationship types")
74 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
76 relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
77 "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
80 relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_REST_CLIENT],
81 "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_REST_CLIENT}"