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)
}
every { blueprintContext.rootPath } returns normalizedPathName("target")
}
- /**
- * Tests the abstract component functionality.
- */
@Test
fun testAbstractComponent() {
runBlocking {
}
}
- /**
- * 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 {
val componentScriptExecutor = BluePrintTypes.nodeTypeComponentScriptExecutor()
assertNotNull(componentScriptExecutor.interfaces, "failed to get interface operations")
}
+
}