From 97fc5fa09de5e349ba1dee9a584a9d525c552d06 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 11 Dec 2018 19:40:51 -0500 Subject: Implement Enhancer Framework Interfaces Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../resource/dict/service/ResourceDefinitionRepoService.kt | 10 +++++----- .../dict/service/ResourceDefinitionValidationService.kt | 13 ++++++------- .../dict/service/ResourceDefinitionRepoServiceTest.java | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'components/resource-dict') diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index 6d186b598..bcb7e7da7 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -21,9 +21,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import reactor.core.publisher.Mono /** * ResourceDefinitionRepoService. @@ -33,7 +32,7 @@ import reactor.core.publisher.Mono interface ResourceDefinitionRepoService : BluePrintRepoService { @Throws(BluePrintException::class) - fun getResourceDefinition(resourceDefinitionName: String): Mono + fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition } /** @@ -57,11 +56,12 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary") } - override fun getResourceDefinition(resourceDefinitionName: String): Mono { + override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition { val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER) .plus(resourceDefinitionName).plus(extension) - return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java) + return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java) + ?: throw BluePrintException("couldn't get resource definition for file($fileName)") } } diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 9f45d1666..9ed077323 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -30,8 +31,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpression import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import com.att.eelf.configuration.EELFManager import java.io.Serializable + /** * ResourceDefinitionValidationService. * @@ -43,6 +44,7 @@ interface ResourceDefinitionValidationService : Serializable { fun validate(resourceDefinition: ResourceDefinition) } + /** * ResourceDefinitionValidationService. * @@ -59,8 +61,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS resourceDefinition.sources.forEach { (name, nodeTemplate) -> val sourceType = nodeTemplate.type - val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block() - ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType)) + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType) // Validate Property Name, expression, values and Data Type validateNodeTemplateProperties(nodeTemplate, sourceNodeType) @@ -91,7 +92,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) { val propertyType = propertyDefinition.type - val isValid : Boolean + val isValid: Boolean if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) @@ -100,9 +101,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) } else { - bluePrintRepoService.getDataType(propertyType).block() - ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository", - propertyName, propertyType)) + bluePrintRepoService.getDataType(propertyType) isValid = true } diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java index 6789c0e0e..ac8cbcb43 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -24,13 +24,13 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition public class ResourceDefinitionRepoServiceTest { @Test - public void testGetResourceDefinition() throws Exception{ + public void testGetResourceDefinition() throws Exception { ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog"); ResourceDefinition resourceDefinition = resourceDefinitionRepoService - .getResourceDefinition("db-source").block(); + .getResourceDefinition("db-source"); Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition); - NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block(); + NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db"); Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition); } } \ No newline at end of file -- cgit 1.2.3-korg