From b8f16f15fa937db113dbe2e3b3438469fa284a71 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 12 Dec 2018 16:49:04 -0500 Subject: Add multiple location repo for enhancer. Change-Id: I5333b30fad8d754caf8dc89956132e4637f28c26 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BluePrintRepoService.kt | 47 +++++++++++ .../core/service/BluePrintRepoFileService.kt | 71 ++++++++++++++++ .../core/service/BluePrintRepoService.kt | 98 ---------------------- .../core/service/BluePrintRepoFileServiceTest.kt | 10 +-- .../core/service/BluePrintRuntimeServiceTest.kt | 2 - 5 files changed, 123 insertions(+), 105 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt (limited to 'components/core') diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt new file mode 100644 index 00000000..efcb0c38 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt @@ -0,0 +1,47 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import java.io.Serializable + +/** + * BluePrintRepoFileService + * @author Brinda Santh + * + */ + +interface BluePrintRepoService : Serializable { + + @Throws(BluePrintException::class) + fun getNodeType(nodeTypeName: String): NodeType + + @Throws(BluePrintException::class) + fun getDataType(dataTypeName: String): DataType + + @Throws(BluePrintException::class) + fun getArtifactType(artifactTypeName: String): ArtifactType + + @Throws(BluePrintException::class) + fun getRelationshipType(relationshipTypeName: String): RelationshipType + + @Throws(BluePrintException::class) + fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt new file mode 100644 index 00000000..de338664 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt @@ -0,0 +1,71 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + +open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) + + private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + private val extension = ".json" + + override fun getDataType(dataTypeName: String): DataType { + val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(dataTypeName).plus(extension) + return getModelType(fileName, DataType::class.java) + } + + override fun getNodeType(nodeTypeName: String): NodeType { + val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) + return getModelType(fileName, NodeType::class.java) + } + + override fun getArtifactType(artifactTypeName: String): ArtifactType { + val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(artifactTypeName).plus(extension) + return getModelType(fileName, ArtifactType::class.java) + } + + override fun getRelationshipType(relationshipTypeName: String): RelationshipType { + val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(relationshipTypeName).plus(extension) + return getModelType(fileName, RelationshipType::class.java) + } + + override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { + val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(capabilityDefinitionName).plus(extension) + return getModelType(fileName, CapabilityDefinition::class.java) + } + + private fun getModelType(fileName: String, valueType: Class): T { + return JacksonUtils.readValueFromFile(fileName, valueType) + ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt deleted file mode 100644 index 5ca43952..00000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import java.io.Serializable - -/** - * BluePrintRepoFileService - * @author Brinda Santh - * - */ - -interface BluePrintRepoService : Serializable { - - @Throws(BluePrintException::class) - fun getNodeType(nodeTypeName: String): NodeType - - @Throws(BluePrintException::class) - fun getDataType(dataTypeName: String): DataType - - @Throws(BluePrintException::class) - fun getArtifactType(artifactTypeName: String): ArtifactType - - @Throws(BluePrintException::class) - fun getRelationshipType(relationshipTypeName: String): RelationshipType - - @Throws(BluePrintException::class) - fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition - -} - - -open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) - - private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) - private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) - private val extension = ".json" - - override fun getDataType(dataTypeName: String): DataType { - val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(dataTypeName).plus(extension) - return getModelType(fileName, DataType::class.java) - } - - override fun getNodeType(nodeTypeName: String): NodeType { - val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) - return getModelType(fileName, NodeType::class.java) - } - - override fun getArtifactType(artifactTypeName: String): ArtifactType { - val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(artifactTypeName).plus(extension) - return getModelType(fileName, ArtifactType::class.java) - } - - override fun getRelationshipType(relationshipTypeName: String): RelationshipType { - val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(relationshipTypeName).plus(extension) - return getModelType(fileName, RelationshipType::class.java) - } - - override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { - val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(capabilityDefinitionName).plus(extension) - return getModelType(fileName, CapabilityDefinition::class.java) - } - - private fun getModelType(fileName: String, valueType: Class): T { - return JacksonUtils.readValueFromFile(fileName, valueType) - ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index f7f995fb..f7ffc394 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -29,29 +29,29 @@ import kotlin.test.assertNotNull class BluePrintRepoFileServiceTest { private val basePath = "load/model_type" - private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath) + private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) @Test fun testGetDataType() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate") + val dataType = bluePrintRepoFileService.getDataType("dt-v4-aggregate") assertNotNull(dataType, "Failed to get DataType from repo") } @Test fun testGetNodeType() { - val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment") + val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment") assertNotNull(nodeType, "Failed to get NodeType from repo") } @Test fun testGetArtifactType() { - val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity") + val nodeType = bluePrintRepoFileService.getArtifactType("artifact-template-velocity") assertNotNull(nodeType, "Failed to get ArtifactType from repo") } @Test(expected = FileNotFoundException::class) fun testModelNotFound() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found") + val dataType = bluePrintRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 2f519802..cbcadeb3 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -53,8 +53,6 @@ class BluePrintRuntimeServiceTest { val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") assertNotNull(propContext, "Failed to populate interface property values") - assertEquals(propContext["process-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name") - assertEquals(propContext["version"], jsonNodeFromObject("sample-action"), "Failed to populate parameter version") } @Test -- cgit 1.2.3-korg