diff options
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test')
42 files changed, 0 insertions, 3415 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt deleted file mode 100644 index 6a028d36f..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintErrorTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.onap.ccsdk.cds.controllerblueprints.core - -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class BluePrintErrorTest { - - @Test - fun testBluePrintErrorIsCreatedWithemptyList() { - val bluePrintError = BluePrintError() - - assertTrue(bluePrintError.errors.isEmpty()) - } - - @Test - fun testAddErrorWith3Params() { - val bluePrintError = BluePrintError() - - bluePrintError.addError("type", "name", "error") - - assertEquals("type : name : error", bluePrintError.errors[0]) - } - - @Test - fun testAddErrorWith1Params() { - val bluePrintError = BluePrintError() - - bluePrintError.addError("error") - - assertEquals("error", bluePrintError.errors[0]) - } -} 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 deleted file mode 100644 index 3ae87b32d..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core - -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.ArrayNode -import com.fasterxml.jackson.databind.node.BooleanNode -import com.fasterxml.jackson.databind.node.IntNode -import com.fasterxml.jackson.databind.node.JsonNodeType -import com.fasterxml.jackson.databind.node.MissingNode -import com.fasterxml.jackson.databind.node.NullNode -import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.databind.node.TextNode -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertNotNull -import kotlin.test.assertNull -import kotlin.test.assertTrue - -/** - * - * - * @author Brinda Santh - */ -class CustomFunctionsTest { - - @Test - fun testFormat() { - 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") - } - - @Test - fun testStringAsJsonPrimitive() { - val returnValue: TextNode = "hello".asJsonPrimitive() - assertEquals("hello", returnValue.textValue()) - } - - @Test - fun testIntAsJsonPrimitive() { - val returnValue: IntNode = 1.asJsonPrimitive() - assertEquals(1, returnValue.intValue()) - } - - @Test - fun testBooleanAsJsonPrimitive() { - val returnValue: BooleanNode = false.asJsonPrimitive() - assertFalse(returnValue.asBoolean()) - } - - @Test - fun testAsJsonType() { - val nullReturnValue: JsonNode = null.asJsonType() - assertEquals(NullNode.instance, nullReturnValue) - - val returnValueString: JsonNode = "hello".asJsonType() - assertEquals("hello", returnValueString.textValue()) - - val returnValueJsonNode: JsonNode = returnValueString.asJsonType() - assertEquals(returnValueString, returnValueJsonNode) - - val returnValueInt: JsonNode = 1.asJsonType() - assertEquals(1, returnValueInt.intValue()) - - val returnValueBool: JsonNode = false.asJsonType() - assertFalse(returnValueBool.asBoolean()) - - val returnValue: JsonNode = BluePrintError().asJsonType() - assertEquals(JsonNodeType.OBJECT, returnValue.getNodeType()) - } - - @Test - fun testMapAsObjectNode() { - val returnValue: ObjectNode = hashMapOf("test" to BluePrintError()).asObjectNode() - assertNotNull(returnValue.get("test")) - } - - @Test - fun testCastOptionalValue() { - val initMap: Map<String, *> = hashMapOf("test" to 1.1, "test2" to null) - val returnValue = initMap.castOptionalValue("test", Number::class) - - assert(returnValue is Number) - - val returnValueNull = initMap.castOptionalValue("test1", Number::class) - - assertNull(returnValueNull) - - val returnValueString: String? = initMap.castOptionalValue("test2", String::class) - - assertNull(returnValueString) - } - - @Test(expected = BluePrintException::class) - fun testCastValue() { - val initMap: Map<String, Double> = hashMapOf("test" to 1.1) - val returnValue = initMap.castValue("test", Number::class) - - assertNotNull(returnValue) - - initMap.castValue("test1", Number::class) - } - - @Test - fun testAsListOfString() { - val arrayNode: ArrayNode = ObjectMapper().createObjectNode().putArray("array") - - val result: List<String> = arrayNode.asListOfString() - - assertTrue(result.isEmpty()) - } - - @Test - fun testReturnNullIfMissing() { - val valueExist = "hello".asJsonType().returnNullIfMissing() - assertNotNull(valueExist) - - val valueNull = NullNode.instance.returnNullIfMissing() - assertNull(valueNull) - - val missingValue = MissingNode.getInstance().returnNullIfMissing() - assertNull(missingValue) - } - - @Test - fun testIsNullOrMissing() { - assertTrue(NullNode.instance.isNullOrMissing()) - assertTrue(MissingNode.getInstance().isNullOrMissing()) - - assertFalse(TextNode("").isNullOrMissing()) - assertFalse("".asJsonType().isNullOrMissing()) - assertFalse("hello".asJsonType().isNullOrMissing()) - assertFalse("{\"key\": \"value\"}".asJsonType().isNullOrMissing()) - assertFalse(TextNode("hello").isNullOrMissing()) - } - - @Test - fun testIsComplexType() { - assertFalse(NullNode.instance.isComplexType()) - assertFalse(MissingNode.getInstance().isComplexType()) - - assertFalse(TextNode("").isComplexType()) - assertFalse("".asJsonType().isComplexType()) - assertFalse("hello".asJsonType().isComplexType()) - assertFalse(TextNode("hello").isComplexType()) - - assertTrue("{\"key\": \"value\"}".asJsonType().isComplexType()) - assertTrue("[{\"key\": \"value\"},{\"key\": \"value\"}]".asJsonType().isComplexType()) - } - - @Test(expected = BluePrintException::class) - fun testRootFieldsToMap() { - 1.asJsonType().rootFieldsToMap() - } - - @Test - fun testPutJsonElement() { - val mutMap = mutableMapOf("test" to 2.asJsonType()) - - mutMap.putJsonElement("hello", 3) - - assertEquals(3, mutMap["hello"]?.asInt()) - } - - @Test(expected = BluePrintException::class) - fun testMapGetAsString() { - val initMap = hashMapOf("test" to "hello".asJsonType()) - - assertEquals("hello", initMap.getAsString("test")) - - initMap.getAsString("test2") - } - - @Test(expected = BluePrintException::class) - fun testMapGetAsBoolean() { - val initMap = hashMapOf("test" to true.asJsonType()) - - assertTrue(initMap.getAsBoolean("test")) - - initMap.getAsBoolean("test2") - } - - @Test(expected = BluePrintException::class) - fun testMapGetAsInt() { - val initMap = hashMapOf("test" to 1.asJsonType()) - - assertEquals(1, initMap.getAsInt("test")) - - initMap.getAsInt("test2") - } - - @Test(expected = BluePrintException::class) - fun testCheckEquals() { - assertTrue(checkEquals("hello", "hello", { -> "error" })) - - checkEquals("hello", "test", { -> "error" }) - } - - @Test(expected = IllegalStateException::class) - fun testCheckNotEmpty() { - assertEquals("hello", checkNotEmpty("hello", { -> "error" })) - - checkNotEmpty("", { -> "error" }) - } - - @Test(expected = IllegalStateException::class) - fun testCheckNotBlank() { - assertEquals("hello", checkNotBlank("hello", { -> "error" })) - - checkNotBlank(" ", { -> "error" }) - } - - @Test - fun testNullToEmpty() { - assertEquals("", nullToEmpty(null)) - - assertEquals("hello", nullToEmpty("hello")) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt deleted file mode 100644 index 81f4a0091..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core - -import org.junit.Test -import kotlin.test.assertTrue - -class FileExtensionFunctionTest { - val blueprintBasePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" - - @Test - fun testCompress() { - val blueprintFile = normalizedFile(blueprintBasePath) - val targetZip = normalizedFile("target", "compress.zip") - targetZip.deleteRecursively() - blueprintFile.compress(targetZip) - assertTrue(blueprintFile.exists(), "failed to create compressed file(${targetZip.absolutePath} ") - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt deleted file mode 100644 index 86cb473ae..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core - -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel -import kotlin.test.assertNotNull - -class GraphExtensionFunctionsTest { - - @Test - fun testGraph() { - val graph = "[p>q/SUCCESS, m>q/SUCCESS, k, p>m/FAILURE, o>p/SUCCESS]".toGraph() - assertNotNull(graph, "failed to create graph") - assertNotNull(graph.toAdjacencyList(), "failed to adjacency list from graph") - - val neighbors = graph.nodes["p"]!!.neighbors() - assertNotNull(neighbors, "failed to neighbors from graph for 'p' node") - - val nodePath = graph.nodes["p"]!!.neighbors(EdgeLabel.SUCCESS) - assertNotNull(nodePath, "failed to nodePath from graph for 'p' node 'SUCCESS' label") - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt deleted file mode 100644 index 498a85239..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContextTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2018-2019 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 kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.junit.After -import org.junit.Before -import org.slf4j.MDC -import kotlin.test.Test -import kotlin.test.assertEquals - -class MDCContextTest { - val log = logger(MDCContextTest::class) - @Before - fun setup() { - MDC.clear() - } - - @After - fun tearDow() { - MDC.clear() - } - - @Test - fun testContextCanBePassedBetweenCoroutines() { - MDC.put(BluePrintConstants.ONAP_REQUEST_ID, "12345") - runBlocking { - GlobalScope.launch { - assertEquals(null, MDC.get(BluePrintConstants.ONAP_REQUEST_ID)) - } - launch(MDCContext()) { - assertEquals( - "12345", MDC.get(BluePrintConstants.ONAP_REQUEST_ID), - "couldn't get request id" - ) - - MDC.put("client_id", "client-1") - assertEquals("client-1", MDC.get("client_id"), "couldn't get client id") - } - } - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotationsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotationsTest.kt deleted file mode 100644 index a75262f96..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotationsTest.kt +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.annotations - -import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.asBluePrintsDataTypes -import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap -import kotlin.test.Test -import kotlin.test.assertNotNull - -class BluePrintsAnnotationsTest { - - @Test - fun testBluePrintWorkflowData() { - val wfInput = TestBluePrintsWorkflowInput::class.asPropertyDefinitionMap() - // println(wfInput.asJsonString(true)) - assertNotNull(wfInput, "failed to generate wfInput property map") - - val wfOutput = TestBluePrintsWorkflowOutput::class.asPropertyDefinitionMap() - // println(wfOutput.asJsonString(true)) - assertNotNull(wfInput, "failed to generate wfOutput property map") - } - - @Test - fun testBluePrintDataType() { - val dataTypes = TestBluePrintsDataType::class.asBluePrintsDataTypes() - // println(dataTypes.asJsonString(true)) - assertNotNull(dataTypes, "failed to generate dataTypes definition") - } -} - -@BluePrintsDataType( - name = "dt-test-datatype", description = "I am test", - version = "1.0.0", derivedFrom = "tosca.datatypes.root" -) -data class TestBluePrintsDataType( - @BluePrintsProperty(description = "this stringData") - var stringData: String, - @BluePrintsProperty(description = "this stringDataWithValue") - @PropertyDefaultValue(value = "USA") - val stringDataWithValue: String, - @BluePrintsProperty(description = "this intDataWithValue") - @PropertyDefaultValue(value = "30") - val intDataWithValue: Int, - @BluePrintsProperty(description = "this booleanDataWithValue") - @PropertyDefaultValue(value = "true") - val booleanDataWithValue: Boolean, - @BluePrintsProperty(description = "this anyData") - val anyData: Any, - @BluePrintsProperty(description = "this jsonDataWithValue") - @PropertyDefaultValue(value = """{"data" : "1234"}""") - val jsonDataWithValue: JsonNode?, - @BluePrintsProperty(description = "listData") - val listData: MutableList<String>, - @BluePrintsProperty(description = "this mapData") - val mapData: MutableMap<String, String> = hashMapOf(), - @BluePrintsProperty(description = "this complexData") - val complexData: TestBluePrintsChildDataType?, - @BluePrintsProperty(description = "this complexDataList") - val complexDataList: MutableList<TestBluePrintsChildDataType> -) - -data class TestBluePrintsChildDataType(val name: String) - -@BluePrintsWorkflowInput -data class TestBluePrintsWorkflowInput( - @BluePrintsProperty(description = "this sample name") - @PropertyDefaultValue(value = "Brinda") - var name: String, - @BluePrintsProperty(description = "this sample name") - val place: String -) - -@BluePrintsWorkflowOutput -data class TestBluePrintsWorkflowOutput( - @BluePrintsProperty(description = "this is dslExpression") - @DSLExpression("field1") - var dslExpression: String, - - @BluePrintsProperty(description = "this is withNodeAttributeExpression") - @AttributeExpression(modelableEntityName = "sample-node", attributeName = "response-data") - var withNodeAttributeExpression: String, - - @BluePrintsProperty(description = "this is withNodeAttributeExpressionSubAttribute") - @AttributeExpression( - modelableEntityName = "sample-node", attributeName = "response-data", - subAttributeName = ".\$field1" - ) - var withNodeAttributeExpressionSubAttribute: String, - - @BluePrintsProperty(description = "this is withAttributeExpressionSubAttribute") - @AttributeExpression(attributeName = "response-data", subAttributeName = ".\$field1") - var withAttributeExpressionSubAttribute: String, - - @BluePrintsProperty(description = "this is withAttributeExpression") - @AttributeExpression(attributeName = "response-data") - var withAttributeExpression: String, - - @BluePrintsProperty(description = "this is withAArtifactExpression") - @ArtifactExpression(modelableEntityName = "test-node", artifactName = "content-template") - var withAArtifactExpression: String, - - @BluePrintsProperty(description = "this status") - val status: String = "success" -) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt deleted file mode 100644 index c2d764bd6..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.dsl - -import com.fasterxml.jackson.databind.JsonNode -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType -import kotlin.test.assertNotNull - -class BluePrintDSLTest { - - @Test - fun testOperationDSLWorkflow() { - - val blueprint = blueprint( - "sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints" - ) { - - artifactType(BluePrintTypes.artifactTypeTemplateVelocity()) - - // For New Component Definition - component( - "resource-resolution", "component-script-executor", "1.0.0", - "Resource Resolution component." - ) { - implementation(180) - // Attributes ( Properties which will be set during execution) - attribute("template1-data", "string", true, "") - - // Properties - property("string-value1", "string", true, "sample") - property("string-value2", "string", true, getInput("key-1")) - // Inputs - input("json-content", "json", true, """{ "name" : "cds"}""") - input("template-content", "string", true, getArtifact("template1")) - // Outputs - output("self-attribute-expression", "json", true, getAttribute("template1-data")) - // Artifacts - artifact("template1", "artifact-template-velocity", "Templates/template1.vtl") - } - - // Already definitions Registered Components - registryComponent( - "activate-restconf", "component-resource-resolution", "1.0.0", - "RestconfExecutor", "Resource Resolution component." - ) { - implementation(180) - // Properties - property("string-value1", "data") - // Inputs - input("json-content", """{ "name" : "cds"}""") - // Outputs - output("self-attribute-expression", getAttribute("template1-data")) - // Artifacts - artifact("template2", "artifact-template-velocity", "Templates/template1.vtl") - } - - workflow("resource-resolution-process", "Resource Resolution wf") { - input("json-content", "json", true, "") - input("key-1", "string", true, "") - output("status", "string", true, "success") - step("resource-resolution-call", "resource-resolution", "Resource Resolution component invoke") - } - } - assertNotNull(blueprint.components, "failed to get components") - assertNotNull(blueprint.workflows, "failed to get workflows") - // println(blueprint.asJsonString(true)) - - val serviceTemplateGenerator = BluePrintServiceTemplateGenerator(blueprint) - val serviceTemplate = serviceTemplateGenerator.serviceTemplate() - assertNotNull(serviceTemplate.topologyTemplate, "failed to get service topology template") - // println(serviceTemplate.asJsonString(true)) - } - - @Test - fun testServiceTemplate() { - val serviceTemplate = serviceTemplate( - "sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints" - ) { - metadata("release", "1806") - import("Definition/data_types.json") - dsl("rest-endpoint", """{ "selector" : "odl-selector"}""") - dsl("db-endpoint", """{ "selector" : "db-selector"}""") - topologyTemplate { - nodeTemplateOperation( - nodeTemplateName = "activate", type = "sample-node-type", interfaceName = "RestconfExecutor", - description = "sample activation" - ) { - implementation(360, "SELF") { - primary("Scripts/sample.py") - dependencies("one", "two") - } - inputs { - property("json-content", """{ "name" : "cds"}""") - property("array-content", """["controller", "blueprints"]""") - property("int-value", 234) - property("boolean-value", true) - property("string-value", "sample") - property("input-expression", getInput("key-1")) - property("self-property-expression", getProperty("key-1")) - property("self-artifact-expression", getArtifact("key-1")) - property("other-artifact-expression", getNodeTemplateArtifact("node-1", "key-1")) - } - outputs { - property("self-attribute-expression", getAttribute("key-1")) - } - } - // Other way of defining Node Template with artifacts, implementation - nodeTemplate("resolve", "sample-resolve-type", "Resource Resolution") { - operation("ResourceResolutionExecutor", "") { - implementation(180) - inputs { - property("boolean-value", true) - property("string-value", "sample") - } - outputs { - property("resolve-expression", getAttribute("key-1")) - } - } - artifact("sample-template", "artifact-velocity", "Templates/sample-template.vtl") - } - - workflow("resource-resolution", "to resolve resources") { - step("resource-resolution-call", "resolve", "Resource Resolution component invoke") - } - // Alternate way to define workflow - workflow("activate", "to resolve resources") { - // Alternate step definition - step("netconf-activate-call", "activate", "call activation component") { - success("END") - failure("END") - } - inputs { - property("request-content", "json", true) - } - outputs { - property("response-content", "json", true) { - value(getAttribute("key-1")) - defaultValue("""{ "status" : "success"}""".jsonAsJsonType()) - } - } - } - } - } - - assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template") - assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates, "failed to get nodeTypes") - assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"], "failed to get nodeTypes(activate)") - // println(serviceTemplate.asJsonString(true)) - } - - @Test - fun testNodeTypePropertyConstrains() { - val nodeType = nodeType("data-node", "1.0.0", "tosca.Nodes.root", "") { - property("ip-address", "string", true, "") { - defaultValue("127.0.0.1") - constrain { - validValues(arrayListOf("""127.0.0.1""".asJsonPrimitive())) - length(10) - maxLength(20) - minLength(10) - } - } - property("disk-space", "string", true, "") { - defaultValue(10) - constrain { - validValues("""["200KB", "400KB"]""") - equal("200KB") - inRange("""["100KB", "500KB" ]""") - maxLength("10MB") - minLength("10KB") - } - constrain { - validValues("""[ 200, 400]""") - greaterOrEqual("10KB") - greaterThan("20KB") - lessOrEqual("200KB") - lessThan("190KB") - } - } - } - assertNotNull(nodeType, "failed to get nodeType") - // println(nodeType.asJsonString(true)) - } - - @Test - fun testServiceTemplateWorkflow() { - val serviceTemplate = serviceTemplate( - "sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints" - ) { - topologyTemplate { - workflowNodeTemplate("activate", "component-resource-resolution", "") { - operation("ResourceResolutionExecutor", "") { - inputs { - property("string-value", "sample") - } - } - } - } - } - assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template") - assertNotNull(serviceTemplate.topologyTemplate?.workflows?.get("activate"), "failed to get workflow(activate)") - // println(serviceTemplate.asJsonString(true)) - } - - @Test - fun testNodeTemplateOperationTypes() { - - val testNodeTemplateInstance = BluePrintTypes.nodeTemplateComponentTestExecutor( - id = "test-node-template", - description = "" - ) { - definedProperties { - prop1("i am property1") - prop2("i am property2") - } - definedOperation("") { - implementation(360) - inputs { - request("i am request") - } - outputs { - response(getAttribute("attribute1")) - } - } - } - assertNotNull(testNodeTemplateInstance, "failed to get test node template") - // println(testNodeTemplateInstance.asJsonString(true)) - } -} - -fun BluePrintTypes.nodeTemplateComponentTestExecutor( - id: String, - description: String, - block: TestNodeTemplateOperationImplBuilder.() -> Unit -): - NodeTemplate { - return TestNodeTemplateOperationImplBuilder(id, description).apply(block).build() -} - -class TestNodeTemplateOperationImplBuilder(id: String, description: String) : - AbstractNodeTemplateOperationImplBuilder<TestProperty, TestInput, TestOutput>( - id, "component-test-executor", - "ComponentTestExecutor", - description - ) - -class TestProperty : PropertiesAssignmentBuilder() { - fun prop1(prop1: String) { - property("prop1", prop1.asJsonPrimitive()) - } - - fun prop2(prop2: String) { - property("prop2", prop2.asJsonPrimitive()) - } -} - -class TestInput : PropertiesAssignmentBuilder() { - fun request(request: String) { - property("request", request.asJsonPrimitive()) - } -} - -class TestOutput : PropertiesAssignmentBuilder() { - fun response(response: String) { - response(response.asJsonPrimitive()) - } - - fun response(response: JsonNode) { - property("response", response) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt deleted file mode 100644 index 60bef8a8d..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.scripts - -import kotlinx.coroutines.runBlocking -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import kotlin.script.experimental.jvm.util.classpathFromClass -import kotlin.script.experimental.jvm.util.classpathFromClassloader -import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty -import kotlin.test.assertNotNull - -class BluePrintScriptsServiceImplTest { - - private fun viewClassPathInfo() { - - println(" *********** classpathFromClass *********** ") - classpathFromClass( - BluePrintScriptsServiceImplTest::class.java.classLoader, - BluePrintScriptsServiceImplTest::class - )!! - .forEach(::println) - - println(" *********** classpathFromClassloader *********** ") - classpathFromClassloader(BluePrintScriptsServiceImplTest::class.java.classLoader)!! - .forEach(::println) - - println(" *********** classpathFromClasspathProperty *********** ") - classpathFromClasspathProperty()!! - .forEach(::println) - } - - @Test - fun testCachedService() { - runBlocking { - - val bluePrintScriptsService = BluePrintScriptsServiceImpl() - - val basePath = normalizedPathName("src/test/resources/compile") - /** Load the Definitions */ - val bluePrintDefinitions = bluePrintScriptsService - .scriptInstance<BluePrintDefinitions>( - basePath, - "cba.scripts.ActivateBlueprintDefinitions", true - ) - assertNotNull(bluePrintDefinitions, "failed to get blueprint definitions") - - val serviceTemplate = bluePrintDefinitions.serviceTemplate() - assertNotNull(serviceTemplate, "failed to get service template") - - val customDataType = bluePrintDefinitions.otherDefinition<DataType>("datatype-custom-datatype") - assertNotNull(customDataType, "failed to get custom definitions") - - val instance = bluePrintScriptsService - .scriptInstance<BlueprintFunctionNode<String, String>>( - basePath, - "cba.scripts.SampleBlueprintFunctionNode", false - ) - assertNotNull(instance, "failed to get compiled instance") - - val cachedInstance = bluePrintScriptsService - .scriptInstance<BlueprintFunctionNode<String, String>>( - basePath, - "cba.scripts.SampleBlueprintFunctionNode", false - ) - assertNotNull(cachedInstance, "failed to get cached compile instance") - } - } -} 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 deleted file mode 100644 index 6dcb4eb1c..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt +++ /dev/null @@ -1,581 +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.cds.controllerblueprints.core.service - -import com.fasterxml.jackson.databind.ObjectMapper -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.Activity -import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition -import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment -import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType -import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceAssignment -import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition -import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType -import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment -import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType -import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementAssignment -import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.data.Step -import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.slf4j.LoggerFactory -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull -import kotlin.test.assertTrue - -/** - * - * - * @author Brinda Santh - */ -class BluePrintContextTest { - - private val log = LoggerFactory.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)) - } - - @Test - fun testImports() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.imports = mutableListOf() - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.imports()!!.isEmpty()) - - serviceTemplate.imports = null - assertNull(bluePrintContext.imports()) - } - - @Test - fun testDataTypes() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.dataTypes = mutableMapOf() - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.dataTypes()!!.isEmpty()) - - serviceTemplate.dataTypes = null - assertNull(bluePrintContext.dataTypes()) - } - - @Test - fun testInputs() { - val topologyTemplate = TopologyTemplate() - topologyTemplate.inputs = mutableMapOf() - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.inputs()!!.isEmpty()) - - topologyTemplate.inputs = null - - assertNull(bluePrintContext.inputs()) - } - - @Test - fun testBluePrintJson() { - val serviceTemplate = ServiceTemplate() - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("{\"tosca_definitions_version\":\"controller_blueprint_1_0_0\"}", bluePrintContext.blueprintJson()) - } - - @Test(expected = BluePrintException::class) - fun testName() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_NAME to "hello") - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.name()) - - serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BluePrintContext(serviceTemplate) - bluePrintContext2.name() - } - - @Test(expected = BluePrintException::class) - fun testVersion() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_VERSION to "hello") - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.version()) - - serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BluePrintContext(serviceTemplate) - bluePrintContext2.version() - } - - @Test(expected = BluePrintException::class) - fun testAuthor() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.metadata = mutableMapOf(BluePrintConstants.METADATA_TEMPLATE_AUTHOR to "hello") - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.author()) - - serviceTemplate.metadata = mutableMapOf() - val bluePrintContext2 = BluePrintContext(serviceTemplate) - bluePrintContext2.author() - } - - @Test - fun testWorkflows() { - val topologyTemplate = TopologyTemplate() - topologyTemplate.workflows = mutableMapOf() - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.workflows()!!.isEmpty()) - - topologyTemplate.workflows = null - assertNull(bluePrintContext.workflows()) - } - - @Test(expected = BluePrintException::class) - fun testWorkFlowsByName() { - val topologyTemplate = TopologyTemplate() - topologyTemplate.workflows = mutableMapOf("workflow" to Workflow()) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.workflowByName("workflow")) - - bluePrintContext.workflowByName("") - } - - @Test - fun testWorkflowInput() { - val topologyTemplate = TopologyTemplate() - val workflow = Workflow() - workflow.inputs = mutableMapOf() - topologyTemplate.workflows = mutableMapOf("workflow" to workflow) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.workflowInputs("workflow")!!.isEmpty()) - - workflow.inputs = null - - assertNull(bluePrintContext.workflowInputs("workflow")) - } - - @Test(expected = BluePrintException::class) - fun testWorkflowStepByName() { - val topologyTemplate = TopologyTemplate() - val workflow = Workflow() - workflow.steps = mutableMapOf("step" to Step()) - topologyTemplate.workflows = mutableMapOf("workflow" to workflow) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.workflowStepByName("workflow", "step")) - - bluePrintContext.workflowStepByName("workflow", "") - } - - @Test(expected = BluePrintException::class) - fun testWorkflowStepNodeTemplate() { - val topologyTemplate = TopologyTemplate() - val workflow = Workflow() - val step = Step() - step.target = "hello" - workflow.steps = mutableMapOf("step" to step) - topologyTemplate.workflows = mutableMapOf("workflow" to workflow) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.workflowStepNodeTemplate("workflow", "step")) - - bluePrintContext.workflowStepNodeTemplate("workflow", "") - } - - @Test(expected = BluePrintException::class) - fun testWorkflowFirstStepNodeTemplate() { - val topologyTemplate = TopologyTemplate() - val workflow = Workflow() - val step = Step() - step.target = "hello" - workflow.steps = mutableMapOf("step" to step, "step2" to Step()) - topologyTemplate.workflows = mutableMapOf("workflow" to workflow) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.workflowFirstStepNodeTemplate("workflow")) - - workflow.steps = null - bluePrintContext.workflowFirstStepNodeTemplate("workflow") - } - - @Test(expected = BluePrintException::class) - fun testWorkflowStepFirstCallOperation() { - val topologyTemplate = TopologyTemplate() - val workflow = Workflow() - val step = Step() - val activity = Activity() - activity.callOperation = "hello" - step.activities = arrayListOf(activity) - workflow.steps = mutableMapOf("step" to step) - topologyTemplate.workflows = mutableMapOf("workflow" to workflow) - val serviceTemplate = ServiceTemplate() - serviceTemplate.topologyTemplate = topologyTemplate - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.workflowStepFirstCallOperation("workflow", "step")) - - bluePrintContext.workflowStepFirstCallOperation("workflow", "") - } - - @Test - fun testDatatypeByName() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.dataTypes = mutableMapOf("data" to DataType()) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.dataTypeByName("data")) - assertNull(bluePrintContext.dataTypeByName("")) - } - - @Test - fun testArtifactTypes() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.artifactTypes = mutableMapOf() - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.artifactTypes()!!.isEmpty()) - - serviceTemplate.artifactTypes = null - assertNull(bluePrintContext.artifactTypes()) - } - - @Test - fun testPolicyTypes() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.policyTypes = mutableMapOf() - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.policyTypes()!!.isEmpty()) - - serviceTemplate.policyTypes = null - assertNull(bluePrintContext.policyTypes()) - } - - @Test(expected = BluePrintException::class) - fun testPolicyTypeByName() { - val serviceTemplate = ServiceTemplate() - serviceTemplate.policyTypes = mutableMapOf("policy" to PolicyType()) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.policyTypeByName("policy")) - - bluePrintContext.policyTypeByName("") - } - - @Test - fun testPolicyTypesDerivedFrom() { - val serviceTemplate = ServiceTemplate() - val policyType = PolicyType() - policyType.derivedFrom = "hi" - val policyType2 = PolicyType() - policyType2.derivedFrom = "hello" - serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals(1, bluePrintContext.policyTypesDerivedFrom("hi")!!.size) - - serviceTemplate.policyTypes = null - assertNull(bluePrintContext.policyTypesDerivedFrom("hi")) - } - - @Test - fun testPolicyTypesTarget() { - val serviceTemplate = ServiceTemplate() - val policyType = PolicyType() - policyType.targets = mutableListOf("hi") - val policyType2 = PolicyType() - policyType2.targets = mutableListOf() - serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals(1, bluePrintContext.policyTypesTarget("hi")!!.size) - - serviceTemplate.policyTypes = null - assertNull(bluePrintContext.policyTypesTarget("hi")) - } - - @Test - fun testPolicyTypesTargetNDerivedFrom() { - val serviceTemplate = ServiceTemplate() - val policyType = PolicyType() - policyType.targets = mutableListOf("hi") - policyType.derivedFrom = "hi" - val policyType2 = PolicyType() - policyType2.targets = mutableListOf() - policyType2.derivedFrom = "hi" - serviceTemplate.policyTypes = mutableMapOf("policy" to policyType, "policy2" to policyType2) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals(1, bluePrintContext.policyTypesTargetNDerivedFrom("hi", "hi")!!.size) - - serviceTemplate.policyTypes = null - assertNull(bluePrintContext.policyTypesTargetNDerivedFrom("hi", "hi")) - } - - @Test - fun testNodeTypeDerivedFrom() { - val serviceTemplate = ServiceTemplate() - val nodeType = NodeType() - nodeType.derivedFrom = "hi" - val nodeType2 = NodeType() - nodeType2.derivedFrom = "hiii" - serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType, "node2" to nodeType2) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals(1, bluePrintContext.nodeTypeDerivedFrom("hi")!!.size) - - serviceTemplate.nodeTypes = null - assertNull(bluePrintContext.nodeTypeDerivedFrom("hi")) - } - - @Test(expected = BluePrintException::class) - fun testInterfaceNameForNodeType() { - val serviceTemplate = ServiceTemplate() - val nodeType = NodeType() - nodeType.interfaces = mutableMapOf("hello" to InterfaceDefinition(), "hi" to InterfaceDefinition()) - serviceTemplate.nodeTypes = mutableMapOf("node" to nodeType) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("hello", bluePrintContext.interfaceNameForNodeType("node")) - - bluePrintContext.interfaceNameForNodeType("") - } - - @Test - fun testNodeTemplateForNodeType() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.type = "hello" - val nodeTemplate2 = NodeTemplate() - nodeTemplate2.type = "hi" - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate, "node2" to nodeTemplate2) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals(1, bluePrintContext.nodeTemplateForNodeType("hello")!!.size) - - serviceTemplate.topologyTemplate!!.nodeTemplates = null - assertNull(bluePrintContext.nodeTemplateForNodeType("hello")) - } - - @Test - fun testNodeTemplateProperty() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.properties = mutableMapOf("prop" to ObjectMapper().createObjectNode()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateProperty("node", "prop")) - - assertNull(bluePrintContext.nodeTemplateProperty("node", "")) - - nodeTemplate.properties = null - assertNull(bluePrintContext.nodeTemplateProperty("node", "prop")) - } - - @Test - fun testNodeTemplateArtifacts() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.artifacts = mutableMapOf() - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertTrue(bluePrintContext.nodeTemplateArtifacts("node")!!.isEmpty()) - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateArtifact() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.artifacts = mutableMapOf("art" to ArtifactDefinition()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateArtifact("node", "art")) - - bluePrintContext.nodeTemplateArtifact("node", "") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateArtifactForArtifactType() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - val artifactDefinition = ArtifactDefinition() - artifactDefinition.type = "type" - val artifactDefinition2 = ArtifactDefinition() - artifactDefinition2.type = "No type" - nodeTemplate.artifacts = mutableMapOf("art" to artifactDefinition, "art2" to artifactDefinition2) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateArtifactForArtifactType("node", "type")) - - bluePrintContext.nodeTemplateArtifactForArtifactType("", "") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateFirstInterface() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateFirstInterface("node")) - - nodeTemplate.interfaces = null - bluePrintContext.nodeTemplateFirstInterface("node") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateFirstInterfaceName() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.interfaces = mutableMapOf("interface" to InterfaceAssignment(), "interf" to InterfaceAssignment()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("interface", bluePrintContext.nodeTemplateFirstInterfaceName("node")) - - nodeTemplate.interfaces = null - bluePrintContext.nodeTemplateFirstInterfaceName("node") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateFirstInterfaceFirstOperationName() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - val interfaceAssignment = InterfaceAssignment() - interfaceAssignment.operations = mutableMapOf("op" to OperationAssignment(), "op2" to OperationAssignment()) - nodeTemplate.interfaces = mutableMapOf("intf" to interfaceAssignment) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertEquals("op", bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node")) - - interfaceAssignment.operations = null - bluePrintContext.nodeTemplateFirstInterfaceFirstOperationName("node") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateCapability() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.capabilities = mutableMapOf("cap" to CapabilityAssignment()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateCapability("node", "cap")) - - bluePrintContext.nodeTemplateCapability("node", "") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateRequirement() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - nodeTemplate.requirements = mutableMapOf("req" to RequirementAssignment()) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateRequirement("node", "req")) - - bluePrintContext.nodeTemplateRequirement("node", "") - } - - @Test(expected = BluePrintException::class) - fun testNodeTemplateRequirementNode() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - val requirementAssignment = RequirementAssignment() - requirementAssignment.node = "node" - nodeTemplate.requirements = mutableMapOf("req" to requirementAssignment) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateRequirementNode("node", "req")) - - bluePrintContext.nodeTemplateRequirementNode("node", "") - } - - @Test - fun testNodeTemplateCapabilityProperty() { - val serviceTemplate = ServiceTemplate() - val nodeTemplate = NodeTemplate() - val capabilityAssignment = CapabilityAssignment() - capabilityAssignment.properties = mutableMapOf("prop" to ObjectMapper().createObjectNode()) - nodeTemplate.capabilities = mutableMapOf("cap" to capabilityAssignment) - serviceTemplate.topologyTemplate = TopologyTemplate() - serviceTemplate.topologyTemplate!!.nodeTemplates = mutableMapOf("node" to nodeTemplate) - val bluePrintContext = BluePrintContext(serviceTemplate) - - assertNotNull(bluePrintContext.nodeTemplateCapabilityProperty("node", "cap", "prop")) - - capabilityAssignment.properties = null - - assertNull(bluePrintContext.nodeTemplateCapabilityProperty("node", "cap", "prop")) - } -} 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 deleted file mode 100644 index f8cad990d..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt +++ /dev/null @@ -1,140 +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.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" - ) - } -} 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 deleted file mode 100644 index 2fbd26040..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/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.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 = "./../../../../components/model-catalog/definition-type/starter-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-resolution") - 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") - } -} 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 deleted file mode 100644 index ddb67706c..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ /dev/null @@ -1,206 +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.cds.controllerblueprints.core.service - -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.normalizedPathName -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 org.slf4j.LoggerFactory -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -/** - * - * - * @author Brinda Santh - */ -class BluePrintRuntimeServiceTest { - - private val log = LoggerFactory.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 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<String, JsonNode> = 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", "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<MutableMap<String, JsonNode>> { - val blueprintBasePath = normalizedPathName("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) - val checkProcessId = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID) - val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) - - assertEquals( - "1234".asJsonPrimitive(), - checkProcessId, "Failed to get process id after runtime creation" - ) - assertEquals( - blueprintBasePath.asJsonPrimitive(), - checkBasePath, "Failed to get base path after runtime creation" - ) - - return blueprintRuntime - } -} 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 deleted file mode 100644 index fd3dec4b3..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Modifications Copyright © 2019 IBM, Bell Canada. - * - * 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 kotlinx.coroutines.runBlocking -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.BeforeTest -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -class BluePrintTemplateServiceTest { - - lateinit var blueprintRuntime: BluePrintRuntimeService<*> - - @BeforeTest - fun setup() { - val blueprintBasePath: String = - ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) - } - - @Test - fun testVelocityGeneratedContent() { - runBlocking { - val template = JacksonUtils.getClassPathFileContent("templates/base-config-velocity-template.vtl") - val json = JacksonUtils.getClassPathFileContent("templates/base-config-data-velocity.json") - - val content = BluePrintVelocityTemplateService.generateContent(template, json) - assertNotNull(content, "failed to generate content for velocity template") - } - } - - @Test - fun testJinjaGeneratedContent() { - runBlocking { - val template = JacksonUtils.getClassPathFileContent("templates/master.jinja") - val json = JacksonUtils.getClassPathFileContent("templates/base-config-data-jinja.json") - - val element: MutableMap<String, Any> = mutableMapOf() - element["additional_array"] = arrayListOf( - hashMapOf("name" to "Element1", "location" to "Region0"), - hashMapOf("name" to "Element2", "location" to "Region1") - ) - - val content = BluePrintJinjaTemplateService.generateContent(template, json, false, element) - assertNotNull(content, "failed to generate content for velocity template") - } - } - - @Test - fun `no value variable should evaluate to default value - standalone template mesh test`() { - runBlocking { - val template = - JacksonUtils.getClassPathFileContent("templates/default-variable-value-velocity-template.vtl") - val json = JacksonUtils.getClassPathFileContent("templates/default-variable-value-data.json") - - val content = BluePrintVelocityTemplateService.generateContent(template, json) - // first line represents a variable whose value was successfully retrieved, second line contains a variable - // whose value could not be evaluated - val expected = "sample-hostname\n\${node0_backup_router_address}" - assertEquals(expected, content, "No value variable should use default value") - } - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowServiceTest.kt deleted file mode 100644 index 72fa3e1eb..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowServiceTest.kt +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.service - -import io.mockk.every -import io.mockk.mockk -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withTimeout -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel -import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph -import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.toGraph -import kotlin.test.assertNotNull - -class BluePrintWorkflowServiceTest { - @Test - fun testSimpleFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>E/SUCCESS, E>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testMultipleFlows() { - runBlocking { - coroutineScope { - val wfs = listOf("12345", "12346").map { - async { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(it), it) - assertNotNull(response, "failed to get response") - } - } - wfs.awaitAll() - } - } - } - - @Test - fun testMissingEdgeForBFailureState() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), arrayListOf("B")) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testBExceptionFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testTimeoutExceptionFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>TO/SUCCESS, TO>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "TO", "C", "D", "E"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testConditionalFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testBothConditionalFlow() { - runBlocking { - // Failure Flow - val failurePatGraph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val failurePathWorkflow = TestBluePrintWorkFlowService() - failurePathWorkflow.simulatedState = prepareSimulation( - arrayListOf("B", "C", "D", "E"), - arrayListOf("A") - ) - val failurePathWorkflowInput = "123456" - val failurePathResponse = failurePathWorkflow.executeWorkflow(failurePatGraph, mockBluePrintRuntimeService(), failurePathWorkflowInput) - assertNotNull(failurePathResponse, "failed to get response") - } - } - - @Test - fun testMultipleSkipFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, C>D/SUCCESS, D>E/SUCCESS, B>E/SUCCESS, E>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - @Test - fun testParallelFlow() { - runBlocking { - val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/SUCCESS, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() - val simpleWorkflow = TestBluePrintWorkFlowService() - simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) - val input = "123456" - val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(), input) - assertNotNull(response, "failed to get response") - } - } - - private fun mockBluePrintRuntimeService(): BluePrintRuntimeService<*> { - return mockBluePrintRuntimeService("123456") - } - - private fun mockBluePrintRuntimeService(id: String): BluePrintRuntimeService<*> { - val bluePrintRuntimeService = mockk<BluePrintRuntimeService<*>>() - every { bluePrintRuntimeService.id() } returns id - return bluePrintRuntimeService - } - - private fun prepareSimulation(successes: List<String>?, failures: List<String>?): MutableMap<String, EdgeLabel> { - val simulatedState: MutableMap<String, EdgeLabel> = hashMapOf() - successes?.forEach { - simulatedState[it] = EdgeLabel.SUCCESS - } - failures?.forEach { - simulatedState[it] = EdgeLabel.FAILURE - } - return simulatedState - } -} - -class TestBluePrintWorkFlowService : - AbstractBluePrintWorkFlowService<String, String>() { - - val log = logger(TestBluePrintWorkFlowService::class) - - lateinit var simulatedState: MutableMap<String, EdgeLabel> - - override suspend fun initializeWorkflow(input: String): EdgeLabel { - return EdgeLabel.SUCCESS - } - - override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: String): String { - log.info("Executing Graph : $graph") - this.graph = graph - this.workflowId = bluePrintRuntimeService.id() - val output = CompletableDeferred<String>() - val startMessage = WorkflowExecuteMessage(input, output) - val workflowActor = workflowActor() - if (!workflowActor.isClosedForSend) { - workflowActor().send(startMessage) - } else { - throw BluePrintProcessorException("workflow actor is closed for send $workflowActor") - } - return startMessage.output.await() - } - - override suspend fun prepareNodeExecutionMessage(node: Graph.Node): - NodeExecuteMessage<String, String> { - return NodeExecuteMessage(node, "$node Input", "") - } - - override suspend fun executeNode( - node: Graph.Node, - nodeInput: String, - nodeOutput: String - ): EdgeLabel { - // val random = (1..10).random() * 100 - // log.info("workflow($workflowId) node(${node.id}) will reply in $random ms") - // kotlinx.coroutines.delay(random.toLong()) - // //Simulation for timeout - if (node.id == "TO") { - withTimeout(1) { - kotlinx.coroutines.delay(2) - } - } - return simulatedState[node.id] ?: throw BluePrintException("failed to get status for the node($node)") - } - - override suspend fun prepareNodeSkipMessage(node: Graph.Node): NodeSkipMessage<String, String> { - val nodeOutput = "" - return NodeSkipMessage(node, "$node Skip Input", nodeOutput) - } - - override suspend fun skipNode( - node: Graph.Node, - nodeInput: String, - nodeOutput: String - ): EdgeLabel { - return simulatedState[node.id] ?: throw BluePrintException("failed to get status for the node($node)") - } - - override suspend fun cancelNode( - node: Graph.Node, - nodeInput: String, - nodeOutput: String - ): EdgeLabel { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun restartNode( - node: Graph.Node, - nodeInput: String, - nodeOutput: String - ): EdgeLabel { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun prepareWorkflowOutput(): String { - if (exceptions.isNotEmpty()) { - exceptions.forEach { - log.error("workflow($workflowId) exceptions :", it) - } - } - return "Final Response" - } -} 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 deleted file mode 100644 index 6413fb5fe..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt +++ /dev/null @@ -1,56 +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.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) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt deleted file mode 100644 index 62bb0afcb..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.utils - -import kotlinx.coroutines.runBlocking -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintRetryException - -class BluePrintIOUtilsTest { - - @Test - fun testRetry() { - runBlocking { - val executionBlock: suspend (Int) -> String = { count: Int -> - "success" - } - val exceptionBlock = { e: Exception -> - if (e is BluePrintRetryException) { - println("this is blueprint error") - } else { - throw e - } - } - BluePrintIOUtils.retry<String>(4, 0, 500, executionBlock, exceptionBlock) - } - } -} 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 deleted file mode 100644 index c29332d4f..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt +++ /dev/null @@ -1,79 +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.cds.controllerblueprints.core.utils - -import kotlinx.coroutines.runBlocking -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull -import kotlin.test.assertTrue - -class BluePrintMetadataUtilsTest { - - @Test - fun testToscaMetaData() { - - runBlocking { - val basePath = "./../../../../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 testKotlinBluePrintContext() { - val path = normalizedPathName("src/test/resources/compile") - val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path) - assertNotNull(blueprintContext, "failed to get blueprint context") - assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template") - assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template") - assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions") - - var cachePresent = BluePrintCompileCache.hasClassLoader(path) - assertTrue(cachePresent, "failed to generate cache key ($path)") - - /** Cleaning Cache */ - BluePrintCompileCache.cleanClassLoader(path) - cachePresent = BluePrintCompileCache.hasClassLoader(path) - assertTrue(!cachePresent, "failed to remove cache key ($path)") - } - - @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") - } -} 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 deleted file mode 100644 index aa4008759..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.utils - -import kotlinx.coroutines.runBlocking -import org.junit.Test -import org.slf4j.LoggerFactory - -class JacksonReactorUtilsTest { - - private val log = LoggerFactory.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) - } - } -} 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 deleted file mode 100644 index 5facad7ef..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ /dev/null @@ -1,74 +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.cds.controllerblueprints.core.utils - -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.slf4j.LoggerFactory -import kotlin.test.assertNotNull -import kotlin.test.assertTrue - -/** - * JacksonUtilsTest - * @author Brinda Santh - * ${DATA} - */ -class JacksonUtilsTest { - - private val log = LoggerFactory.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") - } -} 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 deleted file mode 100644 index 336e47604..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.utils - -import org.junit.Test -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType -import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse -import org.onap.ccsdk.cds.controllerblueprints.core.jsonPaths -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -class JsonParserUtilsTest { - - @Test - fun `test parse Node`() { - val dataNode = JacksonUtils.jsonNodeFromClassPathFile("data/default-context.json") - - val parsedNode = dataNode.jsonPathParse("$.request-id") - - assertEquals(parsedNode, "12345".asJsonPrimitive(), "failed to parse json request-id") - } - - @Test - fun testPaths() { - val json: String = """ - { - "data" : { - "prop1" : "1234" - }, - "data2" : { - "prop1" : "12345" - }, - "data3" : [{ - "prop1" : "12345" - } - ] - } - """.trimIndent() - val jsonNode = json.jsonAsJsonType() - val parsedPath = jsonNode.jsonPaths("$..prop1") - assertNotNull(parsedPath, "failed to get parsed path") - } -} 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 deleted file mode 100644 index fc11947de..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.utils - -import org.junit.Test -import org.slf4j.LoggerFactory - -class TopologicalSortingUtilsTest { - - private val log = LoggerFactory.getLogger(TopologicalSortingUtilsTest::class.java) - @Test - fun testSorting() { - 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") - - log.debug("The current graph: $graph") - log.debug("In-degrees: " + graph.inDegree()) - log.debug("Out-degrees: " + graph.outDegree()) - log.debug("A topological sort of the vertices: " + graph.topSort()) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtilsTest.kt deleted file mode 100644 index 66272d61a..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtilsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.utils - -import org.onap.ccsdk.cds.controllerblueprints.core.dsl.workflow -import kotlin.test.Test -import kotlin.test.assertNotNull - -class WorkflowGraphUtilsTest { - - @Test - fun testWorkFlowToGraph() { - - val workflow = workflow("sample", "") { - step("A", "A", "") { - success("B") - } - step("B", "B", "") { - success("C") - failure("D") - } - step("C", "C", "") - step("D", "D", "") - } - val graph = WorkflowGraphUtils.workFlowToGraph(workflow) - assertNotNull(graph, "failed to create graph") - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt deleted file mode 100644 index 5dd1937f8..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt +++ /dev/null @@ -1,57 +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 cba.scripts - -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.dsl.dataType -import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBluePrintDefinitions - -class ActivateBlueprintDefinitions : AbstractBluePrintDefinitions() { - - override fun serviceTemplate(): ServiceTemplate { - - return serviceTemplate( - "sample-blue-print", "1.0.0", - "brindasanth@onap.com", "sample, blueprints" - ) { - topologyTemplate { - workflowNodeTemplate("activate", "component-resource-resolution", "") { - operation("ResourceResolutionExecutor", "") { - inputs { - property("string-value", "sample") - } - } - } - } - } - } - - override fun loadOtherDefinitions() { - /** Sample Definitions */ - val customDataType = dataType( - "custom-datatype", "1.0.0", - BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, "" - ) { - property("name", BluePrintConstants.DATA_TYPE_STRING, true, "") - property("value", BluePrintConstants.DATA_TYPE_STRING, true, "") - } - /** Loading to definitions */ - addOtherDefinition("datatype-custom-datatype", customDataType) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/SampleBlueprintFunctionNode.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/SampleBlueprintFunctionNode.kt deleted file mode 100644 index 8bd060e17..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/SampleBlueprintFunctionNode.kt +++ /dev/null @@ -1,66 +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 cba.scripts - -import org.onap.ccsdk.cds.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" - } - - override suspend fun prepareRequestNB(executionRequest: String): String { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun processNB(executionRequest: String) { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun prepareResponseNB(): String { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } - - override suspend fun applyNB(t: String): String { - TODO("not implemented") // To change body of created functions use File | Settings | File Templates. - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index b1ffabd13..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,7 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Brinda Santh <brindasanth@in.ibm.com> -Entry-Definitions: cba.scripts.ActivateBlueprintDefinitions.kt -Template-Tags: Brinda Santh, activation-blueprint -Template-Name: activate-blueprint -Template-Version: 1.0.0 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 deleted file mode 100644 index a1982631b..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "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 deleted file mode 100644 index 055b09658..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "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 deleted file mode 100644 index 9f733f0fd..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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 deleted file mode 100644 index b7340f336..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json +++ /dev/null @@ -1,299 +0,0 @@ -{ - "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-data": { - "type": "object", - "properties": { - "verb": { - "type": "string", - "required": true - }, - "path": { - "type": "string", - "required": true - }, - "url-path": { - "type": "string", - "required": true - }, - "payload": { - "type": "string", - "required": false - }, - "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 - } - } - }, - "sdnc": { - "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" - } - } - } - }, - "processor-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-data": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "sdnc": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "network-resource-discovery": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "processor-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/environments/Environments/environment1.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties deleted file mode 100644 index d735087bb..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties +++ /dev/null @@ -1,2 +0,0 @@ -blueprintsprocessor.database.alt1.username=username1 -blueprintsprocessor.database.alt1.password=password1
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties deleted file mode 100644 index 5530a8f8a..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties +++ /dev/null @@ -1,2 +0,0 @@ -blueprintsprocessor.database.alt2.username=username2 -blueprintsprocessor.database.alt2.password=password2
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml deleted file mode 100644 index 83e0bc674..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml +++ /dev/null @@ -1,31 +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. - --> - -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <!-- encoders are assigned the type - ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> - <encoder> - <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern> - </encoder> - </appender> - - <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/> - <root level="info"> - <appender-ref ref="STDOUT"/> - </root> - -</configuration> 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 deleted file mode 100644 index f7893ce53..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "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 deleted file mode 100644 index 9f17574e7..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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/templates/base-config-data-jinja.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data-jinja.json deleted file mode 100644 index ab7abf3d4..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data-jinja.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "occurrence": 2 -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data-velocity.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data-velocity.json deleted file mode 100755 index 2acc6fcdd..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data-velocity.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "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-velocity-template.vtl b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-velocity-template.vtl deleted file mode 100755 index f7b1269b3..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-velocity-template.vtl +++ /dev/null @@ -1,61 +0,0 @@ -<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 diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-data.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-data.json deleted file mode 100755 index 940ca8d73..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-data.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "node0_hostname": "sample-hostname" -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-velocity-template.vtl b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-velocity-template.vtl deleted file mode 100755 index ce2458e2e..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/default-variable-value-velocity-template.vtl +++ /dev/null @@ -1,2 +0,0 @@ -$node0_hostname -${node0_backup_router_address}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/interface.jinja b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/interface.jinja deleted file mode 100755 index 93114d90a..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/interface.jinja +++ /dev/null @@ -1,3 +0,0 @@ - <interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"> -blo - </interface-configurations>
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/isis.jinja b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/isis.jinja deleted file mode 100644 index f46d91330..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/isis.jinja +++ /dev/null @@ -1,3 +0,0 @@ - <isis xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-clns-isis-cfg"> -blah - </isis>
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/master.jinja b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/master.jinja deleted file mode 100644 index 1137b2595..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/master.jinja +++ /dev/null @@ -1,7 +0,0 @@ -{%- for i in range(occurrence) %} -<config> -{% include "templates/isis.jinja" %} -{% include "templates/interface.jinja" %} -</config> -{{ "]]>]]" if not loop.last }} -{%- endfor %}
\ No newline at end of file |