From 0007063cc856483e36dd49718dea5dda80ed6809 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 3 Apr 2019 21:36:57 -0400 Subject: Improve step data access. Change-Id: I3917905b1e38cebcb26e4422784a5553e2dbac9f Issue-ID: CCSDK-1127 Signed-off-by: Muthuramalingam, Brinda Santh --- .../executor/ComponentRestconfExecutorTest.kt | 79 ++++++++++++---------- 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'ms/blueprintsprocessor/functions/restconf-executor') diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt index 24eb453c9..a651dad52 100644 --- a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt @@ -21,13 +21,14 @@ import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode import io.mockk.every import io.mockk.mockk +import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader 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.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService @@ -51,7 +52,7 @@ import kotlin.test.assertNotNull "blueprintsprocessor.restclient.odlPrimary.url=http://127.0.0.1:9111", "blueprintsprocessor.restclient.odlPrimary.userId=sampleuser", "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"], - locations = ["classpath:application-test.properties"]) + locations = ["classpath:application-test.properties"]) class ComponentRestconfExecutorTest { @Autowired @@ -59,44 +60,50 @@ class ComponentRestconfExecutorTest { @Test fun `test Restconf Component Instance`() { - assertNotNull(componentRestconfExecutor, "failed to get ComponentRestconfExecutor instance") - val executionServiceInput = ExecutionServiceInput().apply { - commonHeader = CommonHeader().apply { - requestId = "1234" + runBlocking { + assertNotNull(componentRestconfExecutor, "failed to get ComponentRestconfExecutor instance") + val executionServiceInput = ExecutionServiceInput().apply { + commonHeader = CommonHeader().apply { + requestId = "1234" + } + actionIdentifiers = ActionIdentifiers().apply { + actionName = "activate" + } + payload = JacksonUtils.jsonNode("{}") as ObjectNode } - actionIdentifiers = ActionIdentifiers().apply { - actionName = "activate" - } - payload = JacksonUtils.jsonNode("{}") as ObjectNode - } - val bluePrintRuntime = mockk("1234") - componentRestconfExecutor.bluePrintRuntimeService = bluePrintRuntime - componentRestconfExecutor.stepName = "sample-step" + val bluePrintRuntime = mockk("1234") + componentRestconfExecutor.bluePrintRuntimeService = bluePrintRuntime + componentRestconfExecutor.stepName = "sample-step" - val operationInputs = hashMapOf() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "activate-restconf".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive() - operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive() - operationInputs[ComponentRestconfExecutor.SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive() - operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] = - "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive() - operationInputs[ComponentRestconfExecutor.INSTANCE_DEPENDENCIES] = JacksonUtils.jsonNode("[]") as ArrayNode + val operationInputs = hashMapOf() + operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "activate-restconf".asJsonPrimitive() + operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive() + operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive() + operationInputs[ComponentRestconfExecutor.SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive() + operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] = + "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive() + operationInputs[ComponentRestconfExecutor.INSTANCE_DEPENDENCIES] = JacksonUtils.jsonNode("[]") as ArrayNode - val blueprintContext = mockk() - every { bluePrintRuntime.bluePrintContext() } returns blueprintContext - every { bluePrintRuntime.get("sample-step-step-inputs") } returns operationInputs.asJsonNode() - every { - bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf", - "interfaceName", "operationName") - } returns operationInputs + val stepInputData = StepData().apply { + name = "activate-restconf" + properties = operationInputs + } + executionServiceInput.stepData = stepInputData - val operationOutputs = hashMapOf() - every { - bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf", - "interfaceName", "operationName") - } returns operationOutputs - every { bluePrintRuntime.put("sample-step-step-outputs", any()) } returns Unit + val blueprintContext = mockk() + every { bluePrintRuntime.bluePrintContext() } returns blueprintContext + every { + bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf", + "interfaceName", "operationName") + } returns operationInputs - componentRestconfExecutor.apply(executionServiceInput) + val operationOutputs = hashMapOf() + every { + bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf", + "interfaceName", "operationName") + } returns operationOutputs + + componentRestconfExecutor.applyNB(executionServiceInput) + } } } \ No newline at end of file -- cgit 1.2.3-korg