import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import org.junit.Test
-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.core.api.data.*
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
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService)
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput =
+ 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")
+ /** Load Workflow Inputs */
+ 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")
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentRemotePythonExecutor")
@Test
fun testComponentRemotePythonExecutorProcessNB() {
runBlocking {
- val remoteScriptExecutionService =
- MockRemoteScriptExecutionService()
- val componentRemotePythonExecutor = ComponentRemotePythonExecutor(
- remoteScriptExecutionService)
- val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>(
- "123456-1000")
- val input = getMockedOutput(bluePrintRuntime)
- componentRemotePythonExecutor.bluePrintRuntimeService =
- bluePrintRuntime
+ val remoteScriptExecutionService = MockRemoteScriptExecutionService()
+ val componentRemotePythonExecutor = ComponentRemotePythonExecutor(remoteScriptExecutionService)
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("123456-1000")
+
+ every { bluePrintRuntime.setNodeTemplateAttributeValue(any(), any(), any()) } answers {}
+
+ val input = getMockedOutput(bluePrintRuntime)
+ componentRemotePythonExecutor.bluePrintRuntimeService = bluePrintRuntime
componentRemotePythonExecutor.applyNB(input)
}
}
"processed successfully".asJsonPrimitive())
} returns Unit
+ every {
+ svc.resolveDSLExpression("aai")
+ } returns """{"url" : "http://xxx.com"}""".asJsonType()
+
every {
svc.bluePrintContext()
} returns bluePrintRuntimeService.bluePrintContext()
}
class MockRemoteScriptExecutionService : RemoteScriptExecutionService {
- override suspend fun init(selector: String) {
+ override suspend fun init(selector: Any) {
}
override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput {