From 9039b516eaa55a08d2f97ef290c17de781e13ae2 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Fri, 30 Aug 2019 13:57:57 -0400 Subject: Refactor handlers, services to designer api. Change-Id: I3bc56e14fca332c0c0b661bb7e8a501a2dadbe91 Issue-ID: CCSDK-1663 Signed-off-by: Brinda Santh --- .../service/AutoResourceMappingService.kt | 174 ---------- .../service/BluePrintRepoServiceImpl.kt | 105 ------ .../ControllerBlueprintExceptionHandler.kt | 57 ---- .../service/controller/ModelTypeController.kt | 58 ---- .../controller/ResourceDictionaryController.kt | 69 ---- .../service/handler/ModelTypeHandler.kt | 122 ------- .../service/handler/ResourceDictionaryHandler.kt | 147 --------- .../repository/BluePrintsReactRepository.kt | 76 ----- .../service/repository/ModelTypeRepository.kt | 85 ----- .../repository/ResourceDictionaryRepository.kt | 66 ---- .../service/utils/BluePrintEnhancerUtils.kt | 164 ---------- .../service/validator/ModelTypeValidator.kt | 83 ----- .../repository/ModelTypeReactRepositoryTest.java | 110 ------- .../service/ModelTypeServiceTest.kt | 138 -------- .../service/controller/ModelTypeControllerTest.kt | 120 ------- .../controller/ResourceDictionaryControllerTest.kt | 43 --- .../service/controller/mock/MockFilePart.kt | 53 ---- .../repository/ResourceDictionaryRepositoryTest.kt | 94 ------ .../service/utils/BluePrintEnhancerUtilsTest.kt | 66 ---- .../service/validator/ModelTypeValidatorTest.kt | 40 --- .../enhance/enhance-resource-assignment.json | 62 ---- .../test/resources/enhance/enhance-template.json | 351 --------------------- .../test/resources/enhance/enhanced-template.json | 327 ------------------- .../model_type/data_type/datatype-property.json | 27 -- .../test/resources/resourcedictionary/automap.json | 14 - .../resourcedictionary/default_definition.json | 17 - 26 files changed, 2668 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ControllerBlueprintExceptionHandler.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/BluePrintsReactRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidator.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/mock/MockFilePart.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidatorTest.kt delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json (limited to 'ms/controllerblueprints/modules') diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.kt deleted file mode 100644 index 3ab9fee58..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.kt +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Huawei. - * - * 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.cds.controllerblueprints.service - -import com.google.common.base.Preconditions -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary -import org.onap.ccsdk.cds.controllerblueprints.service.model.AutoMapResponse -import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Service -import java.util.* - -@Service -open class AutoResourceMappingService(private val dataDictionaryRepository: ResourceDictionaryRepository) { - - private val log = LoggerFactory.getLogger(AutoResourceMappingService::class.java) - - @Throws(BluePrintException::class) - fun autoMap(resourceAssignments: MutableList): - AutoMapResponse { - val autoMapResponse = AutoMapResponse() - try { - if (CollectionUtils.isNotEmpty(resourceAssignments)) { - // Create the Dictionary definitions for the ResourceAssignment Names - val dictionaryMap = getDictionaryDefinitions(resourceAssignments) - - for (resourceAssignment in resourceAssignments) { - if (StringUtils.isNotBlank(resourceAssignment.name) - && StringUtils.isBlank(resourceAssignment.dictionaryName)) { - populateDictionaryMapping(dictionaryMap, resourceAssignment) - log.info("Mapped Resource : {}", resourceAssignment) - } - } - } - val dictionaries = getDictionaryDefinitionsList(resourceAssignments) - val resourceAssignmentsFinal = getAllAutoMapResourceAssignments(resourceAssignments) - autoMapResponse.dataDictionaries = dictionaries - autoMapResponse.resourceAssignments = resourceAssignmentsFinal - } catch (e: Exception) { - log.error(String.format("Failed in auto process %s", e.message)) - throw BluePrintException(e, e.message!!) - } - - return autoMapResponse - } - - private fun populateDictionaryMapping(dictionaryMap: Map, resourceAssignment: ResourceAssignment) { - val dbDataDictionary = dictionaryMap[resourceAssignment.name] - if (dbDataDictionary != null && dbDataDictionary.definition != null) { - - val dictionaryDefinition = dbDataDictionary.definition - - if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.name) - && StringUtils.isBlank(resourceAssignment.dictionaryName)) { - - resourceAssignment.dictionaryName = dbDataDictionary.name - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition) - } - } - } - - private fun getDictionaryDefinitions(resourceAssignments: List): Map { - val dictionaryMap = HashMap() - val names = ArrayList() - for (resourceAssignment in resourceAssignments) { - if (StringUtils.isNotBlank(resourceAssignment.name)) { - names.add(resourceAssignment.name) - } - } - if (CollectionUtils.isNotEmpty(names)) { - - val dictionaries = dataDictionaryRepository.findByNameIn(names) - if (CollectionUtils.isNotEmpty(dictionaries)) { - for (dataDictionary in dictionaries) { - if (StringUtils.isNotBlank(dataDictionary.name)) { - dictionaryMap[dataDictionary.name] = dataDictionary - } - } - } - } - return dictionaryMap - - } - private fun getDictionaryDefinitionsList(resourceAssignments: List): List? { - var dictionaries: List? = null - val names = ArrayList() - for (resourceAssignment in resourceAssignments) { - if (StringUtils.isNotBlank(resourceAssignment.dictionaryName)) { - - if (!names.contains(resourceAssignment.dictionaryName)) { - names.add(resourceAssignment.dictionaryName!!) - } - - if (resourceAssignment.dependencies != null && !resourceAssignment.dependencies!!.isEmpty()) { - val dependencyNames = resourceAssignment.dependencies - for (dependencyName in dependencyNames!!) { - if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName)) { - names.add(dependencyName) - } - } - } - } - } - if (CollectionUtils.isNotEmpty(names)) { - dictionaries = dataDictionaryRepository.findByNameIn(names) - } - return dictionaries - - } - - private fun getAllAutoMapResourceAssignments(resourceAssignments: MutableList): List { - var dictionaries: List? = null - val names = ArrayList() - for (resourceAssignment in resourceAssignments) { - if (StringUtils.isNotBlank(resourceAssignment.dictionaryName)) { - if (resourceAssignment.dependencies != null && !resourceAssignment.dependencies!!.isEmpty()) { - val dependencyNames = resourceAssignment.dependencies - for (dependencyName in dependencyNames!!) { - if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName) - && !checkAssignmentsExists(resourceAssignments, dependencyName)) { - names.add(dependencyName) - } - } - } - } - } - - if (!names.isEmpty()) { - dictionaries = dataDictionaryRepository.findByNameIn(names) - } - if (dictionaries != null) { - for (rscDictionary in dictionaries) { - val dictionaryDefinition = rscDictionary.definition - Preconditions.checkNotNull(dictionaryDefinition, "failed to get Resource Definition from dictionary definition") - val property = PropertyDefinition() - property.required = true - val resourceAssignment = ResourceAssignment() - resourceAssignment.name = rscDictionary.name - resourceAssignment.dictionaryName = rscDictionary.name - resourceAssignment.version = 0 - resourceAssignment.property = property - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition) - resourceAssignments.add(resourceAssignment) - } - } - return resourceAssignments - } - - - private fun checkAssignmentsExists(resourceAssignmentsWithDepencies: List, resourceName: String): Boolean { - return resourceAssignmentsWithDepencies.stream().anyMatch { names -> names.name.equals(resourceName, ignoreCase = true) } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt deleted file mode 100644 index e1fa1882d..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 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.cds.controllerblueprints.service - -import com.fasterxml.jackson.databind.JsonNode -import com.google.common.base.Preconditions -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.* -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition -import org.onap.ccsdk.cds.controllerblueprints.service.repository.ModelTypeRepository -import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository -import org.springframework.stereotype.Service - -interface ResourceDefinitionRepoService : BluePrintRepoService { - - @Throws(BluePrintException::class) - fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition -} - -@Service -open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRepository, - private val resourceDictionaryRepository: ResourceDictionaryRepository) : ResourceDefinitionRepoService { - - @Throws(BluePrintException::class) - override fun getNodeType(nodeTypeName: String): NodeType { - return getModelType(nodeTypeName, NodeType::class.java) - ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)") - } - - @Throws(BluePrintException::class) - override fun getDataType(dataTypeName: String): DataType { - return getModelType(dataTypeName, DataType::class.java) - ?: throw BluePrintException("couldn't get DataType($dataTypeName)") - } - - @Throws(BluePrintException::class) - override fun getArtifactType(artifactTypeName: String): ArtifactType { - return getModelType(artifactTypeName, ArtifactType::class.java) - ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)") - } - - @Throws(BluePrintException::class) - override fun getRelationshipType(relationshipTypeName: String): RelationshipType { - return getModelType(relationshipTypeName, RelationshipType::class.java) - ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)") - } - - @Throws(BluePrintException::class) - override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { - return getModelType(capabilityDefinitionName, CapabilityDefinition::class.java) - ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)") - } - - @Throws(BluePrintException::class) - override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition { - val dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName) - return if (dbResourceDictionary != null) { - dbResourceDictionary.definition - } else { - throw BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName)) - } - } - - @Throws(BluePrintException::class) - private fun getModelType(modelName: String, valueClass: Class): T? { - Preconditions.checkArgument(StringUtils.isNotBlank(modelName), - "Failed to get model from repo, model name is missing") - - val modelDefinition = getModelDefinition(modelName) - Preconditions.checkNotNull(modelDefinition, - String.format("Failed to get model content for model name (%s)", modelName)) - - return JacksonUtils.readValue(modelDefinition, valueClass) - } - - @Throws(BluePrintException::class) - private fun getModelDefinition(modelName: String): JsonNode { - val modelDefinition: JsonNode - val modelTypeDb = modelTypeRepository.findByModelName(modelName) - if (modelTypeDb != null) { - modelDefinition = modelTypeDb.definition - } else { - throw BluePrintException(String.format("failed to get model definition (%s) from repo", modelName)) - } - return modelDefinition - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ControllerBlueprintExceptionHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ControllerBlueprintExceptionHandler.kt deleted file mode 100644 index 4537dbb9d..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ControllerBlueprintExceptionHandler.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2018-2019 Bell Canada 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.cds.controllerblueprints.service.controller - -import org.springframework.web.bind.annotation.RestControllerAdvice -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode -import org.onap.ccsdk.cds.controllerblueprints.service.common.ErrorMessage -import org.slf4j.LoggerFactory -import org.springframework.http.HttpStatus -import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.ExceptionHandler - -/** - * ControllerBlueprintExceptionHandler Purpose: Handle exceptions in controllerBlueprint API and provide the right - * HTTP code status - * - * @author Vinal Patel - * @version 1.0 - */ -@RestControllerAdvice("org.onap.ccsdk.cds.controllerblueprints") -open class ControllerBlueprintExceptionHandler { - - companion object ControllerBlueprintExceptionHandler { - val LOG = LoggerFactory.getLogger(ControllerBlueprintExceptionHandler::class.java) - } - - @ExceptionHandler - fun ControllerBlueprintExceptionHandler(e: BluePrintException): ResponseEntity { - var errorCode = ErrorCode.valueOf(e.code) - val errorMessage = ErrorMessage(errorCode?.message(e.message!!), errorCode?.value, "ControllerBluePrint_Error_Message") - LOG.error("Error: $errorCode ${e.message}") - return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode!!.httpCode)) - } - - @ExceptionHandler - fun ControllerBlueprintExceptionHandler(e: Exception): ResponseEntity { - var errorCode = ErrorCode.GENERIC_FAILURE - val errorMessage = ErrorMessage(errorCode?.message(e.message!!), errorCode?.value, "ControllerBluePrint_Error_Message") - LOG.error("Error: $errorCode ${e.message}") - return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode!!.httpCode)) - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt deleted file mode 100644 index 341d63bf0..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 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.cds.controllerblueprints.service.controller - -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler -import kotlinx.coroutines.runBlocking -import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.* - -@RestController -@RequestMapping(value = arrayOf("/api/v1/model-type")) -open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) { - - @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) - fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? = runBlocking { - modelTypeHandler.getModelTypeByName(name) - } - - @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) - fun searchModelTypes(@PathVariable(value = "tags") tags: String): List = runBlocking { - modelTypeHandler.searchModelTypes(tags) - } - - @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) - @ResponseBody - fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List = runBlocking { - modelTypeHandler.getModelTypeByDefinitionType(definitionType) - } - - @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE)) - @ResponseBody - @Throws(BluePrintException::class) - fun saveModelType(@RequestBody modelType: ModelType): ModelType = runBlocking { - modelTypeHandler.saveModel(modelType) - } - - @DeleteMapping(path = arrayOf("/{name}")) - fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = runBlocking { - modelTypeHandler.deleteByModelName(name) - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt deleted file mode 100644 index d728fc229..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.controller - -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary -import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler -import kotlinx.coroutines.runBlocking -import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.* - -@RestController -@RequestMapping(value = ["/api/v1/dictionary"]) -open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) { - - @GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE]) - @ResponseBody - @Throws(BluePrintException::class) - fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary = runBlocking { - resourceDictionaryHandler.getResourceDictionaryByName(name) - } - - @PostMapping(path = [""], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE]) - @ResponseBody - @Throws(BluePrintException::class) - fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary = runBlocking { - resourceDictionaryHandler.saveResourceDictionary(dataDictionary) - } - - @DeleteMapping(path = ["/{name}"]) - fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) = runBlocking { - resourceDictionaryHandler.deleteResourceDictionary(name) - } - - @PostMapping(path = ["/by-names"], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE]) - @ResponseBody - fun searchResourceDictionaryByNames(@RequestBody names: List): List = runBlocking { - resourceDictionaryHandler.searchResourceDictionaryByNames(names) - } - - @GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE]) - @ResponseBody - fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List = runBlocking { - resourceDictionaryHandler.searchResourceDictionaryByTags(tags) - - } - - @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE]) - @ResponseBody - fun getResourceSourceMapping(): ResourceSourceMapping = runBlocking { - resourceDictionaryHandler.getResourceSourceMapping() - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt deleted file mode 100644 index d68fdd025..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 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.cds.controllerblueprints.service.handler - -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.onap.ccsdk.cds.controllerblueprints.service.repository.ModelTypeRepository -import org.onap.ccsdk.cds.controllerblueprints.service.validator.ModelTypeValidator -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Service - -@Service -open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) { - - private val log = LoggerFactory.getLogger(ModelTypeHandler::class.java)!! - - /** - * This is a getModelTypeByName service - * - * @param modelTypeName modelTypeName - * @return ModelType - */ - suspend fun getModelTypeByName(modelTypeName: String): ModelType { - log.info("Searching : $modelTypeName") - check(modelTypeName.isNotBlank()) { "Model Name Information is missing." } - val modelType = modelTypeRepository.findByModelName(modelTypeName) - return if (modelType != null) { - modelType - } else { - throw BluePrintException("couldn't get modelType($modelTypeName)") - } - } - - - /** - * This is a searchModelTypes service - * - * @param tags tags - * @return List - */ - suspend fun searchModelTypes(tags: String): List { - check(tags.isNotBlank()) { "No Search Information provide" } - return modelTypeRepository.findByTagsContainingIgnoreCase(tags) - } - - /** - * This is a saveModel service - * - * @param modelType modelType - * @return ModelType - * @throws BluePrintException BluePrintException - */ - @Throws(BluePrintException::class) - suspend open fun saveModel(modelType: ModelType): ModelType { - lateinit var dbModel: ModelType - ModelTypeValidator.validateModelType(modelType) - val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName) - if (dbModelType != null) { - dbModel = dbModelType - dbModel.description = modelType.description - dbModel.definition = modelType.definition - dbModel.definitionType = modelType.definitionType - dbModel.derivedFrom = modelType.derivedFrom - dbModel.tags = modelType.tags - dbModel.version = modelType.version - dbModel.updatedBy = modelType.updatedBy - dbModel = modelTypeRepository.save(dbModel) - } else { - dbModel = modelTypeRepository.save(modelType) - } - return dbModel - } - - - /** - * This is a deleteByModelName service - * - * @param modelName modelName - */ - suspend open fun deleteByModelName(modelName: String) { - check(modelName.isNotBlank()) { "Model Name Information is missing." } - modelTypeRepository.deleteByModelName(modelName) - - } - - /** - * This is a getModelTypeByDefinitionType service - * - * @param definitionType definitionType - * @return List - */ - suspend fun getModelTypeByDefinitionType(definitionType: String): List { - check(definitionType.isNotBlank()) { "Model definitionType Information is missing." } - return modelTypeRepository.findByDefinitionType(definitionType) - } - - /** - * This is a getModelTypeByDerivedFrom service - * - * @param derivedFrom derivedFrom - * @return List - */ - suspend fun getModelTypeByDerivedFrom(derivedFrom: String): List { - check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." } - return modelTypeRepository.findByDerivedFrom(derivedFrom) - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt deleted file mode 100644 index e339bcd68..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 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.cds.controllerblueprints.service.handler - -import com.google.common.base.Preconditions -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary -import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository -import org.springframework.stereotype.Service - -@Service -class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) { - - - /** - * This is a getDataDictionaryByName service - * - * @param name name - * @return DataDictionary - * @throws BluePrintException BluePrintException - */ - @Throws(BluePrintException::class) - suspend fun getResourceDictionaryByName(name: String): ResourceDictionary { - Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.") - val resourceDictionaryDb = resourceDictionaryRepository.findByName(name) - return if (resourceDictionaryDb != null) { - resourceDictionaryDb - } else { - throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name)) - } - } - - /** - * This is a searchResourceDictionaryByNames service - * - * @param names names - * @return List - */ - suspend fun searchResourceDictionaryByNames(names: List): List { - Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide") - return resourceDictionaryRepository.findByNameIn(names) - } - - /** - * This is a searchResourceDictionaryByTags service - * - * @param tags tags - * @return List - */ - suspend fun searchResourceDictionaryByTags(tags: String): List { - Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide") - return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags) - } - - /** - * This is a saveDataDictionary service - * - * @param resourceDictionary resourceDictionary - * @return DataDictionary - */ - @Throws(BluePrintException::class) - suspend fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary { - var resourceDictionary = resourceDictionary - - val resourceDefinition = resourceDictionary.definition - Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content") - // Validate the Resource Definitions - //TODO( Save Validator) - //validate(resourceDefinition) - - resourceDictionary.tags = resourceDefinition.tags - resourceDefinition.updatedBy = resourceDictionary.updatedBy - // Set the Property Definitions - val propertyDefinition = resourceDefinition.property - resourceDictionary.description = propertyDefinition.description - resourceDictionary.dataType = propertyDefinition.type - if (propertyDefinition.entrySchema != null) { - resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type - } - - validateResourceDictionary(resourceDictionary) - - val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name) - if (dbResourceDictionaryData != null) { - val dbResourceDictionary = dbResourceDictionaryData - - dbResourceDictionary.name = resourceDictionary.name - dbResourceDictionary.definition = resourceDictionary.definition - dbResourceDictionary.description = resourceDictionary.description - dbResourceDictionary.tags = resourceDictionary.tags - dbResourceDictionary.updatedBy = resourceDictionary.updatedBy - dbResourceDictionary.dataType = resourceDictionary.dataType - dbResourceDictionary.entrySchema = resourceDictionary.entrySchema - resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary) - } else { - resourceDictionary = resourceDictionaryRepository.save(resourceDictionary) - } - - return resourceDictionary - } - - /** - * This is a deleteResourceDictionary service - * - * @param name name - */ - suspend fun deleteResourceDictionary(name: String) { - check(name.isNotBlank()) { "Resource dictionary name is missing." } - resourceDictionaryRepository.deleteByName(name) - } - - /** - * This is a getResourceSourceMapping service - */ - suspend fun getResourceSourceMapping(): ResourceSourceMapping { - return ResourceSourceMappingFactory.getRegisterSourceMapping() - } - - private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean { - checkNotEmpty(resourceDictionary.name){ "DataDictionary Definition name is missing."} - checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." } - checkNotEmpty(resourceDictionary.description){ "DataDictionary Definition Information is missing."} - checkNotEmpty(resourceDictionary.tags){ "DataDictionary Definition tags is missing."} - checkNotEmpty(resourceDictionary.updatedBy){ "DataDictionary Definition updatedBy is missing."} - return true - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/BluePrintsReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/BluePrintsReactRepository.kt deleted file mode 100644 index 0041fa7c8..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/BluePrintsReactRepository.kt +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.cds.controllerblueprints.service.repository - -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.springframework.stereotype.Service -import reactor.core.publisher.Flux -import reactor.core.publisher.Mono -import reactor.core.scheduler.Schedulers - -/** - * ModelTypeReactRepository. - * - * @author Brinda Santh - */ -@Service -open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRepository) { - - fun save(modelType: ModelType): Mono { - return Mono.justOrEmpty(modelTypeRepository.save(modelType)) - } - - fun findByModelName(modelName: String): Mono { - return Mono.justOrEmpty(modelTypeRepository.findByModelName(modelName)) - } - - fun findByModelNameIn(modelNames: List): Flux { - return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames)) - .subscribeOn(Schedulers.elastic()) - } - - fun findByDerivedFrom(derivedFrom: String): Flux { - return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom)) - .subscribeOn(Schedulers.elastic()) - } - - fun findByDerivedFromIn(derivedFroms: List): Flux { - return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms)) - .subscribeOn(Schedulers.elastic()) - } - - fun findByDefinitionType(definitionType: String): Flux { - return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType)) - .subscribeOn(Schedulers.elastic()) - } - - fun findByDefinitionTypeIn(definitionTypes: List): Flux { - return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes)) - .subscribeOn(Schedulers.elastic()) - } - - fun findByTagsContainingIgnoreCase(tags: String): Flux { - return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags)) - .subscribeOn(Schedulers.elastic()) - } - - fun deleteByModelName(modelName: String): Mono { - modelTypeRepository.deleteByModelName(modelName) - return Mono.empty() - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeRepository.kt deleted file mode 100644 index 4fefc8144..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeRepository.kt +++ /dev/null @@ -1,85 +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.cds.controllerblueprints.service.repository - -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository -import javax.transaction.Transactional - -@Repository -interface ModelTypeRepository : JpaRepository { - /** - * This is a findByModelName method - * - * @param modelName Model Name - * @return Optional - */ - fun findByModelName(modelName: String): ModelType? - /** - * This is a findByModelNameIn method - * - * @param modelNames Model Names - * @return List - */ - fun findByModelNameIn(modelNames: List): List - /** - * This is a findByDerivedFrom method - * - * @param derivedFrom Derived From - * @return List - */ - fun findByDerivedFrom(derivedFrom: String): List - /** - * This is a findByDerivedFromIn method - * - * @param derivedFroms Derived Froms - * @return List - */ - fun findByDerivedFromIn(derivedFroms: List): List - - /** - * This is a findByDefinitionType method - * - * @param definitionType Definition Type - * @return List - */ - fun findByDefinitionType(definitionType: String): List - /** - * This is a findByDefinitionTypeIn method - * - * @param definitionTypes Definition Types - * @return List - */ - fun findByDefinitionTypeIn(definitionTypes: List): List - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags Tags - * @return Optional - */ - fun findByTagsContainingIgnoreCase(tags: String): List - - /** - * This is a deleteByModelName method - * - * @param modelName ModelName - */ - @Transactional - fun deleteByModelName(modelName: String) -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt deleted file mode 100644 index b1b633a10..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.repository - -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository - - -/** - * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -interface ResourceDictionaryRepository : JpaRepository { - - - /** - * This is a findByName method - * - * @param name name - * @return Optional - */ - fun findByName(name: String): ResourceDictionary? - - /** - * This is a findByNameIn method - * - * @param names names - * @return Optional - */ - fun findByNameIn(names: List): List - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags tags - * @return Optional - */ - fun findByTagsContainingIgnoreCase(tags: String): List - - /** - * This is a deleteByName method - * - * @param name name - */ - fun deleteByName(name: String) - - -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt deleted file mode 100644 index 97b9a813a..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * Modifications Copyright © 2019 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.cds.controllerblueprints.service.utils - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.reactive.awaitSingle -import kotlinx.coroutines.withContext -import org.onap.ccsdk.cds.controllerblueprints.core.* -import org.onap.ccsdk.cds.controllerblueprints.core.data.* -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils -import org.springframework.core.io.ByteArrayResource -import org.springframework.core.io.Resource -import org.springframework.http.HttpHeaders -import org.springframework.http.MediaType -import org.springframework.http.ResponseEntity -import org.springframework.http.codec.multipart.FilePart -import org.springframework.util.StringUtils -import reactor.core.publisher.Mono -import java.io.File -import java.io.IOException -import java.nio.file.Path -import java.nio.file.Paths -import java.util.* - - -class BluePrintEnhancerUtils { - companion object { - - fun populateDataTypes(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - dataTypeName: String): DataType { - val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName) - ?: bluePrintRepoService.getDataType(dataTypeName) - ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.") - bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType) - return dataType - } - - fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - relationshipName: String): RelationshipType { - - val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName) - ?: bluePrintRepoService.getRelationshipType(relationshipName) - ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.") - bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType) - return relationshipType - } - - - fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - nodeTypeName: String): NodeType { - - val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName) - ?: bluePrintRepoService.getNodeType(nodeTypeName) - ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.") - bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) - return nodeType - } - - fun populateArtifactType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - artifactTypeName: String): ArtifactType { - - val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: bluePrintRepoService.getArtifactType(artifactTypeName) - ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.") - bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) - return artifactType - } - - suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File { - // Delete the Directory - targetFile.deleteRecursively() - return filePart.transferTo(targetFile) - .thenReturn(targetFile) - .awaitSingle() - } - - suspend fun extractCompressFilePart(filePart: FilePart, archiveDir: String, enhanceDir: String): File { - //Recreate the Base Directories - normalizedFile(archiveDir).reCreateDirs() - normalizedFile(enhanceDir).reCreateDirs() - val filePartFile = normalizedFile(archiveDir, "cba.zip") - // Copy the File Part to ZIP - return copyFromFilePart(filePart, filePartFile) - } - - suspend fun decompressFilePart(filePart: FilePart, archiveDir: String, enhanceDir: String): File { - val filePartFile = extractCompressFilePart(filePart, archiveDir, enhanceDir) - val deCompressFileName = normalizedPathName(enhanceDir) - return filePartFile.deCompress(deCompressFileName) - } - - suspend fun compressToFilePart(enhanceDir: String, archiveDir: String, - outputFileName:String="enhanced-cba.zip"): ResponseEntity { - val compressedFile = normalizedFile(archiveDir, outputFileName) - BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) - return prepareResourceEntity(compressedFile.name, compressedFile.readBytes()) - } - - suspend fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity { - return ResponseEntity.ok() - .contentType(MediaType.parseMediaType("text/plain")) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"") - .body(ByteArrayResource(file)) - } - - suspend fun cleanEnhancer(archiveLocation: String, enhancementLocation: String) = withContext(Dispatchers.Default) { - deleteDir(archiveLocation) - deleteDir(enhancementLocation) - } - - /** - * This is a saveCBAFile method - * take a [FilePart], transfer it to disk using a Flux of FilePart and return a [Mono] representing the CBA file name - * - * @param (filePart, targetDirectory) - the request part containing the file to be saved and the default directory where to save - * @return a [Mono] String representing the result of the operation - * @throws (BluePrintException, IOException) BluePrintException, IOException - */ - @Throws(BluePrintException::class, IOException::class) - fun saveCBAFile(filePart: FilePart, targetDirectory: Path): Mono { - - // Normalize file name - val fileName = StringUtils.cleanPath(filePart.filename()) - - // Check if the file's extension is "CBA" - if (StringUtils.getFilenameExtension(fileName) != "zip") { - throw BluePrintException(ErrorCode.INVALID_FILE_EXTENSION.value, "Invalid file extension required ZIP") - } - - // Change file name to match a pattern - val changedFileName = UUID.randomUUID().toString() + ".zip" - //String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN); - - // Copy file to the target location (Replacing existing file with the same name) - val targetLocation = targetDirectory.resolve(changedFileName) - - // if a file with the same name already exists in a repository, delete and recreate it - val file = File(targetLocation.toString()) - if (file.exists()) - file.delete() - file.createNewFile() - - return filePart.transferTo(file).thenReturn(changedFileName) - } - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidator.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidator.kt deleted file mode 100644 index 9bfb29c23..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidator.kt +++ /dev/null @@ -1,83 +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.cds.controllerblueprints.service.validator - -import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.cds.controllerblueprints.core.data.* -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType - -class ModelTypeValidator { - companion object { - /** - * This is a validateModelTypeDefinition - * - * @param definitionType definitionType - * @param definitionContent definitionContent - * @return boolean - */ - fun validateModelTypeDefinition(definitionType: String, definitionContent: JsonNode): Boolean { - - when (definitionType) { - BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> { - JacksonUtils.readValue(definitionContent, DataType::class.java) - ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent") - } - BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> { - JacksonUtils.readValue(definitionContent, NodeType::class.java) - ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent") - } - BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> { - JacksonUtils.readValue(definitionContent, ArtifactType::class.java) - ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent") - } - BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> { - JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java) - ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent") - } - BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> { - JacksonUtils.readValue(definitionContent, RelationshipType::class.java) - ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent") - } - } - return true - } - - /** - * This is a validateModelType method - * - * @param modelType modelType - * @return boolean - */ - fun validateModelType(modelType: ModelType?): Boolean { - checkNotNull(modelType) { "Model Type Information is missing." } - - val validRootTypes = BluePrintTypes.validModelTypes() - - check(validRootTypes.contains(modelType.definitionType)) { - "Not Valid Model Root Type(${modelType.definitionType}), It should be $validRootTypes" - } - - validateModelTypeDefinition(modelType.definitionType, modelType.definition) - return true - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java deleted file mode 100644 index 26b162494..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.cds.controllerblueprints.service.repository; - -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.onap.ccsdk.cds.controllerblueprints.TestApplication; -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.test.annotation.Commit; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.Arrays; -import java.util.List; - -/** - * ModelTypeReactRepositoryTest. - * - * @author Brinda Santh - */ - -@RunWith(SpringRunner.class) -@DataJpaTest -@ContextConfiguration(classes = {TestApplication.class}) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ModelTypeReactRepositoryTest { - - @Autowired - private ModelTypeReactRepository modelTypeReactRepository; - - String modelName = "test-datatype"; - - @Test - @Commit - public void test01Save() { - String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json"); - ModelType modelType = new ModelType(); - modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); - modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); - modelType.setDescription("Definition for Sample Datatype "); - modelType.setDefinition(JacksonUtils.Companion.jsonNode(content)); - modelType.setModelName(modelName); - modelType.setVersion("1.0.0"); - modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); - modelType.setUpdatedBy("xxxxxx@xxx.com"); - - ModelType dbModelType = modelTypeReactRepository.save(modelType).block(); - Assert.assertNotNull("Failed to get Saved ModelType", dbModelType); - } - - @Test - public void test02Finds() { - ModelType dbFindByModelName = modelTypeReactRepository.findByModelName(modelName).block(); - Assert.assertNotNull("Failed to findByModelName ", dbFindByModelName); - - List dbFindByDefinitionType = - modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block(); - Assert.assertNotNull("Failed to findByDefinitionType ", dbFindByDefinitionType); - Assert.assertTrue("Failed to findByDefinitionType count", dbFindByDefinitionType.size() > 0); - - List dbFindByDerivedFrom = - modelTypeReactRepository.findByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT).collectList().block(); - Assert.assertNotNull("Failed to find findByDerivedFrom", dbFindByDerivedFrom); - Assert.assertTrue("Failed to find findByDerivedFrom by count", dbFindByDerivedFrom.size() > 0); - - List dbFindByModelNameIn = - modelTypeReactRepository.findByModelNameIn(Arrays.asList(modelName)).collectList().block(); - Assert.assertNotNull("Failed to findByModelNameIn ", dbFindByModelNameIn); - Assert.assertTrue("Failed to findByModelNameIn by count", dbFindByModelNameIn.size() > 0); - - List dbFindByDefinitionTypeIn = - modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block(); - Assert.assertNotNull("Failed to findByDefinitionTypeIn", dbFindByDefinitionTypeIn); - Assert.assertTrue("Failed to findByDefinitionTypeIn by count", dbFindByDefinitionTypeIn.size() > 0); - - List dbFindByDerivedFromIn = - modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block(); - Assert.assertNotNull("Failed to find findByDerivedFromIn", dbFindByDerivedFromIn); - Assert.assertTrue("Failed to find findByDerivedFromIn by count", dbFindByDerivedFromIn.size() > 0); - } - - @Test - @Commit - public void test03Delete() { - modelTypeReactRepository.deleteByModelName(modelName).block(); - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt deleted file mode 100644 index e55f2a511..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service - -import kotlinx.coroutines.runBlocking -import org.junit.Assert -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest -import org.springframework.test.annotation.Commit -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner -import org.springframework.transaction.annotation.Propagation -import org.springframework.transaction.annotation.Transactional - - -@RunWith(SpringRunner::class) -@DataJpaTest -@Transactional(propagation = Propagation.NOT_SUPPORTED) -@ContextConfiguration(classes = [TestApplication::class]) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ModelTypeServiceTest { - @Autowired - private val modelTypeHandler: ModelTypeHandler? = null - - internal var modelName = "test-datatype" - - private val log = LoggerFactory.getLogger(ModelTypeServiceTest::class.java) - - @Test - @Commit - @Throws(Exception::class) - fun test01SaveModelType() { - runBlocking { - log.info("**************** test01SaveModelType ********************") - - val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json") - var modelType = ModelType() - modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE - modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT - modelType.description = "Definition for Sample Datatype " - modelType.definition = JacksonUtils.jsonNode(content) - modelType.modelName = modelName - modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - modelType.updatedBy = "xxxxxx@xxx.com" - modelType = modelTypeHandler!!.saveModel(modelType) - log.info("Saved Mode {}", modelType.toString()) - Assert.assertNotNull("Failed to get Saved ModelType", modelType) - Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName) - - val dbModelType = modelTypeHandler.getModelTypeByName(modelType.modelName) - Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", - dbModelType) - - // Model Update - modelType.updatedBy = "bs2796@xxx.com" - modelType = modelTypeHandler.saveModel(modelType) - Assert.assertNotNull("Failed to get Saved ModelType", modelType) - Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy) - } - - } - - @Test - @Throws(Exception::class) - fun test02SearchModelTypes() { - runBlocking { - log.info("*********************** test02SearchModelTypes ***************************") - - val tags = "test-datatype" - - val dbModelTypes = modelTypeHandler!!.searchModelTypes(tags) - Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes) - Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size > 0) - } - - } - - @Test - @Throws(Exception::class) - fun test03GetModelType() { - runBlocking { - log.info("************************* test03GetModelType *********************************") - val dbModelType = modelTypeHandler!!.getModelTypeByName(modelName) - Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType) - Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName) - - val dbDatatypeModelTypes = modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes) - Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size > 0) - - val dbModelTypeByDerivedFroms = modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT) - Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms) - Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size > 0) - } - - } - - @Test - @Throws(Exception::class) - fun test04DeleteModelType() { - runBlocking { - log.info( - "************************ test03DeleteModelType ***********************") - val dbResourceMapping = modelTypeHandler!!.getModelTypeByName(modelName) - Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping) - Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName) - - modelTypeHandler.deleteByModelName(dbResourceMapping.modelName) - } - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt deleted file mode 100644 index 4af8851a5..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.controller - -import org.junit.Assert -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest -import org.springframework.test.annotation.Commit -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner - -@RunWith(SpringRunner::class) -@DataJpaTest -@ContextConfiguration(classes = [TestApplication::class]) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ModelTypeControllerTest { - - private val log = LoggerFactory.getLogger(ModelTypeControllerTest::class.java)!! - - @Autowired - internal var modelTypeController: ModelTypeController? = null - - private var modelName = "test-datatype" - - @Test - @Commit - @Throws(Exception::class) - fun test01SaveModelType() { - log.info("**************** test01SaveModelType ********************") - - val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json") - var modelType = ModelType() - modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE - modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT - modelType.description = "Definition for Sample Datatype " - modelType.definition = JacksonUtils.jsonNode(content) - modelType.modelName = modelName - modelType.version = "1.0.0" - modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - modelType.updatedBy = "xxxxxx@xxx.com" - modelType = modelTypeController!!.saveModelType(modelType) - log.info("Saved Mode {}", modelType.toString()) - Assert.assertNotNull("Failed to get Saved ModelType", modelType) - Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName) - - val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName) - Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")", - dbModelType) - - // Model Update - modelType.updatedBy = "bs2796@xxx.com" - modelType = modelTypeController!!.saveModelType(modelType) - Assert.assertNotNull("Failed to get Saved ModelType", modelType) - Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy) - - } - - @Test - @Throws(Exception::class) - fun test02SearchModelTypes() { - log.info("*********************** test02SearchModelTypes ***************************") - - val tags = "test-datatype" - - val dbModelTypes = modelTypeController!!.searchModelTypes(tags) - Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes) - Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty()) - - } - - @Test - @Throws(Exception::class) - fun test03GetModelType() { - log.info("************************* test03GetModelType *********************************") - val dbModelType = modelTypeController!!.getModelTypeByName(modelName) - Assert.assertNotNull("Failed to get response for api call getModelByName $modelName", dbModelType) - Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName) - - val dbDatatypeModelTypes = modelTypeController!!.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes) - Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.isNotEmpty()) - } - - @Test - @Commit - @Throws(Exception::class) - fun test04DeleteModelType() { - log.info( - "************************ test03DeleteModelType ***********************") - val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName) - Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping) - Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName) - - modelTypeController!!.deleteModelTypeByName(dbResourceMapping.modelName) - } -} diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt deleted file mode 100644 index cf139ec00..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.controller - -import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.annotation.ComponentScan -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner -import kotlin.test.assertNotNull - -@RunWith(SpringRunner::class) -@ContextConfiguration(classes = [TestApplication::class]) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints"]) -class ResourceDictionaryControllerTest { - - @Autowired - lateinit var resourceDictionaryController: ResourceDictionaryController - - @Test - fun testResourceDictionaryControllerPresence() { - assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController") - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/mock/MockFilePart.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/mock/MockFilePart.kt deleted file mode 100644 index 2fb2129ae..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/mock/MockFilePart.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.controller.mock - -import org.apache.commons.io.FilenameUtils -import org.slf4j.LoggerFactory -import org.springframework.core.io.buffer.DataBuffer -import org.springframework.http.HttpHeaders -import org.springframework.http.codec.multipart.FilePart -import org.springframework.util.FileCopyUtils -import reactor.core.publisher.Flux -import reactor.core.publisher.Mono -import java.io.File -import java.nio.file.Path - -class MockFilePart(private val fileName: String) : FilePart { - val log = LoggerFactory.getLogger(MockFilePart::class.java)!! - override fun content(): Flux { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun headers(): HttpHeaders { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun filename(): String { - return FilenameUtils.getName(fileName) - } - - override fun name(): String { - return FilenameUtils.getBaseName(fileName) - } - - override fun transferTo(path: Path): Mono { - log.info("Copying file($fileName to ${path}") - FileCopyUtils.copy(File(fileName), path.toFile()) - return Mono.empty() - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt deleted file mode 100644 index 3f52d9183..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.repository - -import kotlinx.coroutines.runBlocking -import org.junit.Assert -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest -import org.springframework.test.annotation.Commit -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner - -@RunWith(SpringRunner::class) -@DataJpaTest -@ContextConfiguration(classes = [TestApplication::class]) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ResourceDictionaryReactRepositoryTest { - - private val sourceName = "test-source" - - @Autowired - lateinit var resourceDictionaryRepository: ResourceDictionaryRepository - - @Test - @Commit - fun test01Save() { - val resourceDefinition = JacksonUtils.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition::class.java) - Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition) - resourceDefinition!!.name = sourceName - - val resourceDictionary = transformResourceDictionary(resourceDefinition) - val dbResourceDictionary = resourceDictionaryRepository.save(resourceDictionary) - Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary) - } - - @Test - fun test02FindByNameReact() { - val dbResourceDictionary = resourceDictionaryRepository.findByName(sourceName) - Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary) - } - - @Test - fun test03FindByNameInReact() { - val dbResourceDictionaries = resourceDictionaryRepository.findByNameIn(arrayListOf(sourceName)) - Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries) - } - - @Test - fun test04FindByTagsContainingIgnoreCaseReact() { - val dbTagsResourceDictionaries = resourceDictionaryRepository.findByTagsContainingIgnoreCase(sourceName) - Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries) - } - - @Test - @Commit - fun test05Delete() { - runBlocking { - resourceDictionaryRepository.deleteByName(sourceName) - } - } - - private fun transformResourceDictionary(resourceDefinition: ResourceDefinition): ResourceDictionary { - val resourceDictionary = ResourceDictionary() - resourceDictionary.name = resourceDefinition.name - resourceDictionary.dataType = resourceDefinition.property.type - resourceDictionary.description = resourceDefinition.property.description - resourceDictionary.tags = resourceDefinition.tags - resourceDictionary.updatedBy = resourceDefinition.updatedBy - resourceDictionary.definition = resourceDefinition - return resourceDictionary - } -} diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtilsTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtilsTest.kt deleted file mode 100644 index 100c3adeb..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtilsTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2019 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.cds.controllerblueprints.service.utils - -import kotlinx.coroutines.runBlocking -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.* -import org.onap.ccsdk.cds.controllerblueprints.service.controller.mock.MockFilePart -import java.nio.file.Paths -import java.util.* -import kotlin.test.assertTrue - -class BluePrintEnhancerUtilsTest { - - private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" - private val blueprintArchivePath: String = "./target/blueprints/archive" - private val blueprintEnrichmentPath: String = "./target/blueprints/enrichment" - private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip") - - @Before - fun setUp() { - val archiveDir = normalizedFile(blueprintArchivePath).reCreateDirs() - assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}") - val enhancerDir = normalizedFile(blueprintEnrichmentPath).reCreateDirs() - assertTrue(enhancerDir.exists(), "failed to create enhancerDir(${enhancerDir.absolutePath}") - val blueprintFile = Paths.get(blueprintDir).toFile().normalize() - val testZipFile = blueprintFile.compress(zipBlueprintFileName) - assertTrue(testZipFile.exists(), "Failed to create blueprint test zip(${testZipFile.absolutePath}") - } - - @After - fun tearDown() { - deleteDir(blueprintArchivePath) - deleteDir(blueprintEnrichmentPath) - } - - @Test - fun testFilePartCompressionNDeCompression() { - val filePart = MockFilePart(zipBlueprintFileName) - - runBlocking { - val enhanceId = UUID.randomUUID().toString() - val blueprintArchiveLocation = normalizedPathName(blueprintArchivePath, enhanceId) - val blueprintEnrichmentLocation = normalizedPathName(blueprintEnrichmentPath, enhanceId) - BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchiveLocation, blueprintEnrichmentLocation) - BluePrintEnhancerUtils.compressToFilePart(blueprintEnrichmentLocation, blueprintArchiveLocation) - } - } -} - diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidatorTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidatorTest.kt deleted file mode 100644 index 728f431a7..000000000 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/validator/ModelTypeValidatorTest.kt +++ /dev/null @@ -1,40 +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.cds.controllerblueprints.service.validator - -import com.fasterxml.jackson.databind.JsonNode -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType - -class ModelTypeValidatorTest { - - @Test(expected = IllegalStateException::class) - @Throws(Exception::class) - fun testvalidateModelType() { - val modelType = ModelType() - modelType.definitionType = "" - modelType.derivedFrom = "" - modelType.description = "" - val definitionContent: JsonNode? = null - modelType.definition = definitionContent - modelType.modelName = "" - modelType.version = "" - modelType.tags = "" - modelType.updatedBy = "" - ModelTypeValidator.validateModelType(modelType) - } -} 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 deleted file mode 100644 index 631b9d901..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "name": "rs-db-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "sample-db-source", - "dictionary-source": "processor-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": "sdnc", - "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 deleted file mode 100644 index f551b248f..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "metadata": { - "template_author": "Brinda Santh", - "template_name": "enhance-template", - "template_version": "1.0.0", - "template_tags": "brinda, VPE", - "service-type": "Sample Service", - "release": "1806", - "vnf-type": "VPE" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "vpe-netconf-device": { - "capabilities": { - "netconf": { - "properties": { - "login-key": "sdnc", - "login-account": "sndc-local", - "source": "local", - "target-ip-address": { - "get_attribute": [ - "SELF", - "lo0-local-ipv4-address" - ] - }, - "port-number": 22, - "connection-time-out": 30 - } - } - }, - "type": "vnf-netconf-device" - }, - "activate-netconf-component": { - "capabilities": { - "component-node": {} - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vpe-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "NetconfExecutorComponent": { - "operations": { - "process": { - "inputs": { - "action-name": { - "get_input": "action-name" - }, - "template-name": { - "get_input": "template_name" - }, - "template-version": { - "get_input": "template_version" - }, - "resource-type": "vnf-type", - "request-id": { - "get_input": "request-id" - }, - "resource-id": { - "get_input": "hostname" - }, - "execution-script": "execution-script" - }, - "outputs": { - "response-data": { - "get_attribute": [ - "SELF", - "netconf-executor-baseconfig.response-data" - ] - }, - "status": { - "get_attribute": [ - "SELF", - "netconf-executor-baseconfig.status" - ] - } - }, - "implementation": { - "primary": "file://netconf_adaptor/DefaultBaseLicenceConfig.py" - } - } - } - } - }, - "type": "component-netconf-executor" - }, - "resource-assignment-ra-component": { - "capabilities": { - "component-node": {} - }, - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "template-names": [ - "base-config-template", - "licence-template" - ], - "action-name": { - "get_input": "action-name" - }, - "template-name": { - "get_input": "template_name" - }, - "template-version": { - "get_input": "template-version" - }, - "resource-type": "vnf-type", - "request-id": { - "get_input": "request-id" - }, - "resource-id": { - "get_input": "hostname" - } - }, - "outputs": { - "resource-assignment-params": "success", - "status": "status" - } - } - } - } - }, - "type": "component-resource-assignment" - }, - "resource-assignment-action": { - "properties": { - "mode": "sync", - "version": "LATEST", - "is-start-flow": false - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment-ra-component", - "relationship": "tosca.relationships.DependsOn" - } - }, - "capabilities": { - "dg-node": {} - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": [] - } - } - } - } - }, - "type": "dg-resource-assignment" - }, - "activate-action": { - "properties": { - "mode": "sync", - "version": "LATEST", - "is-start-flow": false - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "activate-netconf-component", - "relationship": "tosca.relationships.DependsOn" - } - }, - "capabilities": { - "dg-node": {} - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": [] - } - } - } - } - }, - "type": "dg-activate-netconf" - }, - "base-config-template": { - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "rs-db-source", - "property": { - "required": true, - "type": "string" - }, - "input-param": false, - "dictionary-name": "sample-db-source", - "dictionary-source": "processor-db", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "mdsal-source", - "property": { - "description": "", - "required": true, - "type": "list", - "entry_schema": { - "type": "dt-v4-aggregate" - } - }, - "input-param": false, - "dictionary-name": "sample-mdsal-source", - "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id" - ], - "version": 0 - }, - { - "name": "hostname", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "hostname", - "dictionary-source": "input", - "version": 0, - "input-param": false - }, - { - "name": "service", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service", - "dictionary-source": "input", - "version": 0, - "input-param": false - }, - { - "name": "service-instance-id", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "version": 0, - "input-param": false - } - ] - } - } - }, - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "type": "artifact-config-template" - }, - "licence-template": { - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "licenses", - "property": { - "required": true, - "type": "list", - "entry_schema": { - "type": "dt-license-key" - } - }, - "input-param": false, - "dictionary-name": "sample-licenses", - "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id" - ], - "version": 0 - }, - { - "name": "service-instance-id", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "version": 0, - "input-param": false - } - ] - } - } - }, - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "type": "artifact-config-template" - } - } - }, - "node_types": { - }, - "data_types": { - } -} 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 deleted file mode 100644 index d71293259..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json +++ /dev/null @@ -1,327 +0,0 @@ -{ - "metadata" : { - "template_author" : "Brinda Santh", - "template_name" : "enhance-template", - "template_version" : "1.0.0", - "template_tags" : "brinda, VPE", - "service-type" : "Sample Service", - "release" : "1806", - "vnf-type" : "VPE" - }, - "tosca_definitions_version" : "controller_blueprint_1_0_0", - "artifact_types" : { }, - "data_types" : { - }, - "node_types" : { - }, - "topology_template" : { - "inputs" : { - "request-id" : { - "required" : true, - "type" : "string" - }, - "service-instance-id" : { - "required" : true, - "type" : "string" - }, - "scope-type" : { - "required" : true, - "type" : "string" - }, - "action-name" : { - "required" : true, - "type" : "string" - }, - "hostname" : { - "required" : true, - "type" : "string" - }, - "resource-assignment-request" : { - "description" : "This is Dynamic Data type for the receipe resource-assignment-action.", - "required" : false, - "type" : "dt-resource-assignment-request" - } - }, - "node_templates" : { - "vpe-netconf-device" : { - "type" : "vnf-netconf-device", - "capabilities" : { - "netconf" : { - "properties" : { - "login-key" : "sdnc", - "login-account" : "sndc-local", - "source" : "local", - "target-ip-address" : { - "get_attribute" : [ "SELF", "lo0-local-ipv4-address" ] - }, - "port-number" : 22, - "connection-time-out" : 30 - } - } - } - }, - "activate-netconf-component" : { - "type" : "component-netconf-executor", - "capabilities" : { - "component-node" : { } - }, - "requirements" : { - "netconf-connection" : { - "capability" : "netconf", - "node" : "vpe-netconf-device", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, - "interfaces" : { - "NetconfExecutorComponent" : { - "operations" : { - "process" : { - "implementation" : { - "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py" - }, - "inputs" : { - "action-name" : { - "get_input" : "action-name" - }, - "template-name" : { - "get_input" : "template_name" - }, - "template-version" : { - "get_input" : "template_version" - }, - "resource-type" : "vnf-type", - "request-id" : { - "get_input" : "request-id" - }, - "resource-id" : { - "get_input" : "hostname" - }, - "execution-script" : "execution-script" - }, - "outputs" : { - "response-data" : { - "get_attribute" : [ "SELF", "netconf-executor-baseconfig.response-data" ] - }, - "status" : { - "get_attribute" : [ "SELF", "netconf-executor-baseconfig.status" ] - } - } - } - } - } - } - }, - "resource-assignment-ra-component" : { - "type" : "component-resource-assignment", - "capabilities" : { - "component-node" : { } - }, - "interfaces" : { - "ResourceAssignmentComponent" : { - "operations" : { - "process" : { - "inputs" : { - "template-names" : [ "base-config-template", "licence-template" ], - "action-name" : { - "get_input" : "action-name" - }, - "template-name" : { - "get_input" : "template_name" - }, - "template-version" : { - "get_input" : "template-version" - }, - "resource-type" : "vnf-type", - "request-id" : { - "get_input" : "request-id" - }, - "resource-id" : { - "get_input" : "hostname" - } - }, - "outputs" : { - "resource-assignment-params" : "success", - "status" : "status" - } - } - } - } - } - }, - "resource-assignment-action" : { - "type" : "dg-resource-assignment", - "properties" : { - "mode" : "sync", - "version" : "LATEST", - "is-start-flow" : false - }, - "capabilities" : { - "dg-node" : { } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "resource-assignment-ra-component", - "relationship" : "tosca.relationships.DependsOn" - } - }, - "interfaces" : { - "CONFIG" : { - "operations" : { - "ResourceAssignment" : { - "inputs" : { - "params" : [ ] - } - } - } - } - } - }, - "activate-action" : { - "type" : "dg-activate-netconf", - "properties" : { - "mode" : "sync", - "version" : "LATEST", - "is-start-flow" : false - }, - "capabilities" : { - "dg-node" : { } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "activate-netconf-component", - "relationship" : "tosca.relationships.DependsOn" - } - }, - "interfaces" : { - "CONFIG" : { - "operations" : { - "ActivateNetconf" : { - "inputs" : { - "params" : [ ] - } - } - } - } - } - }, - "base-config-template" : { - "type" : "artifact-config-template", - "properties" : { - "action-names" : [ "resource-assignment-action" ] - }, - "capabilities" : { - "content" : { - "properties" : { - "content" : "db://base-config-template" - } - }, - "mapping" : { - "properties" : { - "mapping" : [ { - "name" : "rs-db-source", - "property" : { - "required" : true, - "type" : "string" - }, - "input-param" : false, - "dictionary-name" : "sample-db-source", - "dictionary-source" : "processor-db", - "dependencies" : [ "hostname" ], - "version" : 0 - }, { - "name" : "mdsal-source", - "property" : { - "description" : "", - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "dt-v4-aggregate" - } - }, - "input-param" : false, - "dictionary-name" : "sample-mdsal-source", - "dictionary-source" : "sdnc", - "dependencies" : [ "service-instance-id" ], - "version" : 0 - }, { - "name" : "hostname", - "property" : { - "required" : true, - "type" : "string" - }, - "dictionary-name" : "hostname", - "dictionary-source" : "input", - "version" : 0, - "input-param" : false - }, { - "name" : "service", - "property" : { - "required" : true, - "type" : "string" - }, - "dictionary-name" : "service", - "dictionary-source" : "input", - "version" : 0, - "input-param" : false - }, { - "name" : "service-instance-id", - "property" : { - "required" : true, - "type" : "string" - }, - "dictionary-name" : "service-instance-id", - "dictionary-source" : "input", - "version" : 0, - "input-param" : false - } ] - } - } - } - }, - "licence-template" : { - "type" : "artifact-config-template", - "properties" : { - "action-names" : [ "resource-assignment-action" ] - }, - "capabilities" : { - "content" : { - "properties" : { - "content" : "db://licence-template" - } - }, - "mapping" : { - "properties" : { - "mapping" : [ { - "name" : "licenses", - "property" : { - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "dt-license-key" - } - }, - "input-param" : false, - "dictionary-name" : "sample-licenses", - "dictionary-source" : "sdnc", - "dependencies" : [ "service-instance-id" ], - "version" : 0 - }, { - "name" : "service-instance-id", - "property" : { - "required" : true, - "type" : "string" - }, - "dictionary-name" : "service-instance-id", - "dictionary-source" : "input", - "version" : 0, - "input-param" : false - } ] - } - } - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json deleted file mode 100644 index 5584b10ea..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json deleted file mode 100644 index c6dd7948b..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "name": "sample-input-source" - }, - { - "name": "sample-default-source" - }, - { - "name": "sample-db-source" - }, - { - "name": "sample-mdsal-source" - } -] \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json deleted file mode 100644 index 334fb24e8..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "ipaddress", - "property": { - "description": "name of the ", - "type": "list", - "entry_schema": { - "type": "dt-v4-aggregate" - } - }, - "updated-by": "Brinda Santh (bs2796)", - "tags": "ipaddress", - "sources": { - "input": { - "type": "source-input" - } - } -} \ No newline at end of file -- cgit 1.2.3-korg