diff options
Diffstat (limited to 'ms/controllerblueprints/modules/service')
3 files changed, 38 insertions, 15 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt index 9fbf0916..fc9ee504 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt @@ -82,8 +82,27 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP private fun enhanceStepTargets(name: String, workflow: Workflow) { - // Get the first Step Target NodeTemplate name( Since that is the DG Node Template) - val dgNodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(name) + // Get the first Step Target NodeTemplate name( It may be Component or DG Node Template) + val firstNodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(name) + + val derivedFrom = bluePrintContext.nodeTemplateNodeType(firstNodeTemplateName).derivedFrom + + when { + derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> { + // DO Nothing + } + derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_DG, true) -> { + enhanceDGStepTargets(name, workflow, firstNodeTemplateName) + } + else -> { + throw BluePrintProcessorException("couldn't execute workflow($name) step mapped " + + "to node template($firstNodeTemplateName) derived from($derivedFrom)") + } + } + + } + + private fun enhanceDGStepTargets(name: String, workflow: Workflow, dgNodeTemplateName: String) { val dgNodeTemplate = bluePrintContext.nodeTemplateByName(dgNodeTemplateName) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt index 6171687f..816b3566 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt @@ -75,7 +75,7 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe // Get all the Mapping files from all node templates. private fun getAllResourceMappingFiles(blueprintContext: BluePrintContext): List<String>? { - return blueprintContext.nodeTemplates?.mapNotNull { nodeTemplateMap -> + return blueprintContext.nodeTemplates()?.mapNotNull { nodeTemplateMap -> // Return only Mapping Artifact File Names nodeTemplateMap.value.artifacts?.filter { artifactDefinitionMap -> diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt index 919d202f..48183f4c 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt @@ -64,30 +64,34 @@ class BluePrintEnhancerServiceImplTest { fun testEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" - - val targetPath = Paths.get("target", "bp-enhance").toUri().path - - val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath) - Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext) - - // Validate the Generated BluePrints - val valid = bluePrintValidatorService.validateBluePrints(targetPath) - Assert.assertTrue("blueprint validation failed ", valid) + testComponentInvokeEnhancementAndValidation(basePath, "base-enhance") } @Test @Throws(Exception::class) - fun testEnhancementAndValidation2() { + fun testComponentInvokeEnhancementAndValidation() { + val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/component_invoke" + testComponentInvokeEnhancementAndValidation(basePath, "component-enhance") + } + @Test + @Throws(Exception::class) + fun testGoldenEnhancementAndValidation() { val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/golden" + testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance") + } - val targetPath = Paths.get("target", "bp-enhance").toUri().path + + private fun testComponentInvokeEnhancementAndValidation(basePath: String, targetDirName: String) { + + val targetPath = Paths.get("target", targetDirName).toUri().path val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath) Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext) // Validate the Generated BluePrints val valid = bluePrintValidatorService.validateBluePrints(targetPath) - Assert.assertTrue("blueprint validation failed ", valid) + Assert.assertTrue("blueprint($basePath) validation failed ", valid) } + }
\ No newline at end of file |