diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib')
2 files changed, 22 insertions, 7 deletions
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}" + ) } } |