summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt20
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt19
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json7
3 files changed, 39 insertions, 7 deletions
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index 8759338b7..5163a93ac 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -154,6 +154,26 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
bluePrintRuntimeService.getBluePrintError().addError(error)
}
+ /**
+ * Get Execution Input Payload data
+ */
+ fun requestPayload(): JsonNode? {
+ return executionServiceInput.payload
+ }
+
+ /**
+ * Get Execution Input payload action property with [expression]
+ * ex: requestPayloadActionProperty("data") will look for path "payload/<action-name>-request/data"
+ */
+ fun requestPayloadActionProperty(expression: String?): JsonNode? {
+ val requestExpression = if (expression.isNullOrBlank()) {
+ "$operationName-request"
+ } else {
+ "$operationName-request.$expression"
+ }
+ return executionServiceInput.payload.jsonPathParse(".$requestExpression")
+ }
+
fun artifactContent(artifactName: String): String {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
index 07be8c809..16e4e611b 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
@@ -70,9 +70,6 @@ class AbstractComponentFunctionTest {
every { blueprintContext.rootPath } returns normalizedPathName("target")
}
- /**
- * Tests the abstract component functionality.
- */
@Test
fun testAbstractComponent() {
runBlocking {
@@ -95,9 +92,18 @@ class AbstractComponentFunctionTest {
}
}
- /**
- * Tests the abstract script component functionality.
- */
+ @Test
+ fun testComponentFunctionPayload() {
+ val sampleComponent = SampleComponent()
+ sampleComponent.operationName = "sample-action"
+ sampleComponent.executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-execution-request.json", ExecutionServiceInput::class.java)!!
+ val payload = sampleComponent.requestPayload()
+ assertNotNull(payload, "failed to get payload")
+ val data = sampleComponent.requestPayloadActionProperty("data")?.first()
+ assertNotNull(data, "failed to get payload request action data")
+ }
+
@Test
fun testAbstractScriptComponent() {
runBlocking {
@@ -190,5 +196,6 @@ class AbstractComponentFunctionTest {
val componentScriptExecutor = BluePrintTypes.nodeTypeComponentScriptExecutor()
assertNotNull(componentScriptExecutor.interfaces, "failed to get interface operations")
}
+
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json
index 27eec8275..c9b8ed2a7 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json
@@ -16,5 +16,10 @@
"timestamp": "2012-04-23T18:25:43.511Z"
},
"payload": {
+ "sample-action-request": {
+ "data": {
+ "prop": "value"
+ }
+ }
}
-}
+} \ No newline at end of file