summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/grpc-lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/grpc-lib/src')
-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
2 files changed, 46 insertions, 15 deletions
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}"
+ )
}
}