From fb0dea26c8db442173b7d93eddf514f33caa15dd Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 22 Feb 2019 10:14:24 -0500 Subject: [PATCH] Add extension validation framework Change-Id: I5674e8da70cc4d20899f6fe2163a595b28861036 Issue-ID: CCSDK-1103 Signed-off-by: Muthuramalingam, Brinda Santh --- .../db/BlueprintProcessorCatalogServiceImpl.kt | 5 +- .../commons/db-lib/src/test/resources/test-cba.zip | Bin 9189 -> 9302 bytes .../modules/inbounds/selfservice-api/pom.xml | 5 +- .../BluePrintDesignTimeRuntimeValidatorService.kt | 38 ++++++++ .../src/test/resources/test-cba.zip | Bin 9189 -> 9302 bytes ms/blueprintsprocessor/parent/pom.xml | 5 ++ .../core/data/BluePrintModel.kt | 7 +- .../core/interfaces/BlueprintValidator.kt | 33 +++++++ .../core/utils/JacksonUtils.kt | 9 +- .../BluePrintArtifactDefinitionValidatorImpl.kt | 97 +++++++++++++++++++++ .../BluePrintArtifactTypeValidatorImpl.kt | 4 +- .../BluePrintAttributeDefinitionValidatorImpl.kt | 63 ++++++++++++- .../validation/BluePrintDataTypeValidatorImpl.kt | 8 +- ...l.kt => BluePrintDesignTimeValidatorService.kt} | 7 +- .../BluePrintNodeTemplateValidatorImpl.kt | 59 ++++++------- .../validation/BluePrintNodeTypeValidatorImpl.kt | 15 +++- .../BluePrintPropertyDefinitionValidatorImpl.kt | 6 ++ .../BluePrintServiceTemplateValidatorImpl.kt | 5 ++ .../BluePrintTopologyTemplateValidatorImpl.kt | 6 ++ .../BluePrintTypeValidatorServiceImpl.kt | 56 ++++++++++-- .../validation/BluePrintValidatorDefaultService.kt | 92 ------------------- .../validation/BluePrintWorkflowValidatorImpl.kt | 5 ++ .../extension/ArtifactMappingResourceValidator.kt | 48 ++++++++++ ... => BluePrintDesignTimeValidatorServiceTest.kt} | 4 +- .../MockBluePrintTypeValidatorService.kt | 17 ++++ .../enhancer/BluePrintEnhancerServiceImplTest.kt | 17 ++-- 26 files changed, 444 insertions(+), 167 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt rename ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/{BluePrintValidatorServiceImpl.kt => BluePrintDesignTimeValidatorService.kt} (87%) delete mode 100644 ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt rename ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/{BluePrintValidatorServiceImplTest.kt => BluePrintDesignTimeValidatorServiceTest.kt} (96%) diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt index 33d0d96d..e94bcff5 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt @@ -1,6 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2019 Bell Canada. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,10 +41,10 @@ import java.nio.file.Paths * Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl] */ @Service -class BlueprintProcessorCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService, +class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService, private val blueprintConfig: BluePrintCoreConfiguration, private val blueprintModelRepository: BlueprintProcessorModelRepository) - : BlueprintCatalogServiceImpl(bluePrintValidatorService) { + : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) { private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString()) diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip index a62d4bfbbfdb6c797e2db2c7f5d6728d1ec8d82a..907482400002f162ee35814a1a5a98d06a4fc31a 100644 GIT binary patch literal 9302 zcmb7JbzGEN*QLRsJEcWBq(i!6=*}S}99mjHKpK$}L_#{GLzHewDWw}kx*OyhyzvfP zukZWK^8@A&&N}BgXYaGuT3bZ{9svMz{UH$70{;B+=PyhcEEo-CbqO&RB?}jjImiXX zrm2GlLx|>JAarDJa0rVBqXHR>2ZI86l9g@_CjRH(pIEGqAz0Ti$*2wn%K(R;FpneZ zFYUAPbVFyE|AEP5=1LKIY8XnGDrQ;-vtZ(%;l8gR<_ZJ^AjXqouf(H(A!yAe}h6Bf%{epz}KF#k*%u$_Ts1H3RlGR8h3XLb0K%zph zs&%vYk#6KAdxR0&Jgwi+$Rp)LVi!xPTh;E(13B}U@woGoE4xpOUfLPCgSBWv(nn-vCMiXX@ z$`@d`x5fOZGT&xOUDWp@r04r9&a&C<8KU63Omh`l_%^lSwy$%e5M->`;qP;fm}sN4 zhBvx}Z_;0b;Efm#Hc~={XcJ3k_p|6GO z+7(!)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org.onap.ccsdk.apps.controllerblueprints - ${project.version} blueprint-core + + org.onap.ccsdk.apps.controllerblueprints + blueprint-validation + io.grpc grpc-testing diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt new file mode 100644 index 00000000..08d2c3b5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt @@ -0,0 +1,38 @@ +/* + * Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintDesignTimeValidatorService +import org.springframework.stereotype.Service + +@Service +open class BluePrintRuntimeValidatorService( + private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService) { + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") + } + return true + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip index a62d4bfbbfdb6c797e2db2c7f5d6728d1ec8d82a..907482400002f162ee35814a1a5a98d06a4fc31a 100644 GIT binary patch literal 9302 zcmb7JbzGEN*QLRsJEcWBq(i!6=*}S}99mjHKpK$}L_#{GLzHewDWw}kx*OyhyzvfP zukZWK^8@A&&N}BgXYaGuT3bZ{9svMz{UH$70{;B+=PyhcEEo-CbqO&RB?}jjImiXX zrm2GlLx|>JAarDJa0rVBqXHR>2ZI86l9g@_CjRH(pIEGqAz0Ti$*2wn%K(R;FpneZ zFYUAPbVFyE|AEP5=1LKIY8XnGDrQ;-vtZ(%;l8gR<_ZJ^AjXqouf(H(A!yAe}h6Bf%{epz}KF#k*%u$_Ts1H3RlGR8h3XLb0K%zph zs&%vYk#6KAdxR0&Jgwi+$Rp)LVi!xPTh;E(13B}U@woGoE4xpOUfLPCgSBWv(nn-vCMiXX@ z$`@d`x5fOZGT&xOUDWp@r04r9&a&C<8KU63Omh`l_%^lSwy$%e5M->`;qP;fm}sN4 zhBvx}Z_;0b;Efm#Hc~={XcJ3k_p|6GO z+7(!)$Nc7@%``=t#ub&{>rPsPR^qG*m>G1d)pzTf;NjEYu0Aqw@bIdGkaCG7ds0ig zxpz|ka93hOF^I1r;Kk}mIjU@AresZ#iy=HQzNMvu^vM(oR{HkIrn zt`>4!visGXDvr?^5kq|K#Pv)#(6wSMV25_Ay?$pZdE?b1ZAN&*T`@kX%s1covT~No zC9UfL)`=-gEUgs;K?}2w%rqHJC`%_mJG^VyHB!KHSj~ASDrA3f6-_lEX1bg(3S$wU z(q*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Obt#Z3#h1TZn%4mhd(cBGxK6sdCcs^^c3rX>_{6;HNJbmI@081)i)?|l{;4Z1X- z)=*nl#Kto977!EgGHwOy3lyhTHu)|=|4|~ZVrX0Tt;>C58E@Api}#vlUYer|rPp13 z4f~R8EY>Vo=xOWOSgaeV<9g;kV;a|o>d<4z0fOwJ2GCMIxm{4)FR55TvD04+65X-Q615X|gcheN0m zoi|o3l65YGH$sM6pX|@Z-=5`ifIsUHA$i%K2VeH^mMorW5oD5f1IQ>fgU4g5nkcxf z(6-IFflPGwy7+G6iPn`DA~XS0fJ+9S67Y)sk3@MeZsRN0EkV-#S6{KOC>x?Qu>AiiWJlNNsdYKNec!v1-f%ME6)WdnAhfxrLJMs+~;juv2;2hEQM)s>Nu z#ZmsPa(C|O=Lf#;7s>N0VjU0r+n)dckN~6rfTSO9N#qz3fIjBI^YiOJ_rH4oTea^; z?=-$uer&(>4j0t_Ui<{?A!2T)UBf<`$UL4e4#C$|R-})9~?(i`r-)V1F-6;6= zpZo9Q{5L@x5s(|6Rw7yvVcHPo?f*OI`P6+k?nP}I5j62P(BG79M6e$-_xtttnY^gy zB7zaZNfdE}zp19f~DeI1p8m)D@5=gbNBbT{Ch;8f8+l1NH~v(O*r`X zgb1HdAOE@keYP&{*b%Yj;M{v5 zsrv!>$Nn7=_vaY@Bk<14Ef+Uah`9CeI>1HT|K3{t|Daz?UJ=o|ul$DoU#aZ>8}#3j ziXYJDPE!nL%O8s)V$Z&bb%1A~aO%|kkn|8vp+D{sr}EE4blueprint-scripts ${project.version} + + org.onap.ccsdk.apps.controllerblueprints + blueprint-validation + ${project.version} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 2647083f..aab4e7c7 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -118,16 +118,13 @@ or Node Template and used by orchestration engine to facilitate deployment and i class ArtifactDefinition { @get:JsonIgnore var id: String? = null - var type: String? = null - var file: String? = null + lateinit var type: String + lateinit var file: String var repository: String? = null var description: String? = null @get:JsonProperty("deploy_Path") var deployPath: String? = null var properties: MutableMap? = null - var content: String? = null - @Deprecated("Mapping content is define by the Type") - var mappingContent: String? = null } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt index bea790fd..a485c677 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -1,3 +1,20 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.ccsdk.apps.controllerblueprints.core.interfaces import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -18,6 +35,8 @@ interface BluePrintTopologyTemplateValidator : BluePrintValidator +interface BluePrintArtifactDefinitionValidator : BluePrintValidator + interface BluePrintDataTypeValidator : BluePrintValidator interface BluePrintNodeTypeValidator : BluePrintValidator @@ -45,12 +64,20 @@ interface BluePrintValidatorService { interface BluePrintTypeValidatorService { + fun > bluePrintValidator(referenceName: String, classType: Class): T? + + fun > bluePrintValidators(referenceNamePrefix: String, classType: Class): List? + + fun > bluePrintValidators(classType: Class): List? + fun getServiceTemplateValidators(): List fun getDataTypeValidators(): List fun getArtifactTypeValidators(): List + fun getArtifactDefinitionsValidators(): List + fun getNodeTypeValidators(): List fun getTopologyTemplateValidators(): List @@ -73,6 +100,12 @@ interface BluePrintTypeValidatorService { doValidation(bluePrintRuntimeService, name, artifactType, validators) } + fun validateArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, + artifactDefinition: ArtifactDefinition) { + val validators = getArtifactDefinitionsValidators() + doValidation(bluePrintRuntimeService, name, artifactDefinition, validators) + } + fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { val validators = getDataTypeValidators() doValidation(bluePrintRuntimeService, name, dataType, validators) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 76f3f329..1bc25005 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.node.ArrayNode @@ -148,22 +147,22 @@ class JacksonUtils { return objectMapper.valueToTree(any) } - fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + fun getListFromJsonNode(node: JsonNode, valueType: Class): List { return getListFromJson(node.toString(), valueType) } - fun getListFromJson(content: String, valueType: Class): List? { + fun getListFromJson(content: String, valueType: Class): List { val objectMapper = jacksonObjectMapper() val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) return objectMapper.readValue>(content, javaType) } - fun getListFromFile(fileName: String, valueType: Class): List? { + fun getListFromFile(fileName: String, valueType: Class): List { val content: String = getContent(fileName) return getListFromJson(content, valueType) } - fun getListFromClassPathFile(fileName: String, valueType: Class): List? { + fun getListFromClassPathFile(fileName: String, valueType: Class): List { val content: String = getClassPathFileContent(fileName) return getListFromJson(content, valueType) } diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt new file mode 100644 index 00000000..4ea5ab5b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt @@ -0,0 +1,97 @@ +/* + * Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +import java.io.File + +@Service("default-artifact-definition-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +open class BluePrintArtifactDefinitionValidatorImpl( + private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintContext: BluePrintContext + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, + artifactDefinition: ArtifactDefinition) { + + this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() + + paths.add(name) + val type: String = artifactDefinition.type + log.info("Validation ArtifactDefinition of type {$type}") + // Check Artifact Type + checkValidArtifactType(name, type) + + val file: String = artifactDefinition.file + + val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file) + + check(File(completePath).exists()) { + throw BluePrintException("couldn't file ($completePath)") + } + + // Perform Extension Validation + validateExtension("$type-artifact-definition-validator", name, artifactDefinition) + + paths.removeAt(paths.lastIndex) + } + + open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { + + val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + + checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") + } + } + + private fun validateExtension(referencePrefix: String, name: String, artifactDefinition: ArtifactDefinition) { + + val customValidators = bluePrintTypeValidatorService + .bluePrintValidators(referencePrefix, BluePrintArtifactDefinitionValidator::class.java) + + customValidators?.let { + it.forEach { validator -> + validator.validate(bluePrintRuntimeService, name, artifactDefinition) + } + + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt index b893c77d..4824d2e9 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.stereotype.Service +@Service("default-artifact-type-validator") open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { @@ -28,6 +31,5 @@ open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidator artifactType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!) } - // TODO ("Files Present ") } } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt index 19e8f0bf..11dbf058 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +17,72 @@ package org.onap.ccsdk.apps.controllerblueprints.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-attribute-definition-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) { - //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, + attributeDefinition: AttributeDefinition) { + + log.trace("Validating AttributeDefinition($name)") + this.bluePrintRuntimeService = bluePrintRuntimeService + val dataType: String = attributeDefinition.type + + when { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { + // Do Nothing + } + BluePrintTypes.validCollectionTypes().contains(dataType) -> { + val entrySchemaType: String = attributeDefinition.entrySchema?.type + ?: throw BluePrintException("Entry schema for DataType ($dataType) for the property ($name) not found") + checkPrimitiveOrComplex(entrySchemaType, name) + } + else -> checkPropertyDataType(dataType, name) + } + } + + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + return true + } else { + throw BluePrintException("DataType($dataType) for the attribute($propertyName) is not valid") + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + } + + private fun checkDataType(key: String): Boolean { + return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false + } + + open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ") + } } } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt index 6ee41774..1494bbc4 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +17,16 @@ package org.onap.ccsdk.apps.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.stereotype.Service +@Service("default-data-type-validator") open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { - log.trace("Validating DataType($name)") - dataType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt similarity index 87% rename from ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt rename to ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt index 5620cb77..84073ff2 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +24,14 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeVal import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.springframework.stereotype.Service import java.util.* -open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { +@Service +open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString()) override fun validateBluePrints(basePath: String): Boolean { diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt index af0f88aa..ded1f384 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +30,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-node-template-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) @@ -39,25 +45,28 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator lateinit var bluePrintContext: BluePrintContext var paths: MutableList = arrayListOf() - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - log.info("Validating NodeTemplate($nodeTemplateName)") + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { + log.info("Validating NodeTemplate($name)") this.bluePrintRuntimeService = bluePrintRuntimeService this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() - paths.add(nodeTemplateName) + paths.add(name) val type: String = nodeTemplate.type val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type) - ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)") + ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($name)") nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } - nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, name, nodeTemplate) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, name, nodeTemplate) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, name, nodeTemplate) } nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } + // Perform Extension Validation + validateExtension("$type-node-template-validator", name, nodeTemplate) + paths.removeAt(paths.lastIndex) } @@ -65,16 +74,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator open fun validateArtifactDefinitions(artifacts: MutableMap) { paths.add("artifacts") artifacts.forEach { artifactDefinitionName, artifactDefinition -> - paths.add(artifactDefinitionName) - val type: String = artifactDefinition.type - ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)") - // Check Artifact Type - checkValidArtifactType(artifactDefinitionName, type) - - val file: String = artifactDefinition.file - ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)") - - paths.removeAt(paths.lastIndex) + bluePrintTypeValidatorService.validateArtifactDefinition(bluePrintRuntimeService, + artifactDefinitionName, artifactDefinition) } paths.removeAt(paths.lastIndex) } @@ -239,21 +240,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator } - open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { - - val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") - - checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) - } - - @Throws(BluePrintException::class) - open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") - } - } - open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { val propertyType = propertyDefinition.type val isValid: Boolean @@ -295,4 +281,13 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator } } + private fun validateExtension(referencePrefix: String, name: String, nodeTemplate: NodeTemplate) { + val customValidator = bluePrintTypeValidatorService + .bluePrintValidator(referencePrefix, BluePrintNodeTemplateValidator::class.java) + + customValidator?.let { + it.validate(bluePrintRuntimeService, name, nodeTemplate) + } + } + } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt index eb2f0102..1108c1b5 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +27,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTyp import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-node-type-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) @@ -52,7 +58,14 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)") } - nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) } + nodeType.attributes?.let { + bluePrintTypeValidatorService.validateAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!) + } + + nodeType.properties?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) + } + nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt index 2f328716..7d81ba62 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-property-definition-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt index 8d49f291..37d3d1bd 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -26,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-service-template-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt index 9f9ad1fa..841d86ea 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +27,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-topology-template-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt index e9bfc613..d8c008ff 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.validation +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext @@ -24,43 +26,79 @@ import org.springframework.stereotype.Service @Service class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { + companion object { + const val PREFIX_DEFAULT = "default" + } + @Autowired private lateinit var context: ApplicationContext + override fun > bluePrintValidator(referenceName: String, classType: Class): T? { + return if (context.containsBean(referenceName)) { + context.getBean(referenceName, classType) + } else { + null + } + } + + override fun > bluePrintValidators(referenceNamePrefix: String, classType: Class): List? { + return context.getBeansOfType(classType) + .filter { it.key.startsWith(referenceNamePrefix) } + .mapNotNull { it.value } + } + + override fun > bluePrintValidators(classType: Class): List? { + return context.getBeansOfType(classType).mapNotNull { it.value } + } + override fun getServiceTemplateValidators(): List { - return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintServiceTemplateValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default ServiceTemplate validators") } override fun getDataTypeValidators(): List { - return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintDataTypeValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default DataType validators") } override fun getArtifactTypeValidators(): List { - return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactTypeValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default ArtifactType validators") + } + + override fun getArtifactDefinitionsValidators(): List { + return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactDefinitionValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default ArtifactDefinition validators") } override fun getNodeTypeValidators(): List { - return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTypeValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default NodeType validators") } override fun getTopologyTemplateValidators(): List { - return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintTopologyTemplateValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default TopologyTemplate validators") } override fun getNodeTemplateValidators(): List { - return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTemplateValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default NodeTemplate validators") } override fun getWorkflowValidators(): List { - return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintWorkflowValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default Workflow validators") } override fun getPropertyDefinitionValidators(): List { - return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintPropertyDefinitionValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default PropertyDefinition validators") } override fun getAttributeDefinitionValidators(): List { - return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } + return bluePrintValidators(PREFIX_DEFAULT, BluePrintAttributeDefinitionValidator::class.java) + ?: throw BluePrintProcessorException("failed to get default AttributeDefinition validators") } } diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt deleted file mode 100644 index 8e26588b..00000000 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("unused") -package org.onap.ccsdk.apps.controllerblueprints.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.springframework.stereotype.Service -import java.util.* - -@Service -class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintValidatorService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - - override fun validateBluePrints(basePath: String): Boolean { - - log.info("validating blueprint($basePath)") - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) - return validateBluePrints(bluePrintRuntimeService) - } - - override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { - - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", - bluePrintRuntimeService.bluePrintContext().serviceTemplate) - - if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { - throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") - } - return true - } -} - -// Core Validator Services - -@Service -class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt index 612ec691..851a7c60 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt @@ -23,7 +23,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Service +@Service("default-workflow-validator") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt new file mode 100644 index 00000000..6fe4fa36 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt @@ -0,0 +1,48 @@ +/* + * Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.validation.extension + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl +import org.springframework.stereotype.Service +import java.io.File + +@Service("artifact-mapping-resource-artifact-definition-validator") +open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintArtifactDefinitionValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(ArtifactMappingResourceValidator::class.toString()) + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, + artifactDefinition: ArtifactDefinition) { + + val bluePrintContext = bluePrintRuntimeService.bluePrintContext() + val file: String = artifactDefinition.file + val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file) + log.info("Validation artifact-mapping-resource($completePath)") + val resourceAssignment = JacksonUtils.getListFromFile(completePath, ResourceAssignment::class.java) + val resourceAssignmentValidationService = ResourceAssignmentValidationServiceImpl() + resourceAssignmentValidationService.validate(resourceAssignment) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt similarity index 96% rename from ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt rename to ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt index f5d157dd..43c3e0e3 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt @@ -30,12 +30,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtil import kotlin.test.assertEquals import kotlin.test.assertTrue -class BluePrintValidatorServiceImplTest { +class BluePrintDesignTimeValidatorServiceTest { private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() - private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) + private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService) private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService) @Test diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt index 971099ca..65574c22 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,18 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService { + override fun > bluePrintValidator(referenceName: String, classType: Class): T? { + return null + } + + override fun > bluePrintValidators(referenceNamePrefix: String, classType: Class): List? { + return null + } + + override fun > bluePrintValidators(classType: Class): List? { + return null + } + override fun getServiceTemplateValidators(): List { return listOf(BluePrintServiceTemplateValidatorImpl(this)) } @@ -32,6 +45,10 @@ class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService { return listOf(BluePrintArtifactTypeValidatorImpl(this)) } + override fun getArtifactDefinitionsValidators(): List { + return listOf(BluePrintArtifactDefinitionValidatorImpl(this)) + } + override fun getNodeTypeValidators(): List { return listOf(BluePrintNodeTypeValidatorImpl(this)) } 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 8d32413f..ccacee02 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 @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,22 +39,22 @@ import java.nio.file.Paths class BluePrintEnhancerServiceImplTest { @Autowired - private val modelTypeLoadService: ModelTypeLoadService? = null + lateinit var modelTypeLoadService: ModelTypeLoadService @Autowired - private val resourceDictionaryLoadService: ResourceDictionaryLoadService? = null + lateinit var resourceDictionaryLoadService: ResourceDictionaryLoadService @Autowired - private val bluePrintEnhancerService: BluePrintEnhancerService? = null + lateinit var bluePrintEnhancerService: BluePrintEnhancerService @Autowired - private val bluePrintValidatorService: BluePrintValidatorService? = null + lateinit var bluePrintValidatorService: BluePrintValidatorService @Before fun init() { runBlocking { - modelTypeLoadService!!.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type") - resourceDictionaryLoadService!!.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary") + modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type") + resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary") } } @@ -65,11 +66,11 @@ class BluePrintEnhancerServiceImplTest { val targetPath = Paths.get("target", "bp-enhance").toUri().path - val bluePrintContext = bluePrintEnhancerService!!.enhance(basePath, targetPath) + val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath) Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext) // Validate the Generated BluePrints - val valid = bluePrintValidatorService!!.validateBluePrints(targetPath) + val valid = bluePrintValidatorService.validateBluePrints(targetPath) Assert.assertTrue("blueprint validation failed ", valid) } } \ No newline at end of file -- 2.16.6