From 54b50882876119f4954bcfba2a466f34b5f79512 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Mon, 15 Jul 2019 13:08:07 -0400 Subject: Fix missing constrains definitions. Change-Id: I1d60b1a24a5876f47af3a7b9936a48187bbf2d16 Issue-ID: CCSDK-1380 Signed-off-by: Brinda Santh --- .../core/dsl/BluePrintDSLTest.kt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt index 020edc78e..c0641be69 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType import kotlin.test.assertNotNull @@ -152,6 +153,41 @@ class BluePrintDSLTest { //println(serviceTemplate.asJsonString(true)) } + @Test + fun testNodeTypePropertyConstrains() { + val nodeType = nodeType("data-node", "1.0.0", "tosca.Nodes.root", "") { + property("ip-address", "string", true, "") { + defaultValue("127.0.0.1") + constrain { + validValues(arrayListOf("""127.0.0.1""".asJsonPrimitive())) + length(10) + maxLength(20) + minLength(10) + } + + } + property("disk-space", "string", true, "") { + defaultValue(10) + constrain { + validValues("""["200KB", "400KB"]""") + equal("200KB") + inRange("""["100KB", "500KB" ]""") + maxLength("10MB") + minLength("10KB") + } + constrain { + validValues("""[ 200, 400]""") + greaterOrEqual("10KB") + greaterThan("20KB") + lessOrEqual("200KB") + lessThan("190KB") + } + } + } + assertNotNull(nodeType, "failed to get nodeType") + // println(nodeType.asJsonString(true)) + } + @Test fun testServiceTemplateWorkflow() { val serviceTemplate = serviceTemplate("sample-bp", "1.0.0", -- cgit 1.2.3-korg