diff options
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test')
23 files changed, 338 insertions, 244 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 index e3e5c26a3..6a028d36f 100644 --- 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 @@ -30,4 +30,4 @@ class BluePrintErrorTest { assertEquals("error", bluePrintError.errors[0]) } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctionsTest.kt index 76be647f1..3ae87b32d 100644 --- 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 @@ -18,9 +18,20 @@ 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.* +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.* +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * @@ -28,12 +39,13 @@ import kotlin.test.* * @author Brinda Santh */ class CustomFunctionsTest { + @Test fun testFormat() { - val returnValue : String = format("This is {} for times {}", "test", 2) + 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") + val returnValue1: String = format("This is test for times 2") assertEquals("This is test for times 2", returnValue1, "Failed to format empty args") } @@ -198,23 +210,23 @@ class CustomFunctionsTest { @Test(expected = BluePrintException::class) fun testCheckEquals() { - assertTrue(checkEquals("hello", "hello", { -> "error"})) + assertTrue(checkEquals("hello", "hello", { -> "error" })) - checkEquals("hello", "test", { -> "error"}) + checkEquals("hello", "test", { -> "error" }) } @Test(expected = IllegalStateException::class) fun testCheckNotEmpty() { - assertEquals("hello", checkNotEmpty("hello", { -> "error"})) + assertEquals("hello", checkNotEmpty("hello", { -> "error" })) - checkNotEmpty("", { -> "error"}) + checkNotEmpty("", { -> "error" }) } @Test(expected = IllegalStateException::class) fun testCheckNotBlank() { - assertEquals("hello", checkNotBlank("hello", { -> "error"})) + assertEquals("hello", checkNotBlank("hello", { -> "error" })) - checkNotBlank(" ", { -> "error"}) + checkNotBlank(" ", { -> "error" }) } @Test @@ -223,4 +235,4 @@ class CustomFunctionsTest { assertEquals("hello", nullToEmpty("hello")) } -}
\ No newline at end of file +} 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 index 9a0da6905..81f4a0091 100644 --- 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 @@ -30,5 +30,4 @@ class FileExtensionFunctionTest { blueprintFile.compress(targetZip) assertTrue(blueprintFile.exists(), "failed to create compressed file(${targetZip.absolutePath} ") } - -}
\ No newline at end of file +} 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 index 6c92d1815..498a85239 100644 --- 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 @@ -45,12 +45,14 @@ class MDCContextTest { assertEquals(null, MDC.get(BluePrintConstants.ONAP_REQUEST_ID)) } launch(MDCContext()) { - assertEquals("12345", MDC.get(BluePrintConstants.ONAP_REQUEST_ID), - "couldn't get request id") + 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") } } } -}
\ No newline at end of file +} 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 index c24ed0327..a75262f96 100644 --- 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 @@ -27,90 +27,93 @@ class BluePrintsAnnotationsTest { @Test fun testBluePrintWorkflowData() { val wfInput = TestBluePrintsWorkflowInput::class.asPropertyDefinitionMap() - //println(wfInput.asJsonString(true)) + // println(wfInput.asJsonString(true)) assertNotNull(wfInput, "failed to generate wfInput property map") val wfOutput = TestBluePrintsWorkflowOutput::class.asPropertyDefinitionMap() - //println(wfOutput.asJsonString(true)) + // println(wfOutput.asJsonString(true)) assertNotNull(wfInput, "failed to generate wfOutput property map") } @Test fun testBluePrintDataType() { val dataTypes = TestBluePrintsDataType::class.asBluePrintsDataTypes() - //println(dataTypes.asJsonString(true)) + // 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") +@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> + @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 + @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" -)
\ No newline at end of file + @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 index ec8f24d85..c2d764bd6 100644 --- 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 @@ -29,14 +29,18 @@ class BluePrintDSLTest { @Test fun testOperationDSLWorkflow() { - val blueprint = blueprint("sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints") { + 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.") { + 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, "") @@ -54,8 +58,10 @@ class BluePrintDSLTest { } // Already definitions Registered Components - registryComponent("activate-restconf", "component-resource-resolution", "1.0.0", - "RestconfExecutor", "Resource Resolution component.") { + registryComponent( + "activate-restconf", "component-resource-resolution", "1.0.0", + "RestconfExecutor", "Resource Resolution component." + ) { implementation(180) // Properties property("string-value1", "data") @@ -65,7 +71,6 @@ class BluePrintDSLTest { output("self-attribute-expression", getAttribute("template1-data")) // Artifacts artifact("template2", "artifact-template-velocity", "Templates/template1.vtl") - } workflow("resource-resolution-process", "Resource Resolution wf") { @@ -77,25 +82,29 @@ class BluePrintDSLTest { } assertNotNull(blueprint.components, "failed to get components") assertNotNull(blueprint.workflows, "failed to get workflows") - //println(blueprint.asJsonString(true)) + // 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)) + // println(serviceTemplate.asJsonString(true)) } @Test fun testServiceTemplate() { - val serviceTemplate = serviceTemplate("sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints") { + 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") { + nodeTemplateOperation( + nodeTemplateName = "activate", type = "sample-node-type", interfaceName = "RestconfExecutor", + description = "sample activation" + ) { implementation(360, "SELF") { primary("Scripts/sample.py") dependencies("one", "two") @@ -156,7 +165,7 @@ class BluePrintDSLTest { 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)) + // println(serviceTemplate.asJsonString(true)) } @Test @@ -170,7 +179,6 @@ class BluePrintDSLTest { maxLength(20) minLength(10) } - } property("disk-space", "string", true, "") { defaultValue(10) @@ -196,8 +204,10 @@ class BluePrintDSLTest { @Test fun testServiceTemplateWorkflow() { - val serviceTemplate = serviceTemplate("sample-bp", "1.0.0", - "brindasanth@onap.com", "sample, blueprints") { + val serviceTemplate = serviceTemplate( + "sample-bp", "1.0.0", + "brindasanth@onap.com", "sample, blueprints" + ) { topologyTemplate { workflowNodeTemplate("activate", "component-resource-resolution", "") { operation("ResourceResolutionExecutor", "") { @@ -210,14 +220,16 @@ class BluePrintDSLTest { } assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template") assertNotNull(serviceTemplate.topologyTemplate?.workflows?.get("activate"), "failed to get workflow(activate)") - //println(serviceTemplate.asJsonString(true)) + // println(serviceTemplate.asJsonString(true)) } @Test fun testNodeTemplateOperationTypes() { - val testNodeTemplateInstance = BluePrintTypes.nodeTemplateComponentTestExecutor(id = "test-node-template", - description = "") { + val testNodeTemplateInstance = BluePrintTypes.nodeTemplateComponentTestExecutor( + id = "test-node-template", + description = "" + ) { definedProperties { prop1("i am property1") prop2("i am property2") @@ -233,21 +245,25 @@ class BluePrintDSLTest { } } assertNotNull(testNodeTemplateInstance, "failed to get test node template") - //println(testNodeTemplateInstance.asJsonString(true)) + // println(testNodeTemplateInstance.asJsonString(true)) } } -fun BluePrintTypes.nodeTemplateComponentTestExecutor(id: String, - description: String, - block: TestNodeTemplateOperationImplBuilder.() -> Unit) - : NodeTemplate { +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) + AbstractNodeTemplateOperationImplBuilder<TestProperty, TestInput, TestOutput>( + id, "component-test-executor", + "ComponentTestExecutor", + description + ) class TestProperty : PropertiesAssignmentBuilder() { fun prop1(prop1: String) { 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 index 66fec7553..60bef8a8d 100644 --- 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 @@ -17,7 +17,6 @@ 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 @@ -34,17 +33,19 @@ class BluePrintScriptsServiceImplTest { private fun viewClassPathInfo() { println(" *********** classpathFromClass *********** ") - classpathFromClass(BluePrintScriptsServiceImplTest::class.java.classLoader, - BluePrintScriptsServiceImplTest::class)!! - .forEach(::println) + classpathFromClass( + BluePrintScriptsServiceImplTest::class.java.classLoader, + BluePrintScriptsServiceImplTest::class + )!! + .forEach(::println) println(" *********** classpathFromClassloader *********** ") classpathFromClassloader(BluePrintScriptsServiceImplTest::class.java.classLoader)!! - .forEach(::println) + .forEach(::println) println(" *********** classpathFromClasspathProperty *********** ") classpathFromClasspathProperty()!! - .forEach(::println) + .forEach(::println) } @Test @@ -56,8 +57,10 @@ class BluePrintScriptsServiceImplTest { val basePath = normalizedPathName("src/test/resources/compile") /** Load the Definitions */ val bluePrintDefinitions = bluePrintScriptsService - .scriptInstance<BluePrintDefinitions>(basePath, - "cba.scripts.ActivateBlueprintDefinitions", true) + .scriptInstance<BluePrintDefinitions>( + basePath, + "cba.scripts.ActivateBlueprintDefinitions", true + ) assertNotNull(bluePrintDefinitions, "failed to get blueprint definitions") val serviceTemplate = bluePrintDefinitions.serviceTemplate() @@ -67,15 +70,18 @@ class BluePrintScriptsServiceImplTest { assertNotNull(customDataType, "failed to get custom definitions") val instance = bluePrintScriptsService - .scriptInstance<BlueprintFunctionNode<String, String>>(basePath, - "cba.scripts.SampleBlueprintFunctionNode", false) + .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) + .scriptInstance<BlueprintFunctionNode<String, String>>( + basePath, + "cba.scripts.SampleBlueprintFunctionNode", false + ) assertNotNull(cachedInstance, "failed to get cached compile instance") } } - -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt index 33890277f..6dcb4eb1c 100644 --- 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 @@ -17,15 +17,28 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service - import com.fasterxml.jackson.databind.ObjectMapper -import org.slf4j.LoggerFactory 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.* +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 @@ -38,7 +51,7 @@ import kotlin.test.assertTrue */ class BluePrintContextTest { - private val log= LoggerFactory.getLogger(this::class.toString()) + private val log = LoggerFactory.getLogger(this::class.toString()) val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") 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 index d2363ab9d..f8cad990d 100644 --- 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 @@ -31,6 +31,7 @@ import kotlin.test.assertNotNull * @author Brinda Santh */ class BluePrintExpressionServiceTest { + @Test fun testInputExpression() { val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }") @@ -58,7 +59,11 @@ class BluePrintExpressionServiceTest { 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") + assertEquals( + "resource/name", + expressionData1.propertyExpression?.subPropertyName, + " Failed to populate nested subPropertyName expression data" + ) } @Test @@ -78,13 +83,17 @@ class BluePrintExpressionServiceTest { 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") + 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 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") @@ -95,7 +104,6 @@ class BluePrintExpressionServiceTest { 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\"] }") @@ -106,7 +114,6 @@ class BluePrintExpressionServiceTest { 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") @@ -125,7 +132,9 @@ class BluePrintExpressionServiceTest { 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") + assertEquals( + "dynamic-rest-source", expressionData.dslExpression!!.propertyName, + " Failed to populate dsl property name" + ) } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index 47b4f2179..2fbd26040 100644 --- 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 @@ -54,4 +54,4 @@ class BluePrintRepoFileServiceTest { val dataType = bluePrintRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index bef1c4570..ddb67706c 100644 --- 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 @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.node.NullNode import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintRuntimeUtils @@ -37,6 +36,7 @@ import kotlin.test.assertNotNull * @author Brinda Santh */ class BluePrintRuntimeServiceTest { + private val log = LoggerFactory.getLogger(this::class.toString()) @Test @@ -51,7 +51,7 @@ class BluePrintRuntimeServiceTest { bluePrintRuntimeService.assignInputs(inputNode) val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService - .resolveNodeTemplateProperties("activate-process") + .resolveNodeTemplateProperties("activate-process") assertNotNull(propContext, "Failed to populate interface property values") } @@ -63,19 +63,25 @@ class BluePrintRuntimeServiceTest { val executionContext = bluePrintRuntimeService.getExecutionContext() - BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), - "data/default-context.json", executionContext) + 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)) + bluePrintRuntimeService.setNodeTemplateAttributeValue( + "resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams) + ) - val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", - "netconf") + 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") @@ -89,12 +95,16 @@ class BluePrintRuntimeServiceTest { val executionContext = bluePrintRuntimeService.getExecutionContext() - BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), - "data/default-context.json", executionContext) + BluePrintRuntimeUtils.assignInputsFromClassPathFile( + bluePrintRuntimeService.bluePrintContext(), + "data/default-context.json", executionContext + ) val inContext: MutableMap<String, JsonNode> = bluePrintRuntimeService - .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "ResourceResolutionComponent", "process") + .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") @@ -109,17 +119,22 @@ class BluePrintRuntimeServiceTest { bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance()) - bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", - "ResourceResolutionComponent", "process") + bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs( + "resource-assignment", + "ResourceResolutionComponent", "process" + ) - val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "ResourceResolutionComponent", "process", "status") + 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") + val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue( + "resource-assignment", + "ResourceResolutionComponent", "process", "resource-assignment-params" + ) assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params") - } @Test @@ -127,17 +142,20 @@ class BluePrintRuntimeServiceTest { 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")) + 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 @@ -159,8 +177,10 @@ class BluePrintRuntimeServiceTest { val assignmentParams = "{\"ipAddress\": \"127.0.0.1\", \"hostName\": \"vnf-host\"}" - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", - JacksonUtils.jsonNode(assignmentParams)) + bluePrintRuntimeService.setNodeTemplateAttributeValue( + "resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams) + ) val resolvedJsonNode = bluePrintRuntimeService.resolveWorkflowOutputs("resource-assignment") assertNotNull(resolvedJsonNode, "Failed to populate workflow output property values") @@ -172,12 +192,15 @@ class BluePrintRuntimeServiceTest { 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") + 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 } - -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt index ce41cfa1f..fd3dec4b3 100644 --- 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 @@ -46,7 +46,6 @@ class BluePrintTemplateServiceTest { val content = BluePrintVelocityTemplateService.generateContent(template, json) assertNotNull(content, "failed to generate content for velocity template") } - } @Test @@ -56,16 +55,16 @@ class BluePrintTemplateServiceTest { 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")) + 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 { @@ -74,12 +73,10 @@ class BluePrintTemplateServiceTest { 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 + // 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 index 4d97f8bc3..72fa3e1eb 100644 --- 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 @@ -18,7 +18,12 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service import io.mockk.every import io.mockk.mockk -import kotlinx.coroutines.* +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 @@ -33,7 +38,7 @@ class BluePrintWorkflowServiceTest { fun testSimpleFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>E/SUCCESS, E>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" @@ -49,7 +54,7 @@ class BluePrintWorkflowServiceTest { 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() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) val response = simpleWorkflow.executeWorkflow(graph, mockBluePrintRuntimeService(it), it) @@ -65,7 +70,7 @@ class BluePrintWorkflowServiceTest { fun testMissingEdgeForBFailureState() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), arrayListOf("B")) val input = "123456" @@ -78,7 +83,7 @@ class BluePrintWorkflowServiceTest { fun testBExceptionFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, B>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "C", "D", "E"), null) val input = "123456" @@ -91,7 +96,7 @@ class BluePrintWorkflowServiceTest { fun testTimeoutExceptionFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>TO/SUCCESS, TO>C/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "TO", "C", "D", "E"), null) val input = "123456" @@ -104,7 +109,7 @@ class BluePrintWorkflowServiceTest { fun testConditionalFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" @@ -118,10 +123,12 @@ class BluePrintWorkflowServiceTest { runBlocking { // Failure Flow val failurePatGraph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/FAILURE, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val failurePathWorkflow = TestBluePrintWorkFlowService() - failurePathWorkflow.simulatedState = prepareSimulation(arrayListOf("B", "C", "D", "E"), - arrayListOf("A")) + 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") @@ -132,7 +139,7 @@ class BluePrintWorkflowServiceTest { 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() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D", "E"), null) val input = "123456" @@ -145,7 +152,7 @@ class BluePrintWorkflowServiceTest { fun testParallelFlow() { runBlocking { val graph = "[START>A/SUCCESS, A>B/SUCCESS, A>C/SUCCESS, B>D/SUCCESS, C>D/SUCCESS, D>END/SUCCESS]" - .toGraph() + .toGraph() val simpleWorkflow = TestBluePrintWorkFlowService() simpleWorkflow.simulatedState = prepareSimulation(arrayListOf("A", "B", "C", "D"), null) val input = "123456" @@ -176,8 +183,9 @@ class BluePrintWorkflowServiceTest { } } -class TestBluePrintWorkFlowService - : AbstractBluePrintWorkFlowService<String, String>() { +class TestBluePrintWorkFlowService : + AbstractBluePrintWorkFlowService<String, String>() { + val log = logger(TestBluePrintWorkFlowService::class) lateinit var simulatedState: MutableMap<String, EdgeLabel> @@ -201,17 +209,20 @@ class TestBluePrintWorkFlowService return startMessage.output.await() } - override suspend fun prepareNodeExecutionMessage(node: Graph.Node) - : NodeExecuteMessage<String, String> { + 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 + 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) @@ -225,19 +236,28 @@ class TestBluePrintWorkFlowService return NodeSkipMessage(node, "$node Skip Input", nodeOutput) } - override suspend fun skipNode(node: Graph.Node, nodeInput: String, - nodeOutput: String): EdgeLabel { + 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 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 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 { @@ -248,4 +268,4 @@ class TestBluePrintWorkFlowService } return "Final Response" } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt index 8517e7536..6413fb5fe 100644 --- 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 @@ -23,14 +23,12 @@ 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 @@ -54,7 +52,5 @@ class BluePrintFileUtilsTest { bluePrintContext.rootPath = targetDir.absolutePath BluePrintFileUtils.writeBluePrintTypes(bluePrintContext) - - } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtilsTest.kt index 2aea4bc2d..62bb0afcb 100644 --- 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 @@ -20,7 +20,6 @@ import kotlinx.coroutines.runBlocking import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintRetryException - class BluePrintIOUtilsTest { @Test @@ -39,4 +38,4 @@ class BluePrintIOUtilsTest { BluePrintIOUtils.retry<String>(4, 0, 500, executionBlock, exceptionBlock) } } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt index 6c0c30e3d..c29332d4f 100644 --- 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 @@ -17,7 +17,6 @@ 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 @@ -44,7 +43,6 @@ class BluePrintMetadataUtilsTest { assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition") assertNotNull(toscaMetaData.templateTags, "Missing Template Tags") } - } @Test @@ -78,4 +76,4 @@ class BluePrintMetadataUtilsTest { assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4") assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5") } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index d0e971ad7..aa4008759 100644 --- 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 @@ -16,13 +16,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.slf4j.LoggerFactory import kotlinx.coroutines.runBlocking import org.junit.Test +import org.slf4j.LoggerFactory class JacksonReactorUtilsTest { - private val log= LoggerFactory.getLogger(this::class.toString()) + private val log = LoggerFactory.getLogger(this::class.toString()) @Test fun testJsonNodeFromClassPathFile() { @@ -39,4 +39,4 @@ class JacksonReactorUtilsTest { JacksonReactorUtils.jsonNodeFromFile(filePath) } } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt index faa198faf..5facad7ef 100644 --- 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 @@ -17,9 +17,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.slf4j.LoggerFactory import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.slf4j.LoggerFactory import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -30,7 +30,7 @@ import kotlin.test.assertTrue */ class JacksonUtilsTest { - private val log= LoggerFactory.getLogger(this::class.toString()) + private val log = LoggerFactory.getLogger(this::class.toString()) @Test fun testJsonNodeFromClassPathFile() { @@ -51,7 +51,6 @@ class JacksonUtilsTest { assertNotNull(nodeType, "Failed to get String array from content") } - @Test fun testJsonValue() { val filePath = "data/alltype-data.json" @@ -71,7 +70,5 @@ class JacksonUtilsTest { assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") - - } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtilsTest.kt index 8a37a4b19..336e47604 100644 --- 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 @@ -55,4 +55,4 @@ class JsonParserUtilsTest { val parsedPath = jsonNode.jsonPaths("$..prop1") assertNotNull(parsedPath, "failed to get parsed path") } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt index 5da43484c..fc11947de 100644 --- 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 @@ -35,4 +35,4 @@ class TopologicalSortingUtilsTest { log.debug("Out-degrees: " + graph.outDegree()) log.debug("A topological sort of the vertices: " + graph.topSort()) } -}
\ No newline at end of file +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtilsTest.kt index fb0a1a63d..66272d61a 100644 --- 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 @@ -39,4 +39,4 @@ class WorkflowGraphUtilsTest { val graph = WorkflowGraphUtils.workFlowToGraph(workflow) assertNotNull(graph, "failed to create graph") } -}
\ No newline at end of file +} 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 index 4f4d210ca..5dd1937f8 100644 --- 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 @@ -26,8 +26,10 @@ class ActivateBlueprintDefinitions : AbstractBluePrintDefinitions() { override fun serviceTemplate(): ServiceTemplate { - return serviceTemplate("sample-blue-print", "1.0.0", - "brindasanth@onap.com", "sample, blueprints") { + return serviceTemplate( + "sample-blue-print", "1.0.0", + "brindasanth@onap.com", "sample, blueprints" + ) { topologyTemplate { workflowNodeTemplate("activate", "component-resource-resolution", "") { operation("ResourceResolutionExecutor", "") { @@ -42,12 +44,14 @@ class ActivateBlueprintDefinitions : AbstractBluePrintDefinitions() { override fun loadOtherDefinitions() { /** Sample Definitions */ - val customDataType = dataType("custom-datatype", "1.0.0", - BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, "") { + 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) } -}
\ No newline at end of file +} 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 index aa77bc30b..8bd060e17 100644 --- 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 @@ -25,19 +25,19 @@ open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String> { } override fun prepareRequest(executionRequest: String): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + 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. + 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. + 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. + TODO("not implemented") // To change body of created functions use File | Settings | File Templates. } override fun apply(t: String): String { @@ -45,22 +45,22 @@ open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String> { } override suspend fun prepareRequestNB(executionRequest: String): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + 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. + 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. + 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. + 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. + TODO("not implemented") // To change body of created functions use File | Settings | File Templates. } -}
\ No newline at end of file +} |