diff options
author | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-04-03 21:36:57 -0400 |
---|---|---|
committer | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-04-04 08:09:16 -0400 |
commit | 0007063cc856483e36dd49718dea5dda80ed6809 (patch) | |
tree | f97d43008e4f0d816a8041b02e5d986cc5f3557e /ms/blueprintsprocessor/functions/restconf-executor/src | |
parent | a2a21cd7a80c3ff3b754d7a4e47fc48f45ff2312 (diff) |
Improve step data access.
Change-Id: I3917905b1e38cebcb26e4422784a5553e2dbac9f
Issue-ID: CCSDK-1127
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/restconf-executor/src')
-rw-r--r-- | ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt | 79 |
1 files changed, 43 insertions, 36 deletions
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<DefaultBluePrintRuntimeService>("1234") - componentRestconfExecutor.bluePrintRuntimeService = bluePrintRuntime - componentRestconfExecutor.stepName = "sample-step" + val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234") + componentRestconfExecutor.bluePrintRuntimeService = bluePrintRuntime + componentRestconfExecutor.stepName = "sample-step" - val operationInputs = hashMapOf<String, JsonNode>() - 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<String, JsonNode>() + 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<BluePrintContext>() - 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<String, JsonNode>() - every { - bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf", - "interfaceName", "operationName") - } returns operationOutputs - every { bluePrintRuntime.put("sample-step-step-outputs", any()) } returns Unit + val blueprintContext = mockk<BluePrintContext>() + every { bluePrintRuntime.bluePrintContext() } returns blueprintContext + every { + bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf", + "interfaceName", "operationName") + } returns operationInputs - componentRestconfExecutor.apply(executionServiceInput) + val operationOutputs = hashMapOf<String, JsonNode>() + every { + bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf", + "interfaceName", "operationName") + } returns operationOutputs + + componentRestconfExecutor.applyNB(executionServiceInput) + } } }
\ No newline at end of file |