summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt10
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt45
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt20
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt41
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt9
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt3
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/db-source.json)2
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/default-source.json)4
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/input-source.json)6
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json29
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json25
-rw-r--r--ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json (renamed from ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json)8
-rw-r--r--ms/controllerblueprints/application/src/test/resources/application.properties2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java23
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java)26
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt (renamed from components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt)3
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt50
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java17
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java6
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java10
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/application.properties4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json62
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json10
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json312
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json37
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/logback.xml5
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json9
29 files changed, 500 insertions, 284 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
index e25b3eea..a971898d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
@@ -16,6 +16,8 @@
package org.onap.ccsdk.apps.controllerblueprints.core
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+
/**
*
*
@@ -104,6 +106,7 @@ object BluePrintTypes {
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
+ validTypes.add(BluePrintConstants.DATA_TYPE_MAP)
return validTypes
}
@@ -128,6 +131,13 @@ object BluePrintTypes {
}
@JvmStatic
+ fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean {
+ val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL
+ return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type)
+ && BluePrintTypes.validPrimitiveTypes().contains(entrySchema)
+ }
+
+ @JvmStatic
fun validCommands(): List<String> {
return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,
BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt
deleted file mode 100644
index d796597b..00000000
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.factory
-
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-
-
-/**
- * BluePrintEnhancerFactory
- * @author Brinda Santh
- *
- */
-
-object BluePrintEnhancerFactory {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- var bluePrintEnhancerServices: MutableMap<String, BluePrintEnhancerService> = HashMap()
-
- fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) {
- bluePrintEnhancerServices[key] = bluePrintEnhancerService
- }
-
- /**
- * Called by clients to get a Blueprint Parser for the Blueprint parser type
- */
- fun instance(key: String): BluePrintEnhancerService? {
- return bluePrintEnhancerServices.get(key)
- }
-}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
index a7c14adf..dec7a50d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -35,19 +35,19 @@ import java.io.Serializable
interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
- fun getNodeType(nodeTypeName: String): Mono<NodeType>?
+ fun getNodeType(nodeTypeName: String): Mono<NodeType>
@Throws(BluePrintException::class)
- fun getDataType(dataTypeName: String): Mono<DataType>?
+ fun getDataType(dataTypeName: String): Mono<DataType>
@Throws(BluePrintException::class)
- fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?
+ fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>
@Throws(BluePrintException::class)
- fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?
+ fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>
@Throws(BluePrintException::class)
- fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?
+ fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>
}
@@ -63,30 +63,30 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic
private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
- override fun getDataType(dataTypeName: String): Mono<DataType>? {
+ override fun getDataType(dataTypeName: String): Mono<DataType> {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(dataTypeName).plus(extension)
return getModelType(fileName, DataType::class.java)
}
- override fun getNodeType(nodeTypeName: String): Mono<NodeType>? {
+ override fun getNodeType(nodeTypeName: String): Mono<NodeType> {
val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)
return getModelType(fileName, NodeType::class.java)
}
- override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>? {
+ override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(artifactTypeName).plus(extension)
return getModelType(fileName, ArtifactType::class.java)
}
- override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>? {
+ override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(relationshipTypeName).plus(extension)
return getModelType(fileName, RelationshipType::class.java)
}
- override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>? {
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(capabilityDefinitionName).plus(extension)
return getModelType(fileName, CapabilityDefinition::class.java)
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
deleted file mode 100644
index 8e6d5efd..00000000
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
+++ /dev/null
@@ -1,41 +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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.core.service
-
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils
-
-/**
- * BluePrintEnhancerServiceTest
- * @author Brinda Santh
- *
- */
-
-class BluePrintEnhancerServiceTest {
- val basePath = "load/model_type"
-
- @Test
- fun testEnrichBlueprint() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
- val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)
-
- val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")
- bluePrintEnhancerService.enhance(serviceTemplate)
-
- }
-} \ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
index fae509d2..089fce0b 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -25,6 +25,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
import java.io.Serializable
/**
@@ -65,6 +67,13 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida
open fun validateSources(resourceAssignments: List<ResourceAssignment>) {
log.info("validating resource assignment sources")
+ resourceAssignments.forEach { resourceAssignment ->
+ try {
+ ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!)
+ } catch (e: BluePrintException) {
+ validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name))
+ }
+ }
}
open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) {
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 370e1ec8..6c83e5f9 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
@@ -18,11 +18,13 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
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.resource.dict.ResourceDefinition
import reactor.core.publisher.Mono
+
/**
* ResourceDefinitionRepoService.
*
@@ -30,6 +32,7 @@ import reactor.core.publisher.Mono
*/
interface ResourceDefinitionRepoService : BluePrintRepoService {
+ @Throws(BluePrintException::class)
fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>
}
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json
index a0c78af0..90775aee 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json
@@ -1,5 +1,5 @@
{
- "name": "db-source",
+ "name": "sample-db-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json
index 64bfa0cc..395b0ddd 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json
@@ -1,6 +1,6 @@
{
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "default-source",
+ "tags": "sample-default-source",
+ "name": "sample-default-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json
index acfad16b..73c0d408 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json
@@ -1,16 +1,16 @@
{
- "name": "input-source",
+ "name": "sample-input-source",
"property" :{
"description": "name of the ",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "action-name, brindasanth",
+ "tags": "sample-input-source",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "action-name"
+ "key": "input-source"
}
}
}
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json
new file mode 100644
index 00000000..5834dd49
--- /dev/null
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json
@@ -0,0 +1,29 @@
+{
+ "tags": "sample-licenses",
+ "name": "sample-licenses",
+ "property": {
+ "description" : " Sample Data for licences",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-license-key"
+ }
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/",
+ "path": "/licenses",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "licenses": "licenses"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json
new file mode 100644
index 00000000..25464d3f
--- /dev/null
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json
@@ -0,0 +1,25 @@
+{
+ "tags": "sample-mdsal-source",
+ "name": "sample-mdsal-source",
+ "property": {
+ "description": "Sample sample-mdsal-source",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "mdsal-source": "v4-ip-prefix"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json
index 1b4432d5..055279c1 100644
--- a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json
+++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json
@@ -1,16 +1,16 @@
{
- "name": "v4-ip-type",
+ "name": "sample-v4-ip-type",
"property": {
- "description": "name of the ",
+ "description": "sample-v4-ip-type",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "v4-ip-type, source-input, brindasanth",
+ "tags": "sample-v4-ip-type",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "v4-ip-type"
+ "key": "sample-v4-ip-type"
}
}
}
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties
index e2d040c2..5c6acf93 100644
--- a/ms/controllerblueprints/application/src/test/resources/application.properties
+++ b/ms/controllerblueprints/application/src/test/resources/application.properties
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+spring.main.banner-mode=off
+
appName=ControllerBluePrints
ms_name=org.onap.ccsdk.apps.controllerblueprints
appVersion=1.0.0
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
index 8e98f947..ef3b4a48 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -25,12 +25,13 @@ import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -48,14 +49,18 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
+ private ResourceAssignmentEnhancerService resourceAssignmentEnhancerService;
+
private Map<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
- super(bluePrintEnhancerRepoDBService);
+ public BluePrintEnhancerService(ResourceDefinitionRepoService resourceDefinitionRepoService,
+ ResourceAssignmentEnhancerService resourceAssignmentEnhancerService) {
+ super(resourceDefinitionRepoService);
+ this.resourceAssignmentEnhancerService = resourceAssignmentEnhancerService;
}
@Override
- public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException {
super.enrichTopologyTemplate(serviceTemplate);
// Update the Recipe Inputs and DataTypes
@@ -101,7 +106,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
// Modified for ONAP converted Object to JsonNode
JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES);
- log.info("Processing Receipe Names : {} ", recipeNames);
+ log.info("Processing Recipe Names : {} ", recipeNames);
if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) {
@@ -159,6 +164,9 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent);
+ // Enhance Resource Assignment
+ resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments);
+
dataTypeProperties = new HashMap<>();
for (ResourceAssignment resourceAssignment : resourceAssignments) {
@@ -167,9 +175,6 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
&& resourceAssignment.getProperty() != null
&& StringUtils.isNotBlank(resourceAssignment.getName())) {
- // Enrich the Property Definition
- super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty());
-
dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty());
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java
index 5510e480..16cc8415 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java
@@ -23,28 +23,35 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-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 org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import java.util.Optional;
/**
- * BluePrintRepoDBService
+ * ResourceDefinitionRepoDBService
*
* @author Brinda Santh
*/
@Service
@SuppressWarnings("unused")
-public class BluePrintRepoDBService implements BluePrintRepoService {
+public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoService {
private ModelTypeRepository modelTypeRepository;
+ private ResourceDictionaryRepository resourceDictionaryRepository;
+
@SuppressWarnings("unused")
- public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
+ public ResourceDefinitionRepoDBService(ModelTypeRepository modelTypeRepository,
+ ResourceDictionaryRepository resourceDictionaryRepository) {
this.modelTypeRepository = modelTypeRepository;
+ this.resourceDictionaryRepository = resourceDictionaryRepository;
}
@Override
@@ -72,6 +79,17 @@ public class BluePrintRepoDBService implements BluePrintRepoService {
return getModelType(capabilityDefinitionName, CapabilityDefinition.class);
}
+ @NotNull
+ @Override
+ public Mono<ResourceDefinition> getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException{
+ Optional<ResourceDictionary> dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName);
+ if(dbResourceDictionary.isPresent()){
+ return Mono.just(dbResourceDictionary.get().getDefinition());
+ }else{
+ throw new BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName));
+ }
+ }
+
private <T> Mono<T> getModelType(String modelName, Class<T> valueClass) throws BluePrintException {
Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
"Failed to get model from repo, model name is missing");
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
index b125c594..cf9e96e7 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.core.service
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import java.io.Serializable
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
index 0d08985a..de6f82ff 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
@@ -19,13 +19,16 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService
+import org.springframework.stereotype.Service
/**
* ResourceAssignmentEnhancerService.
@@ -47,6 +50,7 @@ interface ResourceAssignmentEnhancerService {
*
* @author Brinda Santh
*/
+@Service
open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
: ResourceAssignmentEnhancerService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
@@ -58,20 +62,41 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti
override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
resourceAssignments: List<ResourceAssignment>) {
+ val uniqueSourceNodeTypeNames = hashSetOf<String>()
+
// Iterate the Resource Assignment and
resourceAssignments.map { resourceAssignment ->
val dictionaryName = resourceAssignment.dictionaryName!!
val dictionarySource = resourceAssignment.dictionarySource!!
- log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
+ log.debug("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
dictionaryName, dictionarySource)
- // Get the Resource Definition from Repo
- val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+ val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)
+
+ // Add Unique Node Types
+ uniqueSourceNodeTypeNames.add(sourceNodeTypeName)
+
+ // TODO("Candidate for Optimisation")
+ if (checkResourceDefinitionNeeded(resourceAssignment)) {
+
+ bluePrintEnhancerService.enrichPropertyDefinition(resourceAssignment.name, resourceAssignment.property!!);
+
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
- val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
- // Enrich as NodeTemplate
- bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate)
+ }
}
+ // Enrich the ResourceSource NodeTypes
+ uniqueSourceNodeTypeNames.map { nodeTypeName ->
+ resourceDefinitionRepoService.getNodeType(nodeTypeName).subscribe { nodeType ->
+ bluePrintEnhancerService.enrichNodeType(nodeTypeName, nodeType)
+ }
+ }
+
}
override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
@@ -82,7 +107,14 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti
return bluePrintEnhancerService.serviceTemplate
}
+ private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
+ return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
+ || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
+ && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!))
+ }
+
private fun getResourceDefinition(name: String): ResourceDefinition {
- return resourceDefinitionRepoService.getResourceDefinition(name).block()!!
+ return resourceDefinitionRepoService.getResourceDefinition(name).block()
+ ?: throw BluePrintException(format("failed to get dictionary definition({})", name))
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
index 7d16f50f..e279ec9c 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
@@ -16,12 +16,17 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
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.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionFileRepoService;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
@@ -33,18 +38,28 @@ import java.util.List;
* @author Brinda Santh
*/
public class ResourceAssignmentEnhancerServiceTest {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class);
+
+ @Before
+ public void setUp(){
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
+ }
@Test
public void testEnhanceBluePrint() throws BluePrintException {
List<ResourceAssignment> resourceAssignments = JacksonReactorUtils
- .getListFromClassPathFile("enhance/simple-enrich.json", ResourceAssignment.class).block();
+ .getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class).block();
Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load");
ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =
new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);
ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
+ log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true));
}
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
index ab939ffa..b2e29018 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 IBM.
+ * Modifications Copyright © 2017-2018 AT&T Intellectual Property.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@
package org.onap.ccsdk.apps.controllerblueprints.service.repository;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest {
@Test
@Commit
public void test01Save() {
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/db-source" +
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/sample-db-source" +
".json", ResourceDefinition.class);
Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition);
resourceDefinition.setName(sourceName);
@@ -88,7 +88,7 @@ public class ResourceDictionaryReactRepositoryTest {
@Test
@Commit
public void test05Delete() {
- resourceDictionaryReactRepository.deleteByName("db-source").block();
+ resourceDictionaryReactRepository.deleteByName(sourceName).block();
}
private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
index ac786d0e..272cdd08 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
@@ -42,7 +42,7 @@ import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResourceDictionaryRestTest {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
index faa10825..37cc61d1 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java
@@ -45,7 +45,7 @@ import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ServiceTemplateRestTest {
@@ -143,7 +143,7 @@ public class ServiceTemplateRestTest {
List<ResourceAssignment> autoMappedResourceAssignment = autoMapResponse.getResourceAssignments();
autoMappedResourceAssignment.forEach(resourceAssignment -> {
- if ("bundle-id".equals(resourceAssignment.getName())) {
+ if ("sample-db-source".equals(resourceAssignment.getName())) {
Assert.assertEquals("Failed to assign default first source", "db",
resourceAssignment.getDictionarySource());
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
index 46b725f8..5f34b551 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java
@@ -19,9 +19,11 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -33,6 +35,14 @@ import java.util.List;
public class ServiceTemplateValidationTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);
+ @Before
+ public void setUp(){
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
+ }
+
@Test
public void testBluePrintDirs() {
List<String> dirs = ConfigModelUtils.getBlueprintNames("load/blueprints");
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index 3a913b70..397f3b13 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+spring.main.banner-mode=off
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
@@ -23,7 +23,7 @@ logging.level.org.hibernate.SQL=warn
logging.level.org.hibernate.type.descriptor.sql=debug
-blueprints.load.initial-data=true
+blueprints.load.initial-data=false
load.dataTypePath=./../../application/load/model_type/data_type
load.nodeTypePath=./../../application/load/model_type/node_type
load.artifactTypePath=./../../application/load/model_type/artifact_type
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json
new file mode 100644
index 00000000..3715beca
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json
@@ -0,0 +1,62 @@
+[
+ {
+ "name": "rs-db-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-db-source",
+ "dictionary-source": "db",
+ "dependencies": [
+ "input-source"
+ ]
+ },
+ {
+ "name": "ra-default-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-default-source",
+ "dictionary-source": "default",
+ "dependencies": []
+ },
+ {
+ "name": "ra-input-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-list-input-source",
+ "input-param": true,
+ "property": {
+ "type": "list",
+ "required": true,
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "dictionary-name": "ra-list-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-complex-input-source",
+ "input-param": true,
+ "property": {
+ "type": "dt-v4-aggregate",
+ "required": true
+ },
+ "dictionary-name": "sample-mdsal-source",
+ "dictionary-source": "mdsal",
+ "dependencies": []
+ }
+]
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
index 70d03e0a..782ed505 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
@@ -218,13 +218,13 @@
"properties": {
"mapping": [
{
- "name": "bundle-mac",
+ "name": "rs-db-source",
"property": {
"required": true,
"type": "string"
},
"input-param": false,
- "dictionary-name": "bundle-mac",
+ "dictionary-name": "sample-db-source",
"dictionary-source": "db",
"dependencies": [
"hostname"
@@ -232,7 +232,7 @@
"version": 0
},
{
- "name": "wan-aggregate-ipv4-addresses",
+ "name": "mdsal-source",
"property": {
"description": "",
"required": true,
@@ -242,7 +242,7 @@
}
},
"input-param": false,
- "dictionary-name": "wan-aggregate-ipv4-addresses",
+ "dictionary-name": "sample-mdsal-source",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
@@ -313,7 +313,7 @@
}
},
"input-param": false,
- "dictionary-name": "licenses",
+ "dictionary-name": "sample-licenses",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
index bf3deffb..531d756b 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
@@ -114,10 +114,6 @@
"description" : "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.",
"version" : "1.0.0",
"properties" : {
- "bundle-mac" : {
- "required" : true,
- "type" : "string"
- },
"hostname" : {
"required" : true,
"type" : "string"
@@ -129,13 +125,9 @@
"type" : "dt-license-key"
}
},
- "wan-aggregate-ipv4-addresses" : {
- "description" : "",
+ "rs-db-source" : {
"required" : true,
- "type" : "list",
- "entry_schema" : {
- "type" : "dt-v4-aggregate"
- }
+ "type" : "string"
},
"service" : {
"required" : true,
@@ -144,6 +136,14 @@
"service-instance-id" : {
"required" : true,
"type" : "string"
+ },
+ "mdsal-source" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
}
},
"derived_from" : "tosca.datatypes.Dynamic"
@@ -206,6 +206,127 @@
"version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
+ "artifact-config-template" : {
+ "description" : "This is Configuration Velocity Template",
+ "version" : "1.0.0",
+ "properties" : {
+ "action-names" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "capabilities" : {
+ "content" : {
+ "type" : "tosca.capabilities.Content",
+ "properties" : {
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ },
+ "mapping" : {
+ "type" : "tosca.capabilities.Mapping",
+ "properties" : {
+ "mapping" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-resource-assignment"
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Artifact"
+ },
+ "tosca.nodes.Vnf" : {
+ "description" : "This is VNF Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Artifact" : {
+ "description" : "This is Deprecated Artifact Node Type.",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "dg-activate-netconf" : {
+ "description" : "This is Download Netconf Directed Graph",
+ "version" : "1.0.0",
+ "properties" : {
+ "mode" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "sync"
+ },
+ "version" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "LATEST"
+ },
+ "is-start-flow" : {
+ "required" : false,
+ "type" : "boolean",
+ "default" : false
+ }
+ },
+ "capabilities" : {
+ "dg-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "component-netconf-executor",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ },
+ "source-input" : {
+ "description" : "This is Input Resource Source Node Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "key" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
+ },
+ "tosca.nodes.ResourceSource" : {
+ "description" : "TOSCA base type for Resource Sources",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"component-resource-assignment" : {
"description" : "This is Resource Assignment Component API",
"version" : "1.0.0",
@@ -279,42 +400,44 @@
"version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
- "artifact-config-template" : {
- "description" : "This is Configuration Velocity Template",
+ "source-db" : {
+ "description" : "This is Database Resource Source Node Type",
"version" : "1.0.0",
"properties" : {
- "action-names" : {
+ "type" : {
"required" : true,
- "type" : "list",
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "SQL", "PLSQL" ]
+ } ]
+ },
+ "query" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
"entry_schema" : {
"type" : "string"
}
- }
- },
- "capabilities" : {
- "content" : {
- "type" : "tosca.capabilities.Content",
- "properties" : {
- "content" : {
- "required" : true,
- "type" : "string"
- }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
}
},
- "mapping" : {
- "type" : "tosca.capabilities.Mapping",
- "properties" : {
- "mapping" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-resource-assignment"
- }
- }
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
}
}
},
- "derived_from" : "tosca.nodes.Artifact"
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"vnf-netconf-device" : {
"description" : "This is VNF Device with Netconf Capability",
@@ -357,10 +480,57 @@
},
"derived_from" : "tosca.nodes.Vnf"
},
- "tosca.nodes.Vnf" : {
- "description" : "This is VNF Node Type",
+ "source-rest" : {
+ "description" : "This is Rest Resource Source Node Type",
"version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
+ "properties" : {
+ "type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON" ]
+ } ],
+ "default" : "JSON"
+ },
+ "url-path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "expression-type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON_PATH", "JSON_POINTER" ]
+ } ],
+ "default" : "JSON_PATH"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"component-netconf-executor" : {
"description" : "This is Netconf Transaction Configuration Component API",
@@ -440,62 +610,6 @@
}
},
"derived_from" : "tosca.nodes.Component"
- },
- "tosca.nodes.Artifact" : {
- "description" : "This is Deprecated Artifact Node Type.",
- "version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
- },
- "dg-activate-netconf" : {
- "description" : "This is Download Netconf Directed Graph",
- "version" : "1.0.0",
- "properties" : {
- "mode" : {
- "required" : false,
- "type" : "string",
- "default" : "sync"
- },
- "version" : {
- "required" : false,
- "type" : "string",
- "default" : "LATEST"
- },
- "is-start-flow" : {
- "required" : false,
- "type" : "boolean",
- "default" : false
- }
- },
- "capabilities" : {
- "dg-node" : {
- "type" : "tosca.capabilities.Node"
- }
- },
- "requirements" : {
- "component-dependency" : {
- "capability" : "component-node",
- "node" : "component-netconf-executor",
- "relationship" : "tosca.relationships.DependsOn"
- }
- },
- "interfaces" : {
- "CONFIG" : {
- "operations" : {
- "ActivateNetconf" : {
- "inputs" : {
- "params" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-property"
- }
- }
- }
- }
- }
- }
- },
- "derived_from" : "tosca.nodes.DG"
}
},
"topology_template" : {
@@ -704,18 +818,18 @@
"mapping" : {
"properties" : {
"mapping" : [ {
- "name" : "bundle-mac",
+ "name" : "rs-db-source",
"property" : {
"required" : true,
"type" : "string"
},
"input-param" : false,
- "dictionary-name" : "bundle-mac",
+ "dictionary-name" : "sample-db-source",
"dictionary-source" : "db",
"dependencies" : [ "hostname" ],
"version" : 0
}, {
- "name" : "wan-aggregate-ipv4-addresses",
+ "name" : "mdsal-source",
"property" : {
"description" : "",
"required" : true,
@@ -725,7 +839,7 @@
}
},
"input-param" : false,
- "dictionary-name" : "wan-aggregate-ipv4-addresses",
+ "dictionary-name" : "sample-mdsal-source",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
@@ -787,7 +901,7 @@
}
},
"input-param" : false,
- "dictionary-name" : "licenses",
+ "dictionary-name" : "sample-licenses",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json
deleted file mode 100644
index 641da80a..00000000
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json
+++ /dev/null
@@ -1,37 +0,0 @@
-[
- {
- "name": "rs-db-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "db-source",
- "dictionary-source": "db",
- "dependencies": [
- "input-source"
- ]
- },
- {
- "name": "ra-default-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "default-source",
- "dictionary-source": "default",
- "dependencies": []
- },
- {
- "name": "ra-input-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "input-source",
- "dictionary-source": "input",
- "dependencies": []
- }
-]
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
index 4a04cfdc..7b7ef756 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
@@ -1,5 +1,6 @@
<!--
~ Copyright © 2018 IBM.
+ ~ Modifications Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -27,8 +28,8 @@
</appender>
- <logger name="org.springframework" level="info"/>
- <logger name="org.springframework.web" level="info"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.springframework.web" level="warn"/>
<logger name="org.hibernate" level="error"/>
<logger name="org.onap.ccsdk.apps" level="info"/>
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
index 5a2a4ec0..c6dd7948 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json
@@ -1,11 +1,14 @@
[
{
- "name": "input-source"
+ "name": "sample-input-source"
},
{
- "name": "v4-ip-type"
+ "name": "sample-default-source"
},
{
- "name": "db-source"
+ "name": "sample-db-source"
+ },
+ {
+ "name": "sample-mdsal-source"
}
] \ No newline at end of file