diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-08-31 19:52:48 +0000 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-08-31 19:52:48 +0000 |
commit | 62cc10e56d33d0399f810c556470f3ad39361ae7 (patch) | |
tree | 87c6406d90e71b86e44bf1cefa81683a03b53005 /ms/controllerblueprints/modules/resource-dict | |
parent | 8fa6853463959ccc7a2215b0f43d4822a2f630b6 (diff) |
Controller Blueprints Microservice
Add resource assignment enhancer, resource definition repo functions and code improvements.
Change-Id: I751bf8149a36f80c20d48b86344cd6bd3054ed21
Issue-ID: CCSDK-431
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict')
17 files changed, 297 insertions, 21 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json index c53a6dd3..92b16a21 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json @@ -1,5 +1,5 @@ {
- "name": "bundle-id",
+ "name": "db-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json index 91921b64..1c47f37b 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json @@ -1,6 +1,6 @@ {
"tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "v4-ip-type",
+ "name": "default-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json index c34c252b..676d92f8 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json @@ -1,5 +1,5 @@ {
- "name": "action-name",
+ "name": "input-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json index 413d9044..b49146a0 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json @@ -1,6 +1,6 @@ {
"tags": "oam-local-ipv4-address",
- "name": "oam-local-ipv4-address",
+ "name": "mdsal-source",
"property" :{
"description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index 9b89f6f4..aa6a9fb6 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -25,6 +25,8 @@ object ResourceDictionaryConstants { const val SOURCE_DEFAULT = "default" const val SOURCE_DB = "db" + const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" + const val PROPERTY_TYPE = "type" const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt new file mode 100644 index 00000000..c5a78a9c --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt @@ -0,0 +1,86 @@ +/*
+ * 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.resource.dict.service
+
+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
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceAssignmentEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>)
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate
+}
+
+/**
+ * ResourceAssignmentEnhancerDefaultService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
+ : ResourceAssignmentEnhancerService {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
+
+ /**
+ * Get the defined source instance from the ResourceAssignment,
+ * then get the NodeType of the Sources assigned
+ */
+ override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>) {
+
+ // 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,
+ dictionaryName, dictionarySource)
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ }
+ }
+
+ override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
+ val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService)
+ bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
+ bluePrintEnhancerService.initialCleanUp()
+ enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
+ return bluePrintEnhancerService.serviceTemplate
+ }
+
+ private fun getResourceDefinition(name: String): ResourceDefinition {
+ return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!!
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 4578aca7..228b39e2 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -16,13 +16,14 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service +import com.att.eelf.configuration.EELFLogger import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder 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 org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager import java.io.Serializable /** @@ -42,7 +43,7 @@ interface ResourceAssignmentValidationService : Serializable { * @author Brinda Santh */ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService { - private val log = LoggerFactory.getLogger(ResourceAssignmentValidationDefaultService::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf() open val validationMessage = StrBuilder() diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt new file mode 100644 index 00000000..d51338ca --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -0,0 +1,61 @@ +/*
+ * 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.resource.dict.service
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+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.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceDefinitionRepoService : BluePrintRepoService {
+
+ fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>?
+}
+
+/**
+ * ResourceDefinitionFileRepoService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,
+ ResourceDefinitionRepoService {
+
+ private var resourceDefinitionPath: String
+ private val extension = ".json"
+
+ constructor(basePath: String) : this(basePath,
+ basePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE))
+
+ constructor(basePath: String, modelTypePath: String) : super(modelTypePath) {
+ resourceDefinitionPath = basePath.plus("/resource_dictionary")
+ }
+
+ override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>? {
+
+ val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(resourceDefinitionName).plus(extension)
+
+ return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 1defa538..14855d4b 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service +import com.att.eelf.configuration.EELFLogger import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -29,7 +30,7 @@ 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 org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager import java.io.Serializable /** * ResourceDefinitionValidationService. @@ -49,7 +50,7 @@ interface ResourceDefinitionValidationService : Serializable { */ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { - private val log = LoggerFactory.getLogger(ResourceDefinitionValidationService::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) override fun validate(resourceDefinition: ResourceDefinition) { Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt index 82fbd3ac..747639c8 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -16,10 +16,11 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+import com.att.eelf.configuration.EELFLogger
import org.apache.commons.collections.CollectionUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
import java.util.ArrayList
/**
* BulkResourceSequencingUtils.
@@ -27,7 +28,7 @@ import java.util.ArrayList * @author Brinda Santh
*/
object BulkResourceSequencingUtils {
- private val log = LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java)
@JvmStatic
fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> {
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index 733a443f..a3456cd4 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -16,6 +16,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils +import com.att.eelf.configuration.EELFLogger import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils @@ -25,11 +26,11 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants -import org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager object ResourceDictionaryUtils { - private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) @JvmStatic fun populateSourceMapping(resourceAssignment: ResourceAssignment, diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index 3e68d099..fde80005 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -20,12 +20,12 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict; import org.junit.Assert;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
public class ResourceDefinitionTest {
- private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class);
- String basePath = "load/resource_dictionary";
+ private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class);
+ private String basePath = "load/resource_dictionary";
@Test
public void testDictionaryDefinitionInputSource(){
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java new file mode 100644 index 00000000..57c8509d --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java @@ -0,0 +1,48 @@ +/*
+ * 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.resource.dict.service;
+
+import org.junit.Assert;
+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.resource.dict.ResourceAssignment;
+
+import java.util.List;
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+public class ResourceAssignmentEnhancerServiceTest {
+
+ @Test
+ public void testEnhanceBluePrint() throws BluePrintException {
+
+ List<ResourceAssignment> resourceAssignments = JacksonReactorUtils
+ .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block();
+ Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
+ ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");
+ ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =
+ new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);
+ ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
+ Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
+ }
+}
+
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 4d8301f4..6216d5bf 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -16,19 +16,20 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+import com.att.eelf.configuration.EELFLogger
import org.junit.Assert
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
/**
* ResourceAssignmentValidationServiceTest.
*
* @author Brinda Santh
*/
class ResourceAssignmentValidationServiceTest {
- private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java)
@Test
fun testValidateSuccess() {
log.info("**************** testValidateSuccess *****************")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java new file mode 100644 index 00000000..1772277d --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -0,0 +1,36 @@ +/*
+ * 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.resource.dict.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+
+public class ResourceDefinitionRepoServiceTest {
+
+ @Test
+ public void testGetResourceDefinition() throws Exception{
+ ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");
+ ResourceDefinition resourceDefinition = resourceDefinitionRepoService
+ .getResourceDefinition("db-source").block();
+ Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);
+
+ NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();
+ Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index 5ee56171..13bf8195 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -27,8 +27,8 @@ 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.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.util.HashMap;
import java.util.Map;
@@ -38,12 +38,13 @@ import java.util.Map; * @author Brinda Santh
*/
public class ResourceDictionaryUtilsTest {
- private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);
@Test
public void testPopulateSourceMapping() {
ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("sample-assignment");
ResourceDefinition resourceDefinition = new ResourceDefinition();
Map<String, NodeTemplate> sources = new HashMap<>();
resourceDefinition.setSources(sources);
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json new file mode 100644 index 00000000..641da80a --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json @@ -0,0 +1,37 @@ +[
+ {
+ "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": []
+ }
+]
|