summaryrefslogtreecommitdiffstats
path: root/components/resource-dict
diff options
context:
space:
mode:
Diffstat (limited to 'components/resource-dict')
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt10
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt13
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java6
3 files changed, 14 insertions, 15 deletions
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 6d186b59..bcb7e7da 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<ResourceDefinition>
+ 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<ResourceDefinition> {
+ 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 9f45d166..9ed07732 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 6789c0e0..ac8cbcb4 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