Metadata for name, version, tags and type
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / python-executor / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / python / executor / ComponentRemotePythonExecutorTest.kt
index 89af425..3d58afa 100644 (file)
@@ -22,7 +22,12 @@ import io.mockk.every
 import io.mockk.mockk
 import kotlinx.coroutines.runBlocking
 import org.junit.Test
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StatusType
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.RemoteScriptExecutionService
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
@@ -34,7 +39,6 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import kotlin.test.assertEquals
 import kotlin.test.assertNotNull
 
-
 class ComponentRemotePythonExecutorTest {
 
     @Test
@@ -45,16 +49,21 @@ class ComponentRemotePythonExecutorTest {
             val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService)
 
             val executionServiceInput =
-                    JacksonUtils.readValueFromClassPathFile("payload/requests/sample-remote-python-request.json",
-                            ExecutionServiceInput::class.java)!!
-
+                JacksonUtils.readValueFromClassPathFile(
+                    "payload/requests/sample-remote-python-request.json",
+                    ExecutionServiceInput::class.java
+                )!!
 
-            val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("123456-1000",
-                    "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts")
+            val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+                "123456-1000",
+                "./../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
+            )
 
             /** Load Workflow Inputs */
-            bluePrintRuntimeService.assignWorkflowInputs("execute-remote-python",
-                    executionServiceInput.payload.get("execute-remote-python-request"))
+            bluePrintRuntimeService.assignWorkflowInputs(
+                "execute-remote-python",
+                executionServiceInput.payload.get("execute-remote-python-request")
+            )
 
             val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
             stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "execute-remote-python")
@@ -93,17 +102,20 @@ class ComponentRemotePythonExecutorTest {
      * Mocked input information for remote python executor.
      */
     fun getMockedOutput(svc: DefaultBluePrintRuntimeService):
-            ExecutionServiceInput {
+        ExecutionServiceInput {
         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
 
         stepMetaData.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
-                "execute-remote-python")
+            BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+            "execute-remote-python"
+        )
         stepMetaData.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
-                "ComponentRemotePythonExecutor")
+            BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+            "ComponentRemotePythonExecutor"
+        )
         stepMetaData.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+            BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process"
+        )
 
         val mapper = ObjectMapper()
         val rootNode = mapper.createObjectNode()
@@ -112,13 +124,16 @@ class ComponentRemotePythonExecutorTest {
 
         val operationalInputs: MutableMap<String, JsonNode> = hashMapOf()
         operationalInputs.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
-                "execute-remote-python")
+            BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE,
+            "execute-remote-python"
+        )
         operationalInputs.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
-                "ComponentRemotePythonExecutor")
+            BluePrintConstants.PROPERTY_CURRENT_INTERFACE,
+            "ComponentRemotePythonExecutor"
+        )
         operationalInputs.putJsonElement(
-                BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+            BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process"
+        )
         operationalInputs.putJsonElement("endpoint-selector", "aai")
         operationalInputs.putJsonElement("dynamic-properties", rootNode)
         operationalInputs.putJsonElement("command", "./run.sh")
@@ -126,8 +141,9 @@ class ComponentRemotePythonExecutorTest {
 
         every {
             svc.resolveNodeTemplateInterfaceOperationInputs(
-                    "execute-remote-python",
-                    "ComponentRemotePythonExecutor", "process")
+                "execute-remote-python",
+                "ComponentRemotePythonExecutor", "process"
+            )
         } returns operationalInputs
 
         val stepInputData = StepData().apply {
@@ -136,42 +152,50 @@ class ComponentRemotePythonExecutorTest {
         }
 
         val executionServiceInput = JacksonUtils
-                .readValueFromClassPathFile(
-                        "payload/requests/sample-remote-python-request.json",
-                        ExecutionServiceInput::class.java)!!
+            .readValueFromClassPathFile(
+                "payload/requests/sample-remote-python-request.json",
+                ExecutionServiceInput::class.java
+            )!!
         executionServiceInput.stepData = stepInputData
 
         val operationOutputs = hashMapOf<String, JsonNode>()
         every {
             svc.resolveNodeTemplateInterfaceOperationOutputs(
-                    "execute-remote-python",
-                    "ComponentRemotePythonExecutor", "process")
+                "execute-remote-python",
+                "ComponentRemotePythonExecutor", "process"
+            )
         } returns operationOutputs
-        val bluePrintRuntimeService = BluePrintMetadataUtils
-                .getBluePrintRuntime("123456-1000",
-                        "./../../../../components/model-" +
-                                "catalog/blueprint-model/test-blueprint/" +
-                                "remote_scripts")
+        val bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime(
+            "123456-1000",
+            "./../../../../components/model-" +
+                "catalog/blueprint-model/test-blueprint/" +
+                "remote_scripts"
+        )
         every {
             svc.resolveNodeTemplateArtifactDefinition(
-                    "execute-remote-python", "component-script")
+                "execute-remote-python", "component-script"
+            )
         } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(
-                "execute-remote-python", "component-script")
+            "execute-remote-python", "component-script"
+        )
         every {
             svc.setNodeTemplateAttributeValue(
-                    "execute-remote-python", "prepare-environment-logs",
-                    "prepared successfully".asJsonPrimitive())
+                "execute-remote-python", "prepare-environment-logs",
+                "prepared successfully".asJsonPrimitive()
+            )
         } returns Unit
         every {
             svc.setNodeTemplateAttributeValue(
-                    "execute-remote-python",
-                    "execute-command-logs", "N/A".asJsonPrimitive())
+                "execute-remote-python",
+                "execute-command-logs", "N/A".asJsonPrimitive()
+            )
         } returns Unit
         every {
             svc.setNodeTemplateAttributeValue(
-                    "execute-remote-python",
-                    "execute-command-logs",
-                    "processed successfully".asJsonPrimitive())
+                "execute-remote-python",
+                "execute-command-logs",
+                "processed successfully".asJsonPrimitive()
+            )
         } returns Unit
 
         every {
@@ -211,6 +235,5 @@ class MockRemoteScriptExecutionService : RemoteScriptExecutionService {
     }
 
     override suspend fun close() {
-
     }
 }