From c90edac236dffb7c495e266dd04991de7e8f04b7 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 25 Mar 2019 13:04:18 -0400 Subject: Migrate ccsdk/apps to ccsdk/cds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: CCSDK-1177 Issue-ID: CCSDK-1178 Change-Id: I0c02702fbec52211ca367abbba72aebecee8cbaa Signed-off-by: Alexis de Talhouët --- .../core/CustomFunctionsTest.kt | 35 ---- .../core/service/BluePrintContextTest.kt | 54 ------- .../core/service/BluePrintExpressionServiceTest.kt | 131 --------------- .../core/service/BluePrintRepoFileServiceTest.kt | 57 ------- .../core/service/BluePrintRuntimeServiceTest.kt | 180 --------------------- .../core/service/BluePrintTemplateServiceTest.kt | 35 ---- .../core/utils/BluePrintFileUtilsTest.kt | 60 ------- .../core/utils/BluePrintMetadataUtilsTest.kt | 57 ------- .../core/utils/JacksonReactorUtilsTest.kt | 43 ----- .../core/utils/JacksonUtilsTest.kt | 78 --------- .../core/utils/JsonParserUtilsTest.kt | 33 ---- .../core/utils/TopologicalSortingUtilsTest.kt | 36 ----- .../core/CustomFunctionsTest.kt | 35 ++++ .../core/service/BluePrintContextTest.kt | 54 +++++++ .../core/service/BluePrintExpressionServiceTest.kt | 131 +++++++++++++++ .../core/service/BluePrintRepoFileServiceTest.kt | 57 +++++++ .../core/service/BluePrintRuntimeServiceTest.kt | 180 +++++++++++++++++++++ .../core/service/BluePrintTemplateServiceTest.kt | 35 ++++ .../core/utils/BluePrintFileUtilsTest.kt | 60 +++++++ .../core/utils/BluePrintMetadataUtilsTest.kt | 57 +++++++ .../core/utils/JacksonReactorUtilsTest.kt | 43 +++++ .../core/utils/JacksonUtilsTest.kt | 78 +++++++++ .../core/utils/JsonParserUtilsTest.kt | 33 ++++ .../core/utils/TopologicalSortingUtilsTest.kt | 36 +++++ .../scripts/SampleBlueprintFunctionNode.kts | 2 +- 25 files changed, 800 insertions(+), 800 deletions(-) delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test') 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 deleted file mode 100644 index 1b315a211..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt +++ /dev/null @@ -1,35 +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 - -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/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt deleted file mode 100644 index 1bd95f322..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt +++ /dev/null @@ -1,54 +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.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/test-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-resolution") - 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 deleted file mode 100644 index 589100552..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt +++ /dev/null @@ -1,131 +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.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive -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") - } - - @Test - fun testDSLExpression() { - val node: JsonNode = "*dynamic-rest-source".asJsonPrimitive() - val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.dslExpression, " Failed to populate dsl expression data") - assertEquals("dynamic-rest-source", expressionData.dslExpression!!.propertyName, - " Failed to populate dsl property name") - } -} \ 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 deleted file mode 100644 index 6f942a365..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ /dev/null @@ -1,57 +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 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 deleted file mode 100644 index dc56b5207..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018-2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.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.data.PropertyDefinition -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 = 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 assignmentParams = "{\n" + - " \"ipAddress\": \"127.0.0.1\",\n" + - " \"hostName\": \"vnf-host\"\n" + - " }" - - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", - JacksonUtils.jsonNode(assignmentParams)) - - val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", - "netconf") - assertNotNull(capProperties, "Failed to populate capability property values") - assertEquals(capProperties["target-ip-address"], "127.0.0.1".asJsonPrimitive(), "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 = bluePrintRuntimeService - .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "ResourceResolutionComponent", "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", - "ResourceResolutionComponent", "process") - - val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "ResourceResolutionComponent", "process", "status") - assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") - - val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "ResourceResolutionComponent", "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) - - } - - @Test - fun `test Resolve DSL Properties`() { - log.info("************************ resolveDSLExpression **********************") - - val bluePrintRuntimeService = getBluePrintRuntimeService() - - bluePrintRuntimeService.setInputValue("rest-user-name", PropertyDefinition(), "sample-username" - .asJsonPrimitive()) - - val resolvedJsonNode: JsonNode = bluePrintRuntimeService.resolveDSLExpression("dynamic-rest-source") - assertNotNull(resolvedJsonNode, "Failed to populate dsl property values") - } - - @Test - fun `test Resolve Workflow Outputs`() { - log.info("************************ resolvePropertyAssignments **********************") - val bluePrintRuntimeService = getBluePrintRuntimeService() - - val assignmentParams = "{\"ipAddress\": \"127.0.0.1\", \"hostName\": \"vnf-host\"}" - - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", - JacksonUtils.jsonNode(assignmentParams)) - - val resolvedJsonNode = bluePrintRuntimeService.resolveWorkflowOutputs("resource-assignment") - assertNotNull(resolvedJsonNode, "Failed to populate workflow output property values") - } - - private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { - val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-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 deleted file mode 100644 index 663a3751a..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt +++ /dev/null @@ -1,35 +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.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/utils/BluePrintFileUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt deleted file mode 100644 index 129317312..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt +++ /dev/null @@ -1,60 +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.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/test-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 deleted file mode 100644 index 366ce4a89..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt +++ /dev/null @@ -1,57 +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.utils - - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -class BluePrintMetadataUtilsTest { - - @Test - fun testToscaMetaData() { - - val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-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") - - } - - @Test - fun environmentDataTest() { - val environmentPath = "./src/test/resources/environments" - - val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath) - - assertNotNull(properties, "Could not read the properties") - assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1") - assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.password"), "password1", "failed 2") - assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.username"), "username2", "failed 3") - assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4") - assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5") - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt deleted file mode 100644 index 9cf8d62af..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import kotlinx.coroutines.runBlocking -import org.junit.Test - -class JacksonReactorUtilsTest { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @Test - fun testJsonNodeFromClassPathFile() { - runBlocking { - val filePath = "data/default-context.json" - JacksonReactorUtils.jsonNodeFromClassPathFile(filePath) - } - } - - @Test - fun testJsonNodeFromFile() { - runBlocking { - val filePath = "src/test/resources/data/default-context.json" - JacksonReactorUtils.jsonNodeFromFile(filePath) - } - } -} \ 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 deleted file mode 100644 index 12156d659..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ /dev/null @@ -1,78 +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.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/JsonParserUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt deleted file mode 100644 index 1f0039999..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive -import kotlin.test.assertEquals - -class JsonParserUtilsTest { - - @Test - fun `test parse Node`() { - val dataNode = JacksonUtils.jsonNodeFromClassPathFile("data/default-context.json") - - val parsedNode = JsonParserUtils.parse(dataNode, "$.request-id") - - assertEquals(parsedNode, "12345".asJsonPrimitive(), "failed to parse json request-id") - } -} \ 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 deleted file mode 100644 index 5999dbfa5..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt +++ /dev/null @@ -1,36 +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.utils - -import org.junit.Test - -class TopologicalSortingUtilsTest { - - @Test - fun testSorting(): Unit { - val graph: TopologicalSortingUtils = 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/cds/controllerblueprints/core/CustomFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt new file mode 100644 index 000000000..d5334dc5f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.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/cds/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt new file mode 100644 index 000000000..ac21f132c --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.controllerblueprints.core.service + + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Test +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.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/test-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-resolution") + 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/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt new file mode 100644 index 000000000..d2363ab9d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt @@ -0,0 +1,131 @@ +/* + * 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.cds.controllerblueprints.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.junit.Test +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.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") + } + + @Test + fun testDSLExpression() { + val node: JsonNode = "*dynamic-rest-source".asJsonPrimitive() + val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.dslExpression, " Failed to populate dsl expression data") + assertEquals("dynamic-rest-source", expressionData.dslExpression!!.propertyName, + " Failed to populate dsl property name") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt new file mode 100644 index 000000000..ac4fc6aea --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.controllerblueprints.core.service + +import org.junit.Test +import org.onap.ccsdk.cds.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/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt new file mode 100644 index 000000000..3c573c483 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -0,0 +1,180 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018-2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.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.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintRuntimeUtils +import org.onap.ccsdk.cds.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 = 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 assignmentParams = "{\n" + + " \"ipAddress\": \"127.0.0.1\",\n" + + " \"hostName\": \"vnf-host\"\n" + + " }" + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams)) + + val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", + "netconf") + assertNotNull(capProperties, "Failed to populate capability property values") + assertEquals(capProperties["target-ip-address"], "127.0.0.1".asJsonPrimitive(), "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 = bluePrintRuntimeService + .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", + "ResourceResolutionComponent", "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", + "ResourceResolutionComponent", "process") + + val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "ResourceResolutionComponent", "process", "status") + assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") + + val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "ResourceResolutionComponent", "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) + + } + + @Test + fun `test Resolve DSL Properties`() { + log.info("************************ resolveDSLExpression **********************") + + val bluePrintRuntimeService = getBluePrintRuntimeService() + + bluePrintRuntimeService.setInputValue("rest-user-name", PropertyDefinition(), "sample-username" + .asJsonPrimitive()) + + val resolvedJsonNode: JsonNode = bluePrintRuntimeService.resolveDSLExpression("dynamic-rest-source") + assertNotNull(resolvedJsonNode, "Failed to populate dsl property values") + } + + @Test + fun `test Resolve Workflow Outputs`() { + log.info("************************ resolvePropertyAssignments **********************") + val bluePrintRuntimeService = getBluePrintRuntimeService() + + val assignmentParams = "{\"ipAddress\": \"127.0.0.1\", \"hostName\": \"vnf-host\"}" + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams)) + + val resolvedJsonNode = bluePrintRuntimeService.resolveWorkflowOutputs("resource-assignment") + assertNotNull(resolvedJsonNode, "Failed to populate workflow output property values") + } + + private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { + val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-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/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt new file mode 100644 index 000000000..6a193c37e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.controllerblueprints.core.service + +import org.junit.Test +import org.onap.ccsdk.cds.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/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt new file mode 100644 index 000000000..8517e7536 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.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/test-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/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt new file mode 100644 index 000000000..7a1fb6d9e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.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.cds.controllerblueprints.core.utils + + +import org.junit.Test +import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull + +class BluePrintMetadataUtilsTest { + + @Test + fun testToscaMetaData() { + + val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-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") + + } + + @Test + fun environmentDataTest() { + val environmentPath = "./src/test/resources/environments" + + val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath) + + assertNotNull(properties, "Could not read the properties") + assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1") + assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.password"), "password1", "failed 2") + assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.username"), "username2", "failed 3") + assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4") + assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt new file mode 100644 index 000000000..8812816ba --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.runBlocking +import org.junit.Test + +class JacksonReactorUtilsTest { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @Test + fun testJsonNodeFromClassPathFile() { + runBlocking { + val filePath = "data/default-context.json" + JacksonReactorUtils.jsonNodeFromClassPathFile(filePath) + } + } + + @Test + fun testJsonNodeFromFile() { + runBlocking { + val filePath = "src/test/resources/data/default-context.json" + JacksonReactorUtils.jsonNodeFromFile(filePath) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt new file mode 100644 index 000000000..3d1721384 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Test +import org.onap.ccsdk.cds.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/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt new file mode 100644 index 000000000..9728a2255 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.core.utils + +import org.junit.Test +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import kotlin.test.assertEquals + +class JsonParserUtilsTest { + + @Test + fun `test parse Node`() { + val dataNode = JacksonUtils.jsonNodeFromClassPathFile("data/default-context.json") + + val parsedNode = JsonParserUtils.parse(dataNode, "$.request-id") + + assertEquals(parsedNode, "12345".asJsonPrimitive(), "failed to parse json request-id") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt new file mode 100644 index 000000000..08b77bd4e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.cds.controllerblueprints.core.utils + +import org.junit.Test + +class TopologicalSortingUtilsTest { + + @Test + fun testSorting(): Unit { + val graph: TopologicalSortingUtils = 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/resources/scripts/SampleBlueprintFunctionNode.kts b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts index 44cc957d2..439351b05 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts @@ -14,7 +14,7 @@ * limitations under the License. */ -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode open class SampleBlueprintFunctionNode : BlueprintFunctionNode{ -- cgit 1.2.3-korg