diff options
author | Brinda Santh <bs2796@att.com> | 2019-11-09 20:35:47 -0500 |
---|---|---|
committer | Brinda Santh <bs2796@att.com> | 2019-11-09 20:51:26 -0500 |
commit | d425c6319a995402163c8868e9fe40f3d88f02ea (patch) | |
tree | 35136b666645b507d8f588dd7122ed19f57d7247 /ms/blueprintsprocessor/functions/netconf-executor | |
parent | 54eb2f2680d4f2447a4d48b612b2b83e37d90754 (diff) |
Convert component functions IT to UT.
Issue-ID: CCSDK-1735
Convert Netconf and Restconf Executor IT to UT.
Remove duplicate BluePrintProperties.
Signed-off-by: Brinda Santh <bs2796@att.com>
Change-Id: I2eafdbabb17a4df72541ab93c46e7fc9eb0fe8d7
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor')
-rw-r--r-- | ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt index 8a08268d8..be3ee4614 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt @@ -20,51 +20,56 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import com.fasterxml.jackson.databind.JsonNode +import io.mockk.coEvery +import io.mockk.every +import io.mockk.mockk +import io.mockk.spyk import kotlinx.coroutines.runBlocking import org.junit.Test -import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.EnableAutoConfiguration -import org.springframework.context.annotation.ComponentScan -import org.springframework.test.annotation.DirtiesContext -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner - -@RunWith(SpringRunner::class) -@EnableAutoConfiguration -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) -@DirtiesContext -@TestPropertySource(properties = -["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints", - "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"], - locations = ["classpath:application-test.properties"]) -class ComponentNetconfExecutorTest { - - @Autowired - lateinit var componentNetconfExecutor: ComponentNetconfExecutor +import org.springframework.context.ApplicationContext +class ComponentNetconfExecutorTest { @Test fun testComponentNetconfExecutor() { runBlocking { + + val applicationContext = mockk<ApplicationContext>() + every { applicationContext.getBean(any()) } returns mockk() + + val blueprintJythonService = mockk<BlueprintJythonService>() + val mockAbstractScriptComponentFunction = spyk<AbstractScriptComponentFunction>() + coEvery { mockAbstractScriptComponentFunction.executeScript(any()) } returns mockk() + + coEvery { blueprintJythonService.jythonComponentInstance(any(), any()) } returns mockAbstractScriptComponentFunction + + val componentFunctionScriptingService = ComponentFunctionScriptingService(applicationContext, + blueprintJythonService) + + val componentNetconfExecutor = ComponentNetconfExecutor(componentFunctionScriptingService) + val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json", ExecutionServiceInput::class.java)!! val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") - val assignmentParams = "{\n" + - " \"ipAddress\": \"127.0.0.1\",\n" + - " \"hostName\": \"vnf-host\"\n" + - " }" + val assignmentParams = """{ + "ipAddress" : "127.0.0.1", + "hostName" : "vnf-host" + } + """.trimIndent() val json = """{ "hostname" : "127.0.0.1" @@ -75,8 +80,6 @@ class ComponentNetconfExecutorTest { bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", JacksonUtils.jsonNode(assignmentParams)) - val executionContext = bluePrintRuntimeService.getExecutionContext() - componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService //TODO("Set Attribute properties") @@ -93,7 +96,6 @@ class ComponentNetconfExecutorTest { executionServiceInput.stepData = stepInputData componentNetconfExecutor.applyNB(executionServiceInput) } - } } |