Component Script Executor Fix 84/97084/1
authorSingal, Kapil (ks220y) <ks220y@att.com>
Mon, 14 Oct 2019 20:37:45 +0000 (16:37 -0400)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Mon, 14 Oct 2019 20:37:45 +0000 (16:37 -0400)
Fixing ExecutionServiceInput object initialization and related test cases

Issue-ID: CCSDK-1829
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I43354487abfb10a98b29d749aa77b08cfdff51b8

components/model-catalog/blueprint-model/test-blueprint/capability_cli/Scripts/kotlin/cba/capability/cli/CapabilityCli.kt
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt

index d29abb0..9552b61 100644 (file)
@@ -35,7 +35,8 @@ open class Check : AbstractScriptComponentFunction() {
     override suspend fun processNB(executionRequest: ExecutionServiceInput) {
         log.info("Executing process : ${executionRequest.payload}")
 
-        val data = executionRequest.payload.at("/check-request/data")
+        val data = requestPayloadActionProperty("data")?.first()
+            ?: throw BluePrintProcessorException("Failed to load payload data properties.")
 
         log.info("Data : ${data.asJsonString()}")
 
index 5163a93..bee9192 100644 (file)
@@ -167,9 +167,9 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
      */
     fun requestPayloadActionProperty(expression: String?): JsonNode? {
         val requestExpression = if (expression.isNullOrBlank()) {
-            "$operationName-request"
+            "$workflowName-request"
         } else {
-            "$operationName-request.$expression"
+            "$workflowName-request.$expression"
         }
         return executionServiceInput.payload.jsonPathParse(".$requestExpression")
     }
index a16c520..062d370 100644 (file)
@@ -54,6 +54,7 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
         scriptComponent.operationName = componentFunction.operationName
         scriptComponent.nodeTemplateName = componentFunction.nodeTemplateName
         scriptComponent.operationInputs = componentFunction.operationInputs
+        scriptComponent.executionServiceInput = componentFunction.executionServiceInput
         scriptComponent.scriptType = scriptType
 
         // Populate Instance Properties
index 16e4e61..2fc9a99 100644 (file)
@@ -95,7 +95,7 @@ class AbstractComponentFunctionTest {
     @Test
     fun testComponentFunctionPayload() {
         val sampleComponent = SampleComponent()
-        sampleComponent.operationName = "sample-action"
+        sampleComponent.workflowName = "sample-action"
         sampleComponent.executionServiceInput = JacksonUtils.readValueFromClassPathFile(
             "payload/requests/sample-execution-request.json", ExecutionServiceInput::class.java)!!
         val payload = sampleComponent.requestPayload()