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.nats
20 import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
21 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getInput
22 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
23 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
24 import kotlin.test.assertEquals
25 import kotlin.test.assertNotNull
27 class NatsPropertiesDSLTest {
30 fun testNatsPropertiesDSL() {
31 val serviceTemplate = serviceTemplate("nats-dsl", "1.0.0", "xx@xx.com", "nats") {
33 relationshipTemplateNats("sample-token-auth", "Nats TokenAuth endpoint") {
35 host("nats://localhost:4222")
37 monitoringSelector(getInput("monitoringUrl"))
40 relationshipTemplateNats("sample-tls-auth", "Nats TLS endpoint.") {
42 host("nats://localhost:4222")
46 relationshipTypeConnectsToNats()
47 relationshipTypeConnectsTo()
50 // println(serviceTemplate.asJsonString(true))
51 assertNotNull(serviceTemplate, "failed to create service template")
52 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
53 assertNotNull(relationshipTemplates, "failed to get relationship templates")
54 assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
55 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
56 assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
58 val relationshipTypes = serviceTemplate.relationshipTypes
59 assertNotNull(relationshipTypes, "failed to get relationship types")
60 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
62 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
63 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
66 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_NATS],
67 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_NATS}"