aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
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
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')
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt69
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt2
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt (renamed from ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt)17
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSL.kt13
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSLTest.kt48
-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
-rw-r--r--ms/blueprintsprocessor/modules/commons/nats-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSL.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/nats-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nats/NatsPropertiesDSLTest.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt22
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSLTest.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt30
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt52
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt62
20 files changed, 423 insertions, 104 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
index c23e495fb..3c5561994 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
@@ -46,9 +46,9 @@ fun serviceTemplate(
version: String,
author: String,
tags: String,
- block: BluePrintServiceDSLBuilder.() -> Unit
+ block: ServiceTemplateBuilder.() -> Unit
): ServiceTemplate {
- return BluePrintServiceDSLBuilder(name, version, author, tags).apply(block).build()
+ return ServiceTemplateBuilder(name, version, author, tags).apply(block).build()
}
fun workflow(id: String, description: String, block: WorkflowBuilder.() -> Unit): Workflow {
@@ -171,6 +171,11 @@ fun getNodeTemplateOperationOutput(
}
/** Blueprint Type Extensions */
+fun ServiceTemplateBuilder.nodeTypeComponent() {
+ val nodeType = BluePrintTypes.nodeTypeComponent()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponent(): NodeType {
return nodeType(
@@ -182,6 +187,7 @@ fun BluePrintTypes.nodeTypeComponent(): NodeType {
}
}
+@Deprecated("CDS won't support, use implerative workflow definitions.")
fun BluePrintTypes.nodeTypeWorkflow(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
@@ -192,6 +198,12 @@ fun BluePrintTypes.nodeTypeWorkflow(): NodeType {
}
}
+fun ServiceTemplateBuilder.nodeTypeVnf() {
+ val nodeType = BluePrintTypes.nodeTypeVnf()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
+
fun BluePrintTypes.nodeTypeVnf(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_VNF,
@@ -202,6 +214,12 @@ fun BluePrintTypes.nodeTypeVnf(): NodeType {
}
}
+fun ServiceTemplateBuilder.nodeTypeResourceSource() {
+ val nodeType = BluePrintTypes.nodeTypeResourceSource()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
+
fun BluePrintTypes.nodeTypeResourceSource(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
@@ -213,6 +231,11 @@ fun BluePrintTypes.nodeTypeResourceSource(): NodeType {
}
/** Artifacts */
+fun ServiceTemplateBuilder.artifactTypeTemplateVelocity() {
+ val artifactType = BluePrintTypes.artifactTypeTemplateVelocity()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType {
return artifactType(
@@ -225,6 +248,12 @@ fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeTempleJinja() {
+ val artifactType = BluePrintTypes.artifactTypeTempleJinja()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA,
@@ -236,6 +265,12 @@ fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeMappingResource() {
+ val artifactType = BluePrintTypes.artifactTypeMappingResource()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeMappingResource(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE,
@@ -259,6 +294,12 @@ fun BluePrintTypes.artifactTypeScriptJython(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeScriptKotlin() {
+ val artifactType = BluePrintTypes.artifactTypeScriptKotlin()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeScriptKotlin(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN,
@@ -282,6 +323,12 @@ fun BluePrintTypes.artifactTypeDirectedGraph(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeComponentJar() {
+ val artifactType = BluePrintTypes.artifactTypeComponentJar()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR,
@@ -295,6 +342,12 @@ fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
/** Relationship Types */
+fun ServiceTemplateBuilder.relationshipTypeConnectsTo() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsTo()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
@@ -306,6 +359,12 @@ fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType {
}
}
+fun ServiceTemplateBuilder.relationshipTypeDependsOn() {
+ val relationshipType = BluePrintTypes.relationshipTypeDependsOn()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
@@ -316,6 +375,12 @@ fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType {
}
}
+fun ServiceTemplateBuilder.relationshipTypeHostedOn() {
+ val relationshipType = BluePrintTypes.relationshipTypeHostedOn()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeHostedOn(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON,
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
index 216a0d16f..a89267387 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
@@ -36,7 +36,7 @@ import kotlin.reflect.jvm.reflect
open class TopologyTemplateBuilder {
private var topologyTemplate = TopologyTemplate()
- private var nodeTemplates: MutableMap<String, NodeTemplate>? = null
+ var nodeTemplates: MutableMap<String, NodeTemplate>? = null
var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
private var workflows: MutableMap<String, Workflow>? = null
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt
index a3db88b6a..254e644b3 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt
@@ -32,7 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
import kotlin.reflect.KClass
-class BluePrintServiceDSLBuilder(
+class ServiceTemplateBuilder(
private val name: String,
private val version: String,
private val author: String,
@@ -44,11 +44,11 @@ class BluePrintServiceDSLBuilder(
private var metadata: MutableMap<String, String> = hashMapOf()
private var dslDefinitions: MutableMap<String, JsonNode>? = null
private var imports: MutableList<ImportDefinition> = mutableListOf()
- private var nodeTypes: MutableMap<String, NodeType>? = null
- private var artifactTypes: MutableMap<String, ArtifactType>? = null
- private var dataTypes: MutableMap<String, DataType>? = null
- private var relationshipTypes: MutableMap<String, RelationshipType>? = null
- private var policyTypes: MutableMap<String, PolicyType>? = null
+ var nodeTypes: MutableMap<String, NodeType>? = null
+ var artifactTypes: MutableMap<String, ArtifactType>? = null
+ var dataTypes: MutableMap<String, DataType>? = null
+ var relationshipTypes: MutableMap<String, RelationshipType>? = null
+ var policyTypes: MutableMap<String, PolicyType>? = null
private fun initMetaData() {
metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = name
@@ -93,25 +93,21 @@ class BluePrintServiceDSLBuilder(
fun artifactTypes(artifactTypes: MutableMap<String, ArtifactType>) {
if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
-
this.artifactTypes!!.putAll(artifactTypes)
}
fun relationshipTypes(relationshipTypes: MutableMap<String, RelationshipType>) {
if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
-
this.relationshipTypes!!.putAll(relationshipTypes)
}
fun policyTypes(policyTypes: MutableMap<String, PolicyType>) {
if (this.policyTypes == null) this.policyTypes = hashMapOf()
-
this.policyTypes!!.putAll(policyTypes)
}
fun nodeType(nodeTypes: MutableMap<String, NodeType>) {
if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
-
this.nodeTypes!!.putAll(nodeTypes)
}
@@ -139,7 +135,6 @@ class BluePrintServiceDSLBuilder(
fun policyType(policyType: PolicyType) {
if (policyTypes == null) policyTypes = hashMapOf()
-
policyTypes!![policyType.id!!] = policyType
}
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
index c2d764bd6..bf16ea93a 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
@@ -100,6 +100,21 @@ class BluePrintDSLTest {
import("Definition/data_types.json")
dsl("rest-endpoint", """{ "selector" : "odl-selector"}""")
dsl("db-endpoint", """{ "selector" : "db-selector"}""")
+
+ nodeTypeComponent()
+ nodeTypeResourceSource()
+ nodeTypeVnf()
+
+ artifactTypeTemplateVelocity()
+ artifactTypeTempleJinja()
+ artifactTypeScriptKotlin()
+ artifactTypeMappingResource()
+ artifactTypeComponentJar()
+
+ relationshipTypeConnectsTo()
+ relationshipTypeDependsOn()
+ relationshipTypeHostedOn()
+
topologyTemplate {
nodeTemplateOperation(
nodeTemplateName = "activate", type = "sample-node-type", interfaceName = "RestconfExecutor",
@@ -162,10 +177,16 @@ class BluePrintDSLTest {
}
}
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate.artifactTypes, "failed to get artifactTypes")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to get nodeTypes")
+ assertNotNull(serviceTemplate.relationshipTypes, "failed to get relationshipTypes")
assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template")
assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates, "failed to get nodeTypes")
- assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"], "failed to get nodeTypes(activate)")
- // println(serviceTemplate.asJsonString(true))
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"],
+ "failed to get nodeTypes(activate)"
+ )
}
@Test
@@ -254,7 +275,7 @@ fun BluePrintTypes.nodeTemplateComponentTestExecutor(
description: String,
block: TestNodeTemplateOperationImplBuilder.() -> Unit
):
- NodeTemplate {
+ NodeTemplate {
return TestNodeTemplateOperationImplBuilder(id, description).apply(block).build()
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt
index 2bf56f482..34dd0a417 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSL.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 Database Producer */
+fun ServiceTemplateBuilder.relationshipTypeConnectsToDb() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToDb()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToDb(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB,
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt
index b0c7d8b3c..dd84e5b02 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/DatabasePropertiesDSLTest.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db
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
@@ -52,19 +52,28 @@ class DatabasePropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToDb(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToDb()
+ 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-maria-db"], "failed to get sample-maria-db")
assertNotNull(relationshipTemplates["sample-mysql-db"], "failed to get sample-mysql-db")
- // 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_DB],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_DB}"
+ )
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSL.kt
index 354e38dc7..8063e8909 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSL.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 GRPC Server Producer */
+fun ServiceTemplateBuilder.relationshipTypeConnectsToGrpcServer() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToGrpcServer()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToGrpcServer(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_SERVER,
@@ -45,6 +52,12 @@ fun BluePrintTypes.relationshipTypeConnectsToGrpcServer(): RelationshipType {
}
}
+fun ServiceTemplateBuilder.relationshipTypeConnectsToGrpcClient() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToGrpcClient()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToGrpcClient(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_CLIENT,
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSLTest.kt
index 9b3cf80bc..3de857fa5 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/GrpcPropertiesDSLTest.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.grpc
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
@@ -44,20 +44,29 @@ class GrpcPropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToGrpcServer(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToGrpcServer()
+ 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-tls-auth"], "failed to get sample-tls-auth")
assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-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_GRPC_SERVER],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_SERVER}"
+ )
}
@Test
@@ -89,13 +98,11 @@ class GrpcPropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToGrpcClient(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToGrpcClient()
+ relationshipTypeConnectsTo()
}
+
+ // println(serviceTemplate.asJsonString(true))
assertNotNull(serviceTemplate, "failed to create service template")
val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
assertNotNull(relationshipTemplates, "failed to get relationship templates")
@@ -103,6 +110,17 @@ class GrpcPropertiesDSLTest {
assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-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_GRPC_CLIENT],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_CLIENT}"
+ )
}
}
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}"
+ )
}
}
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}"
+ )
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
index 4c25cb5bf..5d68e5d43 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.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 Type DSL for Rest */
+fun ServiceTemplateBuilder.relationshipTypeConnectsToRestClient() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToRestClient()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToRestClient(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_REST_CLIENT,
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
index 28784e4ae..f06f827ad 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
@@ -19,7 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.rest.relationshipTemplateRestClient
import org.onap.ccsdk.cds.blueprintsprocessor.rest.relationshipTypeConnectsToRestClient
-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
@@ -56,12 +56,8 @@ class RestClientPropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToRestClient(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToRestClient()
+ relationshipTypeConnectsTo()
}
// println(serviceTemplate.asJsonString(true))
@@ -72,5 +68,17 @@ class RestClientPropertiesDSLTest {
assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
assertNotNull(relationshipTemplates["sample-ssl-auth"], "failed to get sample-ssl-auth")
+
+ 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_REST_CLIENT],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_REST_CLIENT}"
+ )
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt
index e63f2eb49..ee7a7dead 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSL.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.relationshipTypeConnectsToSshClient() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsToSshClient()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsToSshClient(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_SSH_CLIENT,
diff --git a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSLTest.kt
index bc4355357..85891b1b5 100644
--- a/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/ssh-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/ssh/SshPropertiesDSLTest.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.ssh
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
@@ -38,19 +38,27 @@ class SshPropertiesDSLTest {
}
}
}
- relationshipTypes(
- arrayListOf(
- BluePrintTypes.relationshipTypeConnectsToSshClient(),
- BluePrintTypes.relationshipTypeConnectsTo()
- )
- )
+ relationshipTypeConnectsToSshClient()
+ 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_SSH_CLIENT],
+ "failed to get ${BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_SSH_CLIENT}"
+ )
}
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
index 0210e88ea..7bb071501 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
@@ -25,9 +25,16 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
+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.nodeType
/** Component Extensions **/
+fun ServiceTemplateBuilder.nodeTypeComponentRemoteScriptExecutor() {
+ val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType {
return nodeType(
@@ -86,12 +93,24 @@ fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType {
}
/** Component Builder */
+fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit
+) {
+ val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
+ id, description,
+ block
+ )
+ if (nodeTemplates == null) nodeTemplates = hashMapOf()
+ nodeTemplates!![nodeTemplate.id!!] = nodeTemplate
+}
+
fun BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
id: String,
description: String,
block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit
-):
- NodeTemplate {
+): NodeTemplate {
return ComponentRemoteScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
index d4ca0f487..8592ce62b 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
@@ -25,10 +25,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
+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.nodeType
import kotlin.reflect.KClass
/** Component Extensions **/
+fun ServiceTemplateBuilder.nodeTypeComponentScriptExecutor() {
+ val nodeType = BluePrintTypes.nodeTypeComponentScriptExecutor()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
return nodeType(
@@ -80,19 +87,31 @@ fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
}
/** Component Builder */
+fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
+) {
+ val nodeTemplate = BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id, description,
+ block
+ )
+ if (nodeTemplates == null) nodeTemplates = hashMapOf()
+ nodeTemplates!![nodeTemplate.id!!] = nodeTemplate
+}
+
fun BluePrintTypes.nodeTemplateComponentScriptExecutor(
id: String,
description: String,
block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
-):
- NodeTemplate {
+): NodeTemplate {
return ComponentScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String) :
AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
+ ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
id, "component-script-executor",
"ComponentScriptExecutor",
description
@@ -110,7 +129,8 @@ class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String
scriptClassReference(scriptClassReference.qualifiedName!!)
}
- fun scriptClassReference(scriptClassReference: String) = scriptClassReference(scriptClassReference.asJsonPrimitive())
+ fun scriptClassReference(scriptClassReference: String) =
+ scriptClassReference(scriptClassReference.asJsonPrimitive())
fun scriptClassReference(scriptClassReference: JsonNode) {
property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, scriptClassReference)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
index 2091e0366..0125cd8d9 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
@@ -36,6 +36,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
@@ -54,26 +55,41 @@ class ComponentRemoteScriptExecutorTest {
@Test
fun testNodeTemplateComponentRemoteScriptExecutor() {
- val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
- "remote-sample",
- "This is sample node template"
- ) {
- definedOperation(" Sample Operation") {
- implementation(180, "SELF")
- inputs {
- selector("remote-script-executor")
- blueprintName("sample")
- blueprintVersion("1.0.0")
- blueprintAction("sample-action")
- timeout(120)
- requestData("""{"key" :"value"}""")
- }
- outputs {
- status("success")
+ val serviceTemplate = serviceTemplate("remote-script-dsl", "1.0.0", "xx@xx.com", "remote-script-ds") {
+ topologyTemplate {
+ nodeTemplateComponentRemoteScriptExecutor(
+ "remote-sample",
+ "This is sample node template"
+ ) {
+ definedOperation(" Sample Operation") {
+ implementation(180, "SELF")
+ inputs {
+ selector("remote-script-executor")
+ blueprintName("sample")
+ blueprintVersion("1.0.0")
+ blueprintAction("sample-action")
+ timeout(120)
+ requestData("""{"key" :"value"}""")
+ }
+ outputs {
+ status("success")
+ }
+ }
}
}
+ nodeTypeComponentRemoteScriptExecutor()
}
- assertNotNull(nodeTemplate, "failed to generate nodeTemplate Component Remote Script Executor")
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate, "failed to service template")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to service template node Types")
+ assertNotNull(
+ serviceTemplate.nodeTypes!!["component-remote-script-executor"],
+ "failed to service template nodeType(component-remote-script-executor)"
+ )
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates?.get("remote-sample"),
+ "failed to nodeTemplate(remote-sample)"
+ )
}
@Test
@@ -95,7 +111,7 @@ class ComponentRemoteScriptExecutorTest {
val mockStreamingRemoteExecutionService = mockk<StreamingRemoteExecutionService<
org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput,
- org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput>>()
+ ExecutionServiceOutput>>()
coEvery {
mockStreamingRemoteExecutionService.sendNonInteractive(
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt
new file mode 100644
index 000000000..6f957e666
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2018-2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
+
+import org.junit.Test
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
+import kotlin.test.assertNotNull
+
+class ComponentScriptExecutorDSLTest {
+
+ @Test
+ fun nodeTemplateComponentScriptExecutor() {
+
+ val serviceTemplate = serviceTemplate("remote-script-dsl", "1.0.0", "xx@xx.com", "remote-script-ds") {
+ topologyTemplate {
+ nodeTemplateComponentScriptExecutor(
+ "script-sample",
+ "This is sample node template"
+ ) {
+ definedOperation(" Sample Operation") {
+ implementation(180, "SELF")
+ inputs {
+ type("kotlin")
+ scriptClassReference("cba.sample.Processor")
+ dynamicProperties("*dynamic-inputs")
+ }
+ outputs {
+ status("success")
+ }
+ }
+ }
+ }
+ nodeTypeComponentScriptExecutor()
+ }
+
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate, "failed to service template")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to service template node Types")
+ assertNotNull(
+ serviceTemplate.nodeTypes!!["component-script-executor"],
+ "failed to service template nodeType(component-script-executor)"
+ )
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates?.get("script-sample"),
+ "failed to nodeTemplate(script-sample)"
+ )
+ }
+}