summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/message-lib/src
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
committerBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
commitba75d2fad2b0111a510f4ee4cc87e658fb32ac4b (patch)
tree92c50b5bea79bb6c424aab6b0ac2e805a9e36e07 /ms/blueprintsprocessor/modules/commons/message-lib/src
parent1fdaf4953daf15970afe6ee10491dfa2d0a76753 (diff)
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 <bs2796@att.com> Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/message-lib/src')
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSL.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSLTest.kt47
2 files changed, 45 insertions, 15 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSL.kt
index c6e923948..88039466d 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSL.kt
@@ -24,10 +24,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
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 Message Producer */
+fun ServiceTemplateBuilder.relationshipTypeConnectsToMessageProducer() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToMessageProducer()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToMessageProducer(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_PRODUCER,
@@ -45,6 +52,12 @@ fun BluePrintTypes.relationshipTypeConnectsToMessageProducer(): RelationshipType
}
}
+fun ServiceTemplateBuilder.relationshipTypeConnectsToMessageConsumer() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToMessageConsumer()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToMessageConsumer(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_CONSUMER,
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSLTest.kt
index 9ece90ffc..b10e1023b 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/MessagePropertiesDSLTest.kt
@@ -18,7 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message
import org.apache.kafka.streams.StreamsConfig
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.relationshipTypeConnectsTo
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
import kotlin.test.assertEquals
@@ -41,19 +41,28 @@ class MessagePropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToMessageProducer(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToMessageProducer()
+ 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(1, relationshipTemplates.size, "relationshipTemplates doesn't match")
assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-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_MESSAGE_PRODUCER],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_PRODUCER}"
+ )
}
@Test
@@ -82,20 +91,28 @@ class MessagePropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToMessageConsumer(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToMessageConsumer()
+ 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-basic-auth"], "failed to get sample-basic-auth")
assertNotNull(relationshipTemplates["sample-stream-basic-auth"], "failed to get sample-stream-basic-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_MESSAGE_CONSUMER],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_CONSUMER}"
+ )
}
}