summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core/src/test
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-07 14:51:50 -0500
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-07 14:51:50 -0500
commit03fde837e1eb307cc0a17dda5161f1215c6159ad (patch)
tree49543d04e227fd7335e9f3171aeecd8a5183b5dd /ms/controllerblueprints/modules/blueprint-core/src/test
parent148c18464cc0ac9948950009084d4338e456321b (diff)
Refactor components core and resource dict modules
Change-Id: I04e9e723d68a38ecefe48206e67fddbe43c55854 Issue-ID: CCSDK-1047 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt35
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt59
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt54
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt117
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt57
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt144
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt35
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt50
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt60
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt41
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt78
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt36
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt100
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json100
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json261
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json36
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json16
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts44
-rwxr-xr-xms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json36
-rwxr-xr-xms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl61
22 files changed, 1437 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt
new file mode 100644
index 000000000..1b315a211
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt
@@ -0,0 +1,35 @@
+/*
+ * 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
+
+import org.junit.Test
+import kotlin.test.assertEquals
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+class CustomFunctionsTest {
+ @Test
+ fun testFormat(): Unit {
+ val returnValue : String = format("This is {} for times {}", "test", 2)
+ assertEquals("This is test for times 2", returnValue, "Failed to format String")
+
+ val returnValue1 : String = format("This is test for times 2")
+ assertEquals("This is test for times 2", returnValue1, "Failed to format empty args")
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt
new file mode 100644
index 000000000..4c174f92e
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt
@@ -0,0 +1,59 @@
+/*
+ * 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.mock
+
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.*
+
+class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
+
+ override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
+ return listOf(BluePrintServiceTemplateValidatorImpl(this))
+ }
+
+ override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
+ return listOf(BluePrintDataTypeValidatorImpl(this))
+ }
+
+ override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
+ return listOf(BluePrintArtifactTypeValidatorImpl(this))
+ }
+
+ override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
+ return listOf(BluePrintNodeTypeValidatorImpl(this))
+ }
+
+ override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
+ return listOf(BluePrintTopologyTemplateValidatorImpl(this))
+ }
+
+ override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
+ return listOf(BluePrintNodeTemplateValidatorImpl(this))
+ }
+
+ override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
+ return listOf(BluePrintWorkflowValidatorImpl(this))
+ }
+
+ override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
+ return listOf(BluePrintPropertyDefinitionValidatorImpl(this))
+ }
+
+ override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
+ return listOf(BluePrintAttributeDefinitionValidatorImpl(this))
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt
new file mode 100644
index 000000000..0c4d94f3c
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt
@@ -0,0 +1,54 @@
+/*
+ * 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.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import kotlin.test.assertNotNull
+
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+class BluePrintContextTest {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ @Test
+ 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/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
new file mode 100644
index 000000000..d68892fc1
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
@@ -0,0 +1,117 @@
+/*
+ * 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.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+class BluePrintExpressionServiceTest {
+ @Test
+ fun testInputExpression() {
+ val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")
+ val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.inputExpression, " Failed to populate input expression data")
+ assertEquals("input-name", expressionData.inputExpression?.propertyName, "Failed to get propertyName from expression data")
+ }
+
+ @Test
+ fun testPropertyExpression() {
+ val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")
+ val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data")
+ assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName")
+
+ val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")
+ val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ assertNotNull(expressionData1, " Failed to populate expression data")
+ assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression")
+ assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data")
+ assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName")
+ assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")
+ }
+
+ @Test
+ fun testAttributeExpression() {
+ val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }")
+ val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data")
+ assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName")
+
+ val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")
+ val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ assertNotNull(expressionData1, " Failed to populate expression data")
+ assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data")
+ assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName")
+ assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")
+ }
+
+
+ @Test
+ fun testOutputOperationExpression() {
+ val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")
+ val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data")
+ assertEquals("SELF", expressionData.operationOutputExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("interface-name", expressionData.operationOutputExpression?.interfaceName, " Failed to get expected interfaceName")
+ assertEquals("operation-name", expressionData.operationOutputExpression?.operationName, " Failed to get expected operationName")
+ assertEquals("output-property-name", expressionData.operationOutputExpression?.propertyName, " Failed to get expected propertyName")
+ }
+
+
+ @Test
+ fun testArtifactExpression() {
+ val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")
+ val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data")
+ assertEquals("SELF", expressionData.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName")
+
+
+ val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")
+ val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ assertNotNull(expressionData1, " Failed to populate expression data")
+ assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data")
+ assertEquals("SELF", expressionData1.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
+ assertEquals("artifact-template", expressionData1.artifactExpression?.artifactName, " Failed to get expected artifactName")
+ assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location")
+ assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove")
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
new file mode 100644
index 000000000..6f942a365
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.service
+
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import kotlin.test.assertNotNull
+
+/**
+ * BluePrintRepoFileServiceTest
+ * @author Brinda Santh
+ *
+ */
+class BluePrintRepoFileServiceTest {
+
+ private val basePath = "load/model_type"
+ private val bluePrintRepoFileService = BluePrintRepoFileService(basePath)
+
+ @Test
+ fun testGetDataType() {
+ val dataType = bluePrintRepoFileService.getDataType("dt-v4-aggregate")
+ assertNotNull(dataType, "Failed to get DataType from repo")
+ }
+
+ @Test
+ fun testGetNodeType() {
+ val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment")
+ assertNotNull(nodeType, "Failed to get NodeType from repo")
+ }
+
+ @Test
+ fun testGetArtifactType() {
+ val nodeType = bluePrintRepoFileService.getArtifactType("artifact-template-velocity")
+ assertNotNull(nodeType, "Failed to get ArtifactType from repo")
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testModelNotFound() {
+ val dataType = bluePrintRepoFileService.getDataType("dt-not-found")
+ assertNotNull(dataType, "Failed to get DataType from repo")
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
new file mode 100644
index 000000000..7a178758a
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -0,0 +1,144 @@
+/*
+ * 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 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
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+class BluePrintRuntimeServiceTest {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ @Test
+ fun `test Resolve NodeTemplate Properties`() {
+ log.info("************************ testResolveNodeTemplateProperties **********************")
+
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ val inputDataPath = "src/test/resources/data/default-context.json"
+
+ val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)
+ bluePrintRuntimeService.assignInputs(inputNode)
+
+ val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService
+ .resolveNodeTemplateProperties("activate-process")
+
+ assertNotNull(propContext, "Failed to populate interface property values")
+ }
+
+ @Test
+ fun `test resolve NodeTemplate Capability Properties`() {
+ log.info("************************ testResolveNodeTemplateRequirementProperties **********************")
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ val executionContext = bluePrintRuntimeService.getExecutionContext()
+
+ BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),
+ "data/default-context.json", executionContext)
+
+ val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device",
+ "netconf")
+ assertNotNull(capProperties, "Failed to populate capability property values")
+ assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address")
+ assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number")
+ }
+
+ @Test
+ fun `test Resolve NodeTemplate Interface Operation Inputs`() {
+ log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")
+
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ val executionContext = bluePrintRuntimeService.getExecutionContext()
+
+ BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(),
+ "data/default-context.json", executionContext)
+
+ val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService
+ .resolveNodeTemplateInterfaceOperationInputs("resource-assignment",
+ "ResourceAssignmentComponent", "process")
+
+ assertNotNull(inContext, "Failed to populate interface input property values")
+ assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
+ assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ }
+
+ @Test
+ fun `test Resolve NodeTemplate Interface Operation Outputs`() {
+ log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************")
+
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance())
+
+ bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment",
+ "ResourceAssignmentComponent", "process")
+
+ val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
+ "ResourceAssignmentComponent", "process", "status")
+ assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status")
+
+ val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment",
+ "ResourceAssignmentComponent", "process", "resource-assignment-params")
+ assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params")
+
+ }
+
+ @Test
+ fun `test NodeTemplate Context Property`() {
+ log.info("************************ testNodeTemplateContextProperty **********************")
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
+ JacksonUtils.jsonNodeFromObject("context1-value"))
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
+ JacksonUtils.jsonNodeFromObject("context2-value"))
+
+ val keys = listOf("context1", "context2")
+
+ val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys)
+ assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties")
+ log.info("JSON Prepared Value Context {}", jsonValueNode)
+
+ }
+
+ private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
+
+ assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation")
+
+ return blueprintRuntime
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt
new file mode 100644
index 000000000..663a3751a
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt
@@ -0,0 +1,35 @@
+/*
+ * 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.utils.JacksonUtils
+import kotlin.test.assertNotNull
+
+class BluePrintTemplateServiceTest {
+
+ @Test
+ fun testGenerateContent() {
+
+ val template = JacksonUtils.getClassPathFileContent("templates/base-config-template.vtl")
+ val json = JacksonUtils.getClassPathFileContent("templates/base-config-data.json")
+
+ val content = BluePrintTemplateService.generateContent(template, json)
+ assertNotNull(content, "failed to generate content for velocity template")
+
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt
new file mode 100644
index 000000000..861f7d095
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt
@@ -0,0 +1,50 @@
+/*
+ * 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.junit.Before
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+class BluePrintValidatorDefaultServiceTest {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ @Before
+ fun setUp(): Unit {
+
+ }
+
+ @Test
+ fun testValidateBluePrint() {
+
+ val blueprintBasePath: String = ("./../../../../components/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)
+ log.info("Validation Message {}", properties)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt
new file mode 100644
index 000000000..528f2c6f2
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt
@@ -0,0 +1,60 @@
+/*
+ * 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.utils
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import java.io.File
+import java.nio.file.Paths
+import kotlin.test.assertTrue
+
+
+class BluePrintFileUtilsTest {
+
+ @Test
+ fun testNewBlueprint() = runBlocking {
+ val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-new-test")
+ BluePrintFileUtils.createEmptyBluePrint(targetPath)
+
+ }
+
+ @Test
+ fun testBlueprintCopy() = runBlocking {
+ val sourcePath: String = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+
+ val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-copy-test")
+
+ val targetDir = File(targetPath)
+ targetDir.deleteOnExit()
+ // Copy the BP file
+ BluePrintFileUtils.copyBluePrint(sourcePath, targetDir.absolutePath)
+
+ assertTrue(targetDir.exists(), "faield to copy blueprint to ${targetDir.absolutePath}")
+
+ // Delete Type Files
+ BluePrintFileUtils.deleteBluePrintTypes(targetDir.absolutePath)
+
+ // Generate the Type Files
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(sourcePath)
+ bluePrintContext.rootPath = targetDir.absolutePath
+
+ BluePrintFileUtils.writeBluePrintTypes(bluePrintContext)
+
+
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
new file mode 100644
index 000000000..80daad5d8
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
@@ -0,0 +1,41 @@
+/*
+ * 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.utils
+
+
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData
+import kotlin.test.assertNotNull
+
+class BluePrintMetadataUtilsTest {
+
+ @Test
+ fun testToscaMetaData(){
+
+ val basePath : String = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+
+ val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
+ assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
+ assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
+ assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
+ assertNotNull(toscaMetaData.createdBy, "Missing Created by")
+ assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition")
+ assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
+
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt
new file mode 100644
index 000000000..12156d659
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt
@@ -0,0 +1,78 @@
+/*
+ * 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.utils
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * JacksonUtilsTest
+ * @author Brinda Santh
+ * ${DATA}
+ */
+class JacksonUtilsTest {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ @Test
+ fun testJsonNodeFromClassPathFile() {
+ val filePath = "data/default-context.json"
+ JacksonUtils.jsonNodeFromClassPathFile(filePath)
+ }
+
+ @Test
+ fun testJsonNodeFromFile() {
+ val filePath = "src/test/resources/data/default-context.json"
+ JacksonUtils.jsonNodeFromFile(filePath)
+ }
+
+ @Test
+ fun testGetListFromJson() {
+ val content = "[\"good\",\"boy\" ]"
+ val nodeType = JacksonUtils.getListFromJson(content, String::class.java)
+ assertNotNull(nodeType, "Failed to get String array from content")
+ }
+
+
+ @Test
+ fun testJsonValue() {
+ val filePath = "data/alltype-data.json"
+ val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath)
+ assertNotNull(rootJson, "Failed to get all type data json node")
+ val intValue = rootJson.get("intValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value")
+ val floatValue = rootJson.get("floatValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value")
+ val stringValue = rootJson.get("stringValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value")
+ val booleanValue = rootJson.get("booleanValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value")
+ val arrayStringValue = rootJson.get("arrayStringValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value")
+ val mapValue = rootJson.get("mapValue")
+ assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value")
+
+ assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed")
+
+
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
new file mode 100644
index 000000000..5999dbfa5
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.utils
+
+import org.junit.Test
+
+class TopologicalSortingUtilsTest {
+
+ @Test
+ fun testSorting(): Unit {
+ val graph: TopologicalSortingUtils<String> = TopologicalSortingUtils()
+ graph.add("bundle-id", "bundle-mac")
+ graph.add("bundle-id", "bundle-ip")
+ graph.add("bundle-mac", "bundle-ip")
+ graph.add("bundle-ip", "bundle-mac")
+
+ println("The current graph: " + graph)
+ println("In-degrees: " + graph.inDegree())
+ println("Out-degrees: " + graph.outDegree())
+ println("A topological sort of the vertices: " + graph.topSort())
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
new file mode 100644
index 000000000..cfcbd9b2f
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
@@ -0,0 +1,100 @@
+/*
+ * 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.validation
+
+import io.mockk.every
+import io.mockk.mockk
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Step
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class BluePrintValidatorServiceImplTest {
+
+ private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+ private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
+
+ @Test
+ fun testValidateOfType() {
+ val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ assertTrue(valid, "failed in blueprint Validation")
+ }
+
+ @Test
+ fun testValidateWorkflowFailToFoundNodeTemplate() {
+ val workflowName = "resource-assignment"
+
+ val step = Step()
+ step.target = "TestCaseFailNoNodeTemplate"
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
+
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0])
+ }
+
+ @Test
+ fun testValidateWorkflowFailNodeTemplateNotDgGeneric() {
+ val workflowName = "resource-assignment"
+ val nodeTemplateName = "resource-assignment-process"
+
+ val nodeTemplate = mockk<NodeTemplate>()
+ every { nodeTemplate.type } returns "TestNodeType"
+
+ val nodeType = mockk<NodeType>()
+ every { nodeType.derivedFrom } returns "tosca.nodes.TEST"
+
+ val blueprintContext = mockk<BluePrintContext>()
+ every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate
+ every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType
+
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234")
+
+ every { bluePrintRuntime.getBluePrintError() } returns BluePrintError()
+ every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
+
+ val step = Step()
+ step.target = nodeTemplateName
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
+
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0])
+ }
+
+ @Test
+ fun testValidateWorkflowSuccess() {
+ val workflowName = "resource-assignment"
+ workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName))
+ }
+
+}
+
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json
new file mode 100644
index 000000000..a1982631b
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json
@@ -0,0 +1,100 @@
+{
+ "metadata": {
+ "template_author": "bs2796",
+ "vendor": "Juniper",
+ "os": "XXX",
+ "service-type": "AVPN",
+ "vnf-type": "VRR",
+ "action": "Base Configuration",
+ "sub-action": "Generate Configuration",
+ "template_name": "VRR-baseconfiguration",
+ "template_version": "1.0.0"
+ },
+ "topology_template": {
+ "inputs": {
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "vnf-id": {
+ "required": true,
+ "type": "string"
+ },
+ "service": {
+ "required": true,
+ "type": "string"
+ },
+ "region": {
+ "required": true,
+ "type": "string"
+ },
+ "bundle-id": {
+ "required": true,
+ "type": "string"
+ },
+ "bundle-mac": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "node_templates": {
+ "generate-configuration": {
+ "type": "mock-component-generateConfig",
+ "interfaces": {
+ "org-onap-ccsdk-config-params-service-MockComponentNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "entity-type": "vnf-type",
+ "template-content": "sample-template",
+ "entity-id": { "get_input" : "vnf-id" }
+ },
+ "outputs": {
+ "mergedData": "merged Data",
+ "status": "status"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "node_types": {
+ "mock-component-generateConfig": {
+ "interfaces": {
+ "org-onap-ccsdk-config-params-service-MockComponentNode": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "entity-type": {
+ "required": false,
+ "type": "string"
+ },
+ "template-content": {
+ "required": false,
+ "type": "string"
+ },
+ "entity-id": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "outputs": {
+ "generated-config": {
+ "required": true,
+ "type": "string"
+ },
+ "status": {
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Component"
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json
new file mode 100644
index 000000000..055b09658
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json
@@ -0,0 +1,10 @@
+{
+ "intValue" : 1,
+ "floatValue" : 1.34,
+ "booleanValue" : true,
+ "stringValue" : "sample-String",
+ "timeValue" : "2018-09-29",
+ "arrayStringValue" : ["one", "two"],
+ "mapValue" : {"profile_name1":"profile_name1",
+ "profile_name2":"profile_name2"}
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json
new file mode 100644
index 000000000..3968626b8
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json
@@ -0,0 +1,7 @@
+{
+ "request-id" : "12345",
+ "hostname" : "localhost",
+ "template_name": "baseconfiguration",
+ "template_version": "1.0.0",
+ "action-name" : "sample-action"
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json
new file mode 100644
index 000000000..cac8770af
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json
@@ -0,0 +1,261 @@
+{
+ "type": "object",
+ "properties": {
+ "resource-path": {
+ "type": "string",
+ "required": true
+ },
+ "description": {
+ "type": "string"
+ },
+ "updated-by": {
+ "type": "string"
+ },
+ "data-type": {
+ "type": "string",
+ "required": true
+ },
+ "source": {
+ "type": "object",
+ "required": true,
+ "properties": {
+ "input": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string"
+ }
+ }
+ },
+ "component": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "required": true
+ },
+ "input-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "default": {
+ "type": "any"
+ },
+ "aai": {
+ "type": "any"
+ },
+ "primary-config-data": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string",
+ "required": true
+ },
+ "url-path": {
+ "type": "string",
+ "required": true
+ },
+ "input-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "type": {
+ "type": "string",
+ "required": true
+ },
+ "output-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "base": {
+ "type": "string",
+ "required": true
+ }
+ }
+ },
+ "network-resource-discovery": {
+ "type": "object",
+ "properties": {
+ "input-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "primary-db": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "required": true
+ },
+ "input-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "type": {
+ "type": "string",
+ "required": true
+ },
+ "output-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "base": {
+ "type": "string",
+ "required": true
+ }
+ }
+ },
+ "policy": {
+ "type": "object",
+ "properties": {
+ "input-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "candidate-dependency": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "component": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "aai": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "primary-config-data": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "network-resource-discovery": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "primary-db": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "policy": {
+ "type": "object",
+ "properties": {
+ "names": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": {
+ "type": "string"
+ },
+ "default": {
+ "type": "any"
+ },
+ "name": {
+ "type": "string",
+ "required": true
+ },
+ "valid-values": {
+ "type": "string"
+ },
+ "resource-type": {
+ "type": "string",
+ "required": true
+ },
+ "sample-value": {
+ "type": "string"
+ },
+ "entry-schema": {
+ "type": "string"
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json
new file mode 100644
index 000000000..f7893ce53
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json
@@ -0,0 +1,36 @@
+{
+ "type": "sdnc-component-getResourceAssignment",
+ "interfaces": {
+ "ResourceAssignmentService": {
+ "operations": {
+ "getResourceAssignment": {
+ "inputs": {
+ "assignment-mappings": [
+ {
+ "name": "service-name",
+ "mapping-field": "service",
+ "mapping-category": "SDN",
+ "required": true
+ },
+ {
+ "name": "region-name",
+ "mapping-field": "region",
+ "mapping-category": "SDN",
+ "required": true
+ }
+ ],
+ "pre-data": {
+ "get_input": "get-resource-assignment.config-params"
+ },
+ "prifix": "get-resource-assignment"
+ },
+ "outputs": {
+ "resource-assignment-status": "success",
+ "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params"
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json
new file mode 100644
index 000000000..9f17574e7
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json
@@ -0,0 +1,16 @@
+{
+ "default": { "get_input" : "loopback-default" },
+ "domain": "ethernet",
+ "criteria": [
+ {
+ "value": "attga301me1",
+ "type": "complex",
+ "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"
+ },
+ {
+ "value": { "get_input" : "host-ip-address" },
+ "type": "simple",
+ "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"
+ }
+ ]
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts
new file mode 100644
index 000000000..44cc957d2
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+
+open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String>{
+
+ override fun getName(): String {
+ return "Kotlin-Script-Function-Node"
+ }
+
+ override fun prepareRequest(executionRequest: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun prepareResponse(): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun apply(t: String): String {
+ return "$t-status"
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json
new file mode 100755
index 000000000..2acc6fcdd
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json
@@ -0,0 +1,36 @@
+{
+ "node0_hostname": "sdnc-host",
+ "node0_backup_router_address": "2001:1890:1253::192:168:100:1",
+ "servers": [
+ "Server1",
+ "Server2",
+ "Server3"
+ ],
+ "tacplus-servers": [
+ {
+ "tacplus-server-name": "tacplus-server-name1",
+ "tacplus-server-source-address": "enc-dsdsasa1"
+ },
+ {
+ "tacplus-server-name": "tacplus-server-name2",
+ "tacplus-server-source-address": "enc-dsdsasa2"
+ }
+ ],
+ "classes": [
+ {
+ "name": "superuser-class",
+ "idle-timeout": 5,
+ "permissions": "all"
+ },
+ {
+ "name": "tacacs-adv-class",
+ "idle-timeout": 5
+ },
+ {
+ "name": "tacacs-base-class",
+ "idle-timeout": 5
+ }
+ ],
+ "system-password": "teamops-system-password",
+ "root-password": "teamops-root-password"
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl
new file mode 100755
index 000000000..f7b1269b3
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl
@@ -0,0 +1,61 @@
+<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"
+xmlns:a="http://xml.juniper.net/junos/15.1X49/junos">
+ <version>15.1X49-D50.3</version>
+ <groups>
+ <name>node0</name>
+ <system>
+ #foreach($server in ${servers})
+ <server-host-name>$StringUtils.upperCase("$server")</server-host-name>
+ #end
+ </system>
+ <system>
+ <host-name>${node0_hostname}</host-name>
+ <backup-router>
+ <address>${node0_backup_router_address}</address>
+ <destination>$node0_backup_router_address</destination>
+ </backup-router>
+ #foreach($tacplus-server in ${tacplus-servers})
+ <tacplus-server>
+ <name>$tacplus-server.tacplus-server-name</name>
+ <source-address>$tacplus-server.tacplus-server-source-address</source-address>
+ </tacplus-server>
+ #end
+ <login>
+ <message>ONAP information assets</message>
+ #foreach($class in ${classes})
+ <class>
+ <name>$class.name</name>
+ <idle-timeout>$class.idle-timeout</idle-timeout>
+ #if ($class.permissions)
+ <permissions>$class.permissions</permissions>
+ #end
+ </class>
+ #end
+ <user>
+ <name>readonly</name>
+ <full-name>Read Only Account Access</full-name>
+ <uid>1001</uid>
+ <class>tacacs-base-class</class>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Read - Write Account Access</full-name>
+ <uid>1002</uid>
+ <class>tacacs-adv-class</class>
+ <authentication>
+ <encrypted-password>${system-password}</encrypted-password>
+ </authentication>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Emergency Access Only</full-name>
+ <uid>1000</uid>
+ <class>superuser-class</class>
+ <authentication>
+ <encrypted-password>${root-password}</encrypted-password>
+ </authentication>
+ </user>
+ </login>
+ </system>
+ </groups>
+</configuration> \ No newline at end of file