From ba75d2fad2b0111a510f4ee4cc87e658fb32ac4b Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 31 Dec 2019 10:53:59 -0500 Subject: Flexible DSL Types and Templates definition. Easy search definitions Types and Templates inside ServiceTemplate DSL builder. Unit test modifications to support this change. Issue-ID: CCSDK-1054 Signed-off-by: Brinda Santh Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7 --- .../blueprintsprocessor/nats/NatsPropertiesDSL.kt | 7 ++++++ .../nats/NatsPropertiesDSLTest.kt | 25 ++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'ms/blueprintsprocessor/modules/commons/nats-lib/src') diff --git a/ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSL.kt index 5c4301b38..8ef476446 100644 --- a/ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSL.kt +++ b/ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSL.kt @@ -24,10 +24,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder import org.onap.ccsdk.cds.controllerblueprints.core.dsl.RelationshipTemplateBuilder +import org.onap.ccsdk.cds.controllerblueprints.core.dsl.ServiceTemplateBuilder import org.onap.ccsdk.cds.controllerblueprints.core.dsl.TopologyTemplateBuilder import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipType /** Relationships Types DSL for NATS Producer */ +fun ServiceTemplateBuilder.relationshipTypeConnectsToNats() { + val relationshipType = BluePrintTypes.relationshipTypeConnectsToNats() + if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf() + this.relationshipTypes!![relationshipType.id!!] = relationshipType +} + fun BluePrintTypes.relationshipTypeConnectsToNats(): RelationshipType { return relationshipType( id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_NATS, diff --git a/ms/blueprintsprocessor/modules/commons/nats-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/nats-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSLTest.kt index 4cf474b93..a95b900fe 100644 --- a/ms/blueprintsprocessor/modules/commons/nats-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSLTest.kt +++ b/ms/blueprintsprocessor/modules/commons/nats-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSLTest.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.nats import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getInput import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate @@ -43,21 +43,28 @@ class NatsPropertiesDSLTest { } } } - - relationshipTypes( - arrayListOf( - BluePrintTypes.relationshipTypeConnectsToNats(), - BluePrintTypes.relationshipTypeConnectsTo() - ) - ) + relationshipTypeConnectsToNats() + relationshipTypeConnectsTo() } + // println(serviceTemplate.asJsonString(true)) assertNotNull(serviceTemplate, "failed to create service template") val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates assertNotNull(relationshipTemplates, "failed to get relationship templates") assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match") assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth") assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth") - // println(serviceTemplate.asJsonString(true)) + + val relationshipTypes = serviceTemplate.relationshipTypes + assertNotNull(relationshipTypes, "failed to get relationship types") + assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match") + assertNotNull( + relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO], + "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}" + ) + assertNotNull( + relationshipTypes[BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_NATS], + "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_NATS}" + ) } } -- cgit 1.2.3-korg