aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-12-11 18:32:24 -0500
committerBrinda Santh <bs2796@att.com>2019-12-11 18:32:24 -0500
commitd4fadc988246eb172ce8333bb3a06443591c5f19 (patch)
tree19701b12c7f3008acb6a62772458ea4b47e043d8 /ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src
parenta30e1864fadad70c797ca1248a3c1272300a6e2b (diff)
Metadata for name, version, tags and type
Mandate Tosca.meta template name, version, type and tags. Auto copy metadata from Tosca.meta to ServiceTemplate definitions. Optimize Blueprint context and runtime creation from file path. Removed attached CBA zip file in test repository dirs Issue-ID: CCSDK-1992 Signed-off-by: Brinda Santh <bs2796@att.com> Change-Id: I5d9d7a4599234a38d431328dbd9b74bd831e0115
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src')
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt6
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt25
2 files changed, 20 insertions, 11 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
index 5df2decdb..67bdd0396 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
@@ -41,13 +41,13 @@ open class BluePrintDesignTimeValidatorService(
private val log = LoggerFactory.getLogger(BluePrintDesignTimeValidatorService::class.toString())
- override fun validateBluePrints(basePath: String): Boolean {
+ override suspend fun validateBluePrints(basePath: String): Boolean {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
return validateBluePrints(bluePrintRuntimeService)
}
- override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+ override suspend fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
bluePrintTypeValidatorService.validateServiceTemplate(
bluePrintRuntimeService, "service_template",
@@ -76,7 +76,7 @@ open class BluePrintDesignTimeValidatorService(
if (resourceDefinitionFile.exists()) {
val resourceDefinitionMap = JacksonUtils.getMapFromFile(resourceDefinitionFile, ResourceDefinition::class.java)
- resourceDefinitionMap?.forEach { resourceDefinitionName, resourceDefinition ->
+ resourceDefinitionMap.forEach { resourceDefinitionName, resourceDefinition ->
resourceDefinitionValidator.validate(bluePrintRuntimeService, resourceDefinitionName, resourceDefinition)
}
}
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
index 19d1ef0a4..dcf352927 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-validation/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
import io.mockk.every
import io.mockk.mockk
+import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
@@ -35,18 +36,21 @@ import kotlin.test.assertTrue
class BluePrintDesignTimeValidatorServiceTest {
private val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
- private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ private val bluePrintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath)
private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
private val resourceDefinitionValidator = mockk<ResourceDefinitionValidator>()
- private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService, resourceDefinitionValidator)
+ private val defaultBluePrintValidatorService =
+ BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService, resourceDefinitionValidator)
private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
fun testValidateOfType() {
- every { resourceDefinitionValidator.validate(bluePrintRuntime, any(), any()) } returns Unit
+ runBlocking {
+ every { resourceDefinitionValidator.validate(bluePrintRuntime, any(), any()) } returns Unit
- val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
- assertTrue(valid, "failed in blueprint Validation")
+ val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ assertTrue(valid, "failed in blueprint Validation")
+ }
}
@Test
@@ -95,14 +99,19 @@ class BluePrintDesignTimeValidatorServiceTest {
assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
assertEquals(
"Failed to validate Workflow(resource-assignment)'s step(test)'s definition : " +
- "resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', " +
- "Expected 'tosca.nodes.Workflow' or 'tosca.nodes.Component'", bluePrintRuntime.getBluePrintError().errors[0]
+ "resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', " +
+ "Expected 'tosca.nodes.Workflow' or 'tosca.nodes.Component'",
+ bluePrintRuntime.getBluePrintError().errors[0]
)
}
@Test
fun testValidateWorkflowSuccess() {
val workflowName = "resource-assignment"
- workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName))
+ workflowValidator.validate(
+ bluePrintRuntime,
+ workflowName,
+ bluePrintRuntime.bluePrintContext().workflowByName(workflowName)
+ )
}
}