diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-12 12:32:25 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-11-12 12:32:25 -0500 |
commit | 2c505b980ea8942ba84fb99278dd1c34a5b5873c (patch) | |
tree | ac10df19ed9c0c5e571a2dcb5d58e43db2df36dc /components/core/src/test | |
parent | c8f708adf9cdb0789fd29cce64a5fb0e89bfb7ca (diff) |
Controller Blueprints Component Core
Modify test case blueprint data pointing to model catalog location.
Change-Id: I601eddf899516b01ae8624c96aa13c5e236c8e5b
Issue-ID: CCSDK-678
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core/src/test')
7 files changed, 43 insertions, 123 deletions
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt index 7a74ca476..6cfed3246 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt @@ -17,17 +17,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
-import org.apache.commons.io.FileUtils
-import org.junit.Before
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import java.io.File
-import java.nio.charset.Charset
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertNotNull
+
/**
*
*
@@ -37,30 +33,17 @@ class BluePrintContextTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- lateinit var bluePrintContext: BluePrintContext
-
- @Before
- fun setUp() {
-
- val basepath = "load/blueprints"
-
- bluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
- }
+ val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
@Test
- fun testBluePrintContextFromContent() {
- val fileName = "load/blueprints/baseconfiguration/Definitions/activation-blueprint.json"
- val content : String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
- val bpContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprint(content)
- assertNotNull(bpContext, "Failed to get blueprint content")
- assertNotNull(bpContext.serviceTemplate, "Failed to get blueprint content's service template")
+ fun testBluePrintContextCreation() {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
+ assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
}
@Test
fun testChainedProperty() {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment")
assertNotNull(nodeType, "Failed to get chained node type")
log.trace("Properties {}", JacksonUtils.getJson(nodeType, true))
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt deleted file mode 100644 index 5a5557d75..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.core.service
-
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import kotlin.test.assertNotNull
-
-/**
- *
- *
- * @author Brinda Santh
- */
-class BluePrintParserFactoryTest {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- @Test
- fun testBluePrintJson() {
- val basepath = "load/blueprints"
-
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
- log.trace("Blue Print {}",bluePrintContext.blueprintJson(true))
- }
-}
\ 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 68031d292..19c6c2f9d 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 @@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.NullNode
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
@@ -49,11 +50,11 @@ class BluePrintRuntimeServiceTest { val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)
bluePrintRuntimeService.assignInputs(inputNode)
- val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action")
+ val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")
assertNotNull(propContext, "Failed to populate interface property values")
- assertEquals(propContext.get("mode"), "sync".asJsonPrimitive(), "Failed to populate parameter process-name")
- assertEquals(propContext.get("version"), "1.0.0".asJsonPrimitive(), "Failed to populate parameter version")
+ 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
@@ -67,14 +68,13 @@ class BluePrintRuntimeServiceTest { BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),
"data/default-context.json", executionContext)
- val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")
-
- log.info("In Context {}", inContext)
+ val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment",
+ "DefaultComponentNode", "process")
assertNotNull(inContext, "Failed to populate interface input property values")
- assertEquals(inContext.get("action-name"), "sample-action".asJsonPrimitive(), "Failed to populate parameter action-name")
- assertEquals(inContext.get("request-id"), "12345".asJsonPrimitive(), "Failed to populate parameter action-name")
+ assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
+ assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ assertEquals(inContext["template-content"], jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name")
}
@Test
@@ -83,24 +83,18 @@ class BluePrintRuntimeServiceTest { val bluePrintRuntimeService = getBluePrintRuntimeService()
- val successValue: JsonNode = jsonNodeFromObject("Success")
- val paramValue: JsonNode = jsonNodeFromObject("param-content")
-
- bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "params", paramValue)
-
- bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")
-
- val resourceAssignmentParamsNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "resource-assignment-params")
-
- val statusNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "status")
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance())
- assertEquals(paramValue, resourceAssignmentParamsNode, "Failed to get operation property resource-assignment-params")
+ bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment",
+ "DefaultComponentNode", "process")
- assertEquals(successValue, statusNode, "Failed to get operation property status")
+ val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
+ "DefaultComponentNode", "process", "status")
+ assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status")
+ val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
+ "DefaultComponentNode", "process", "resource-assignment-params")
+ assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params")
}
@@ -123,7 +117,7 @@ class BluePrintRuntimeServiceTest { }
private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val blueprintBasePath: String = ("load/blueprints/baseconfiguration")
+ val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt index b05fcb61b..09c58170f 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt @@ -16,12 +16,11 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
-import org.junit.Before
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.junit.Before
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
/**
*
@@ -30,7 +29,6 @@ import com.att.eelf.configuration.EELFManager */
class BluePrintValidatorDefaultServiceTest {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- val basepath = "load/blueprints"
@Before
fun setUp(): Unit {
@@ -39,11 +37,13 @@ class BluePrintValidatorDefaultServiceTest { @Test
fun testValidateBluePrint() {
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- val properties : MutableMap<String, Any> = hashMapOf()
+
+ val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
+ val properties: MutableMap<String, Any> = hashMapOf()
+
val validatorService = BluePrintValidatorDefaultService()
- validatorService.validateBlueprint(bluePrintContext.serviceTemplate,properties)
+ validatorService.validateBlueprint(bluePrintContext.serviceTemplate, properties)
log.info("Validation Message {}", properties)
}
}
\ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt index ddb39a2d6..d5b184f6e 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt @@ -26,7 +26,7 @@ class BluePrintMetadataUtilsTest { @Test
fun testToscaMetaData(){
- val basePath : String = "load/blueprints/baseconfiguration"
+ val basePath : String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index c5f451ea6..be76593d8 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -29,7 +29,7 @@ class JacksonReactorUtilsTest { @Test
fun testReadValues() {
- val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json",
+ val serviceTemplate = JacksonReactorUtils.readValueFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json",
ServiceTemplate::class.java).block()
assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
@@ -38,7 +38,7 @@ class JacksonReactorUtilsTest { val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block()
assertNotNull(jsonContent, "Failed to get json content")
- val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")
+ val jsonNode = JacksonReactorUtils.jsonNodeFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json")
.block()
assertNotNull(jsonContent, "Failed to get json Node")
}
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt index c3718b27a..b5edab0fa 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -17,12 +17,10 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import kotlin.test.assertEquals
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@@ -35,19 +33,6 @@ class JacksonUtilsTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- val basePath = "load/blueprints"
-
- @Test
- fun testReadValues() {
- val content = ResourceResolverUtils.getFileContent("baseconfiguration/Definitions/activation-blueprint.json", basePath)
- val serviceTemplate = JacksonUtils.readValue(content, ServiceTemplate::class.java)
- assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
- assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
-
- val jsonContent = JacksonUtils.getJson(serviceTemplate, true)
- assertNotNull(jsonContent, "Failed to get json content")
- }
-
@Test
fun testJsonNodeFromClassPathFile() {
val filePath = "data/default-context.json"
@@ -56,7 +41,7 @@ class JacksonUtilsTest { @Test
fun testJsonNodeFromFile() {
- val filePath = basePath + "/baseconfiguration/Definitions/activation-blueprint.json"
+ val filePath = "src/test/resources/data/default-context.json"
JacksonUtils.jsonNodeFromFile(filePath)
}
|