summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/services
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/modules/services')
-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/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt4
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt47
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt15
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt70
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt77
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt31
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt6
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt5
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt11
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt50
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt62
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt28
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt33
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt13
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt22
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt84
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt18
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt20
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt59
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt39
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt24
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt14
36 files changed, 588 insertions, 410 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 bee919249..1abac7f3d 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
@@ -17,7 +17,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
-
import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.withTimeout
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
@@ -25,8 +24,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutp
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
+import org.onap.ccsdk.cds.controllerblueprints.core.getOptionalAsInt
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
import org.slf4j.LoggerFactory
@@ -36,6 +42,7 @@ import org.slf4j.LoggerFactory
* @author Brinda Santh
*/
abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
+
@Transient
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
@@ -85,7 +92,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }
val operationResolvedProperties = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
+ .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
this.operationInputs.putAll(operationResolvedProperties)
@@ -103,7 +110,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
try {
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
val stepOutputData = StepData().apply {
name = stepName
@@ -135,7 +142,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
fun getOperationInput(key: String): JsonNode {
return operationInputs[key]
- ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
}
fun getOptionalOperationInput(key: String): JsonNode? {
@@ -188,5 +195,4 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
val file = normalizedFile(bluePrintRuntimeService.bluePrintContext().rootPath, artifactDefinition.file)
return file.readNBLines()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
index f17085ef1..041588616 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt
@@ -45,7 +45,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() {
@Deprecated("Dependencies will be resolved dynamically")
open fun <T> functionDependencyInstanceAsType(name: String): T {
return functionDependencyInstances[name] as? T
- ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
}
fun checkDynamicProperties(key: String): Boolean {
@@ -125,4 +125,4 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() {
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
throw BluePrintException("Not Implemented, child class will implement this")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
index 67ab9c4de..e573afd7a 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractServiceFunction.kt
@@ -109,4 +109,4 @@ abstract class AbstractServiceFunction : BlueprintFunctionNode<ExecutionServiceI
}
return executionServiceInput.payload.jsonPathParse(".$requestExpression")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
index 062d370bc..4c7d5d0ec 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
@@ -28,21 +28,29 @@ import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
@Service
-class ComponentFunctionScriptingService(private val applicationContext: ApplicationContext,
- private val blueprintJythonService: BlueprintJythonService) {
+class ComponentFunctionScriptingService(
+ private val applicationContext: ApplicationContext,
+ private val blueprintJythonService: BlueprintJythonService
+) {
private val log = LoggerFactory.getLogger(ComponentFunctionScriptingService::class.java)
- suspend fun <T : AbstractScriptComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction,
- scriptType: String,
- scriptClassReference: String,
- instanceDependencies: List<String>): T {
+ suspend fun <T : AbstractScriptComponentFunction> scriptInstance(
+ componentFunction: AbstractComponentFunction,
+ scriptType: String,
+ scriptClassReference: String,
+ instanceDependencies: List<String>
+ ): T {
- log.info("creating component function of script type($scriptType), reference name($scriptClassReference) and " +
- "instanceDependencies($instanceDependencies)")
+ log.info(
+ "creating component function of script type($scriptType), reference name($scriptClassReference) and " +
+ "instanceDependencies($instanceDependencies)"
+ )
- val scriptComponent: T = scriptInstance(componentFunction.bluePrintRuntimeService.bluePrintContext(),
- scriptType, scriptClassReference)
+ val scriptComponent: T = scriptInstance(
+ componentFunction.bluePrintRuntimeService.bluePrintContext(),
+ scriptType, scriptClassReference
+ )
checkNotNull(scriptComponent) { "failed to initialize script component" }
@@ -60,14 +68,16 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
// Populate Instance Properties
instanceDependencies.forEach { instanceDependency ->
scriptComponent.functionDependencyInstances[instanceDependency] = applicationContext
- .getBean(instanceDependency)
+ .getBean(instanceDependency)
}
return scriptComponent
}
-
- suspend fun <T : BlueprintFunctionNode<*, *>> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
- scriptClassReference: String): T {
+ suspend fun <T : BlueprintFunctionNode<*, *>> scriptInstance(
+ bluePrintContext: BluePrintContext,
+ scriptType: String,
+ scriptClassReference: String
+ ): T {
var scriptComponent: T? = null
when (scriptType) {
@@ -77,8 +87,10 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
}
BluePrintConstants.SCRIPT_KOTLIN -> {
val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl()
- scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext.rootPath,
- bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false)
+ scriptComponent = bluePrintScriptsService.scriptInstance<T>(
+ bluePrintContext.rootPath,
+ bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false
+ )
}
BluePrintConstants.SCRIPT_JYTHON -> {
scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T
@@ -89,5 +101,4 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
}
return scriptComponent
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
index c66c3e913..09eee6717 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
@@ -28,8 +28,8 @@ import org.springframework.stereotype.Component
*/
@Component("component-script-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentScriptExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService)
- : AbstractComponentFunction() {
+open class ComponentScriptExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
+ AbstractComponentFunction() {
companion object {
const val INPUT_SCRIPT_TYPE = "script-type"
@@ -53,8 +53,10 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
val scriptDependencies: MutableList<String> = arrayListOf()
populateScriptDependencies(scriptDependencies)
- scriptComponentFunction = componentFunctionScriptingService.scriptInstance(this, scriptType,
- scriptClassReference, scriptDependencies)
+ scriptComponentFunction = componentFunctionScriptingService.scriptInstance(
+ this, scriptType,
+ scriptClassReference, scriptDependencies
+ )
// Handles both script processing and error handling
scriptComponentFunction.executeScript(executionServiceInput)
@@ -62,11 +64,10 @@ open class ComponentScriptExecutor(private var componentFunctionScriptingService
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError()
- .addError("Failed in ComponentCliExecutor : ${runtimeException.message}")
-
+ .addError("Failed in ComponentCliExecutor : ${runtimeException.message}")
}
open fun populateScriptDependencies(scriptDependencies: MutableList<String>) {
/** Place holder for Child to add extra dependencies */
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
index 89338b781..d4ca0f487 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
@@ -31,52 +31,72 @@ import kotlin.reflect.KClass
/** Component Extensions **/
fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
- return nodeType(id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- description = "Generic Script Component Executor") {
+ return nodeType(
+ id = "component-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ description = "Generic Script Component Executor"
+ ) {
attribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false)
attribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true)
operation("ComponentScriptExecutor", "ComponentScriptExecutor Operation") {
inputs {
- property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Script Type") {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Script Type"
+ ) {
defaultValue(BluePrintConstants.SCRIPT_INTERNAL)
constrain {
- validValues(listOf(BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
+ validValues(
+ listOf(
+ BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(),
- BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()))
+ BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()
+ )
+ )
}
}
- property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Kotlin Script class name or jython script name.")
- property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Kotlin Script class name or jython script name."
+ )
+ property(
+ ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Dynamic Json Content or DSL Json reference."
+ )
}
outputs {
- property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
- false, "Output Response")
- property(ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Status of the Component Execution ( success or failure )")
+ property(
+ ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Output Response"
+ )
+ property(
+ ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Status of the Component Execution ( success or failure )"
+ )
}
}
}
}
/** Component Builder */
-fun BluePrintTypes.nodeTemplateComponentScriptExecutor(id: String,
- description: String,
- block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit)
- : NodeTemplate {
+fun BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
+):
+ NodeTemplate {
return ComponentScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
- "ComponentScriptExecutor",
- description) {
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
+ id, "component-script-executor",
+ "ComponentScriptExecutor",
+ description
+ ) {
class InputsBuilder : PropertiesAssignmentBuilder() {
@@ -117,4 +137,4 @@ class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String
property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, responseData)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
index 806c33039..3ff54076d 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ExecutionServiceConfiguration.kt
@@ -23,7 +23,6 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
open class ExecutionServiceConfiguration
-
object ExecutionServiceConstant {
const val SERVICE_GRPC_REMOTE_SCRIPT_EXECUTION = "grpc-remote-script-execution-service"
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
index d6146e111..3b83261e5 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
@@ -21,10 +21,19 @@ import com.google.protobuf.Struct
import com.google.protobuf.Timestamp
import com.google.protobuf.util.JsonFormat
import io.grpc.ManagedChannel
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteIdentifier
+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.grpc.service.BluePrintGrpcClientService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
-import org.onap.ccsdk.cds.controllerblueprints.command.api.*
+import org.onap.ccsdk.cds.controllerblueprints.command.api.CommandExecutorServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionInput
+import org.onap.ccsdk.cds.controllerblueprints.command.api.ExecutionOutput
+import org.onap.ccsdk.cds.controllerblueprints.command.api.Identifiers
+import org.onap.ccsdk.cds.controllerblueprints.command.api.Packages
+import org.onap.ccsdk.cds.controllerblueprints.command.api.PrepareEnvInput
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
@@ -41,11 +50,13 @@ interface RemoteScriptExecutionService {
}
@Service(ExecutionServiceConstant.SERVICE_GRPC_REMOTE_SCRIPT_EXECUTION)
-@ConditionalOnProperty(prefix = "blueprintprocessor.remoteScriptCommand", name = arrayOf("enabled"),
- havingValue = "true", matchIfMissing = false)
+@ConditionalOnProperty(
+ prefix = "blueprintprocessor.remoteScriptCommand", name = arrayOf("enabled"),
+ havingValue = "true", matchIfMissing = false
+)
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService)
- : RemoteScriptExecutionService {
+class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) :
+ RemoteScriptExecutionService {
private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!!
@@ -70,8 +81,8 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
}
}
- override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput)
- : RemoteScriptExecutionOutput {
+ override suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput):
+ RemoteScriptExecutionOutput {
val grpResponse = commandExecutorServiceGrpc.prepareEnv(prepareEnvInput.asGrpcData())
checkNotNull(grpResponse.status) {
@@ -84,8 +95,8 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
return remoteScriptExecutionOutput
}
- override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput)
- : RemoteScriptExecutionOutput {
+ override suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput):
+ RemoteScriptExecutionOutput {
val grpResponse = commandExecutorServiceGrpc.executeCommand(remoteExecutionInput.asGrpcData())
@@ -103,7 +114,6 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
channel?.shutdownNow()
}
-
fun PrepareRemoteEnvInput.asGrpcData(): PrepareEnvInput {
val correlationId = this.correlationId ?: this.requestId
@@ -116,33 +126,33 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
}
return PrepareEnvInput.newBuilder()
- .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
- .setRequestId(this.requestId)
- .setCorrelationId(correlationId)
- .setTimeOut(this.timeOut.toInt())
- .addAllPackages(packageList)
- .setProperties(this.properties.asGrpcData())
- .build()
+ .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
+ .setRequestId(this.requestId)
+ .setCorrelationId(correlationId)
+ .setTimeOut(this.timeOut.toInt())
+ .addAllPackages(packageList)
+ .setProperties(this.properties.asGrpcData())
+ .build()
}
fun RemoteScriptExecutionInput.asGrpcData(): ExecutionInput {
val correlationId = this.correlationId ?: this.requestId
return ExecutionInput.newBuilder()
- .setRequestId(this.requestId)
- .setCorrelationId(correlationId)
- .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
- .setCommand(this.command)
- .setTimeOut(this.timeOut.toInt())
- .setProperties(this.properties.asGrpcData())
- .setTimestamp(Timestamp.getDefaultInstance())
- .build()
+ .setRequestId(this.requestId)
+ .setCorrelationId(correlationId)
+ .setIdentifiers(this.remoteIdentifier!!.asGrpcData())
+ .setCommand(this.command)
+ .setTimeOut(this.timeOut.toInt())
+ .setProperties(this.properties.asGrpcData())
+ .setTimestamp(Timestamp.getDefaultInstance())
+ .build()
}
fun RemoteIdentifier.asGrpcData(): Identifiers? {
return Identifiers.newBuilder()
- .setBlueprintName(this.blueprintName)
- .setBlueprintVersion(this.blueprintVersion)
- .build()
+ .setBlueprintName(this.blueprintName)
+ .setBlueprintVersion(this.blueprintVersion)
+ .build()
}
fun Map<String, JsonNode>.asGrpcData(): Struct {
@@ -153,11 +163,10 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
fun ExecutionOutput.asJavaData(): RemoteScriptExecutionOutput {
return RemoteScriptExecutionOutput(
- requestId = this.requestId,
- response = this.responseList,
- status = StatusType.valueOf(this.status.name),
- payload = payload.jsonAsJsonType()
+ requestId = this.requestId,
+ response = this.responseList,
+ status = StatusType.valueOf(this.status.name),
+ payload = payload.jsonAsJsonType()
)
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
index adb1d67d2..239ff00c5 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionService.kt
@@ -20,10 +20,14 @@ import com.fasterxml.jackson.databind.JsonNode
import com.github.marcoferrer.krotoplus.coroutines.client.ClientBidiCallChannel
import com.github.marcoferrer.krotoplus.coroutines.client.clientCallBidiStreaming
import io.grpc.ManagedChannel
-import kotlinx.coroutines.*
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withTimeout
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GrpcClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService
import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
@@ -50,10 +54,12 @@ interface StreamingRemoteExecutionService<ReqT, ResT> {
}
@Service
-@ConditionalOnProperty(prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"],
- havingValue = "true", matchIfMissing = false)
-class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService)
- : StreamingRemoteExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+@ConditionalOnProperty(
+ prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"],
+ havingValue = "true", matchIfMissing = false
+)
+class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) :
+ StreamingRemoteExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = logger(StreamingRemoteExecutionServiceImpl::class)
@@ -62,7 +68,6 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
private val commChannels: MutableMap<String,
ClientBidiCallChannel<ExecutionServiceInput, ExecutionServiceOutput>> = hashMapOf()
-
/**
* Open new channel to send and receive for grpc properties [selector] for [txId],
* Create the only one GRPC channel per host port and reuse for further communication.
@@ -84,7 +89,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
}
val commChannel = commChannels[txId]
- ?: throw BluePrintException("failed to create response subscription for transactionId($txId) channel")
+ ?: throw BluePrintException("failed to create response subscription for transactionId($txId) channel")
log.info("created subscription for transactionId($txId)")
@@ -97,7 +102,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
*/
override suspend fun send(txId: String, input: ExecutionServiceInput) {
val sendChannel = commChannels[txId]?.requestChannel
- ?: throw BluePrintException("failed to get transactionId($txId) send channel")
+ ?: throw BluePrintException("failed to get transactionId($txId) send channel")
coroutineScope {
launch {
sendChannel.send(input)
@@ -114,15 +119,15 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
* so the correlation is sub request id to receive the response.
*/
@ExperimentalCoroutinesApi
- override suspend fun sendNonInteractive(selector: Any, txId: String, input: ExecutionServiceInput, timeOutMill: Long)
- : ExecutionServiceOutput {
+ override suspend fun sendNonInteractive(selector: Any, txId: String, input: ExecutionServiceInput, timeOutMill: Long):
+ ExecutionServiceOutput {
var output: ExecutionServiceOutput? = null
val flow = openSubscription(selector, txId)
/** Send the request */
val sendChannel = commChannels[txId]?.requestChannel
- ?: throw BluePrintException("failed to get transactionId($txId) send channel")
+ ?: throw BluePrintException("failed to get transactionId($txId) send channel")
sendChannel.send(input)
/** Receive the response with timeout */
@@ -145,7 +150,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
if (!it.requestChannel.isClosedForSend)
it.requestChannel.close()
/** If receive channel has to close immediately, once the subscription has cancelled, then enable this */
- //it.responseChannel.cancel(CancellationException("subscription cancelled"))
+ // it.responseChannel.cancel(CancellationException("subscription cancelled"))
commChannels.remove(txId)
log.info("closed subscription for transactionId($txId)")
}
@@ -182,7 +187,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe
suspend fun createGrpcChannel(grpcProperties: GrpcClientProperties): ManagedChannel {
val grpcClientService: BluePrintGrpcClientService = bluePrintGrpcLibPropertyService
- .blueprintGrpcClientService(grpcProperties)
+ .blueprintGrpcClientService(grpcProperties)
return grpcClientService.channel()
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index 814054804..dd4c0ec99 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -32,13 +32,19 @@ import org.springframework.stereotype.Service
import java.io.File
@Service
-class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
- private val applicationContext: ApplicationContext) {
+class BlueprintJythonService(
+ val pythonExecutorProperty: PythonExecutorProperty,
+ private val applicationContext: ApplicationContext
+) {
val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java)
- inline fun <reified T> jythonInstance(blueprintContext: BluePrintContext, pythonClassName: String, content: String,
- dependencyInstanceNames: MutableMap<String, Any>?): T {
+ inline fun <reified T> jythonInstance(
+ blueprintContext: BluePrintContext,
+ pythonClassName: String,
+ content: String,
+ dependencyInstanceNames: MutableMap<String, Any>?
+ ): T {
val blueprintBasePath: String = blueprintContext.rootPath
val pythonPath: MutableList<String> = arrayListOf()
@@ -59,8 +65,8 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
BlueprintFunctionNode<*, *> {
val pythonFileName = bluePrintContext.rootPath
- .plus(File.separator)
- .plus(scriptClassReference)
+ .plus(File.separator)
+ .plus(scriptClassReference)
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
log.info("Getting Jython Script Class($pythonClassName)")
@@ -70,8 +76,10 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val jythonInstances: MutableMap<String, Any> = hashMapOf()
jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
- return jythonInstance<BlueprintFunctionNode<*, *>>(bluePrintContext, pythonClassName,
- content, jythonInstances)
+ return jythonInstance<BlueprintFunctionNode<*, *>>(
+ bluePrintContext, pythonClassName,
+ content, jythonInstances
+ )
}
fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
@@ -82,25 +90,27 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs
val operationAssignment: OperationAssignment = bluePrintContext
- .nodeTemplateInterfaceOperation(abstractComponentFunction.nodeTemplateName,
- abstractComponentFunction.interfaceName, abstractComponentFunction.operationName)
+ .nodeTemplateInterfaceOperation(
+ abstractComponentFunction.nodeTemplateName,
+ abstractComponentFunction.interfaceName, abstractComponentFunction.operationName
+ )
val blueprintBasePath: String = bluePrintContext.rootPath
val artifactName: String = operationAssignment.implementation?.primary
- ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
val pythonFileName = artifactDefinition.file
- ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+ ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
log.info("Getting Jython Script Class($pythonClassName)")
val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
- checkNotEmpty(content){ "artifact ($artifactName) content is empty"}
+ checkNotEmpty(content) { "artifact ($artifactName) content is empty" }
val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
pythonPath.add(blueprintBasePath)
@@ -110,17 +120,17 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
- ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+ ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
instanceDependenciesNode.forEach { instanceName ->
jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
}
- val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName,
- content!!, jythonInstances)
+ val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(
+ bluePrintContext, pythonClassName,
+ content!!, jythonInstances
+ )
return scriptComponentFunction
-
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
index 78b7556f3..b348a9bef 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
@@ -19,7 +19,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.python.core.PyObject
import org.python.util.PythonInterpreter
-open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
+open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython) {
private val blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
init {
@@ -42,9 +42,9 @@ open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){
try {
return blueprintPythonInterpreterProxy.getPythonInstance(properties)
} catch (e: Exception) {
- throw BluePrintProcessorException("Failed to execute Jython component ${e.toString()}", e)
+ throw BluePrintProcessorException("Failed to execute Jython component $e", e)
}
}
- //TODO Check potential errors in python scripts
+ // TODO Check potential errors in python scripts
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
index 6e514de49..6f311bcd2 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
@@ -33,12 +33,13 @@ open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrin
try {
this.exec(bluePrintPython.content)
} catch (e: PySyntaxError) {
- throw BluePrintProcessorException("Error executing Jython code! Python error: '${e.toString()}'", e)
+ throw BluePrintProcessorException("Error executing Jython code! Python error: '$e'", e)
}
}
val initCommand = bluePrintPython.pythonClassName.plus(" = ").plus(
- bluePrintPython.pythonClassName).plus("()")
+ bluePrintPython.pythonClassName
+ ).plus("()")
this.exec(initCommand)
return this.get(bluePrintPython.pythonClassName)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
index 658b0c291..0a220948d 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
@@ -32,6 +32,7 @@ open class PythonExecutorConfiguration
@Configuration
open class PythonExecutorProperty {
+
@Value("\${blueprints.processor.functions.python.executor.executionPath}")
lateinit var executionPath: String
@Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
@@ -44,8 +45,12 @@ class PythonExecutorConstants {
}
}
-open class BluePrintPython(executablePath: String, blueprintPythonPlatform: MutableList<String>,
- val argv: MutableList<String>){
+open class BluePrintPython(
+ executablePath: String,
+ blueprintPythonPlatform: MutableList<String>,
+ val argv: MutableList<String>
+) {
+
lateinit var moduleName: String
lateinit var pythonClassName: String
lateinit var content: String
@@ -65,4 +70,4 @@ open class BluePrintPython(executablePath: String, blueprintPythonPlatform: Muta
props.setProperty("python.verbose", "error")
props.setProperty("python.executable", executablePath)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
index 6bffffdb5..a0eaeca5f 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt
@@ -31,15 +31,16 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOu
private val log = logger(MockBluePrintProcessingServer::class)
-
class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
override fun process(responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
- log.info("Received requestId(${executionServiceInput.commonHeader.requestId}) " +
- "subRequestId(${executionServiceInput.commonHeader.subRequestId})")
+ log.info(
+ "Received requestId(${executionServiceInput.commonHeader.requestId}) " +
+ "subRequestId(${executionServiceInput.commonHeader.subRequestId})"
+ )
runBlocking {
launch(MDCContext()) {
responseObserver.onNext(buildNotification(executionServiceInput))
@@ -52,9 +53,11 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
- responseObserver.onError(io.grpc.Status.INTERNAL
+ responseObserver.onError(
+ io.grpc.Status.INTERNAL
.withDescription(error.message)
- .asException())
+ .asException()
+ )
}
override fun onCompleted() {
@@ -63,29 +66,27 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
}
}
-
private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput {
val status = Status.newBuilder()
- .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION)
- .build()
+ .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION)
+ .build()
return ExecutionServiceOutput.newBuilder()
- .setCommonHeader(input.commonHeader)
- .setActionIdentifiers(input.actionIdentifiers)
- .setStatus(status)
- .build()
+ .setCommonHeader(input.commonHeader)
+ .setActionIdentifiers(input.actionIdentifiers)
+ .setStatus(status)
+ .build()
}
private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput {
val status = Status.newBuilder().setCode(200)
- .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
- .build()
+ .setEventType(EventType.EVENT_COMPONENT_EXECUTED)
+ .build()
return ExecutionServiceOutput.newBuilder()
- .setCommonHeader(input.commonHeader)
- .setActionIdentifiers(input.actionIdentifiers)
- .setStatus(status)
- .build()
-
+ .setCommonHeader(input.commonHeader)
+ .setActionIdentifiers(input.actionIdentifiers)
+ .setStatus(status)
+ .build()
}
}
@@ -93,15 +94,14 @@ class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintPr
fun main() {
try {
val server = ServerBuilder
- .forPort(50052)
- .intercept(GrpcServerLoggingInterceptor())
- .addService(MockBluePrintProcessingServer())
- .build()
+ .forPort(50052)
+ .intercept(GrpcServerLoggingInterceptor())
+ .addService(MockBluePrintProcessingServer())
+ .build()
server.start()
log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...")
server.awaitTermination()
} catch (e: Exception) {
e.printStackTrace()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
index 9a5be0151..dede885c1 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/StreamingRemoteExecutionServiceTest.kt
@@ -23,8 +23,13 @@ import io.grpc.testing.GrpcCleanupRule
import io.mockk.coEvery
import io.mockk.mockk
import io.mockk.spyk
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC
@@ -37,11 +42,10 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
-import java.util.*
+import java.util.UUID
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-
class StreamingRemoteExecutionServiceTest {
val log = logger(StreamingRemoteExecutionServiceTest::class)
@@ -82,16 +86,21 @@ class StreamingRemoteExecutionServiceTest {
val request = getRequest(requestId)
val invocationId = request.commonHeader.subRequestId
val deferred = async {
- val response = spyStreamingRemoteExecutionService.sendNonInteractive(tokenAuthGrpcClientProperties,
- invocationId, request, 1000L)
+ val response = spyStreamingRemoteExecutionService.sendNonInteractive(
+ tokenAuthGrpcClientProperties,
+ invocationId, request, 1000L
+ )
assertNotNull(response, "failed to get non interactive response")
- assertEquals(response.commonHeader.requestId, requestId,
- "failed to match non interactive response id")
- assertEquals(response.status.eventType, EventType.EVENT_COMPONENT_EXECUTED,
- "failed to match non interactive response type")
+ assertEquals(
+ response.commonHeader.requestId, requestId,
+ "failed to match non interactive response id"
+ )
+ assertEquals(
+ response.status.eventType, EventType.EVENT_COMPONENT_EXECUTED,
+ "failed to match non interactive response type"
+ )
}
nonInteractiveDeferred.add(deferred)
-
}
nonInteractiveDeferred.awaitAll()
@@ -102,7 +111,7 @@ class StreamingRemoteExecutionServiceTest {
val request = getRequest(requestId)
val invocationId = request.commonHeader.requestId
val responseFlow = spyStreamingRemoteExecutionService
- .openSubscription(tokenAuthGrpcClientProperties, invocationId)
+ .openSubscription(tokenAuthGrpcClientProperties, invocationId)
val deferred = async {
responseFlow.collect {
@@ -119,33 +128,30 @@ class StreamingRemoteExecutionServiceTest {
responseFlowsDeferred.awaitAll()
streamingRemoteExecutionService.closeChannel(tokenAuthGrpcClientProperties)
}
-
}
private fun getRequest(requestId: String): ExecutionServiceInput {
val commonHeader = CommonHeader.newBuilder()
- .setTimestamp("2012-04-23T18:25:43.511Z")
- .setOriginatorId("System")
- .setRequestId(requestId)
- .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
-
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId(requestId)
+ .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build()
val actionIdentifier = ActionIdentifiers.newBuilder()
- .setActionName("SampleScript")
- .setBlueprintName("sample-cba")
- .setBlueprintVersion("1.0.0")
- .setMode(ACTION_MODE_SYNC)
- .build()
+ .setActionName("SampleScript")
+ .setBlueprintName("sample-cba")
+ .setBlueprintVersion("1.0.0")
+ .setMode(ACTION_MODE_SYNC)
+ .build()
val jsonContent = """{ "key1" : "value1" }"""
val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
JsonFormat.parser().merge(jsonContent, payloadBuilder)
return ExecutionServiceInput.newBuilder()
- .setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifier)
- .setPayload(payloadBuilder.build())
- .build()
-
+ .setCommonHeader(commonHeader)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
}
-} \ No newline at end of file
+}
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 2fc9a993b..d6720427e 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
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts;
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
@@ -54,9 +54,11 @@ import kotlin.test.assertNotNull
* Unit test cases for abstract component function.
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ComponentFunctionScriptingService::class,
- BluePrintScriptsServiceImpl::class, PythonExecutorProperty::class,
- BlueprintJythonService::class])
+@ContextConfiguration(
+ classes = [ComponentFunctionScriptingService::class,
+ BluePrintScriptsServiceImpl::class, PythonExecutorProperty::class,
+ BlueprintJythonService::class]
+)
class AbstractComponentFunctionTest {
lateinit var blueprintContext: BluePrintContext
@@ -97,7 +99,8 @@ class AbstractComponentFunctionTest {
val sampleComponent = SampleComponent()
sampleComponent.workflowName = "sample-action"
sampleComponent.executionServiceInput = JacksonUtils.readValueFromClassPathFile(
- "payload/requests/sample-execution-request.json", ExecutionServiceInput::class.java)!!
+ "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()
@@ -153,14 +156,13 @@ class AbstractComponentFunctionTest {
val operationInputs = hashMapOf<String, JsonNode>()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] =
- "activate-restconf".asJsonPrimitive()
+ "activate-restconf".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] =
- "interfaceName".asJsonPrimitive()
+ "interfaceName".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] =
- "operationName".asJsonPrimitive()
+ "operationName".asJsonPrimitive()
operationInputs["dynamic-properties"] = rootNode
-
val stepInputData = StepData().apply {
name = "activate-restconf"
properties = operationInputs
@@ -178,13 +180,15 @@ class AbstractComponentFunctionTest {
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs(
- "activate-restconf", "interfaceName", "operationName")
+ "activate-restconf", "interfaceName", "operationName"
+ )
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs(
- "activate-restconf", "interfaceName", "operationName")
+ "activate-restconf", "interfaceName", "operationName"
+ )
} returns operationOutputs
every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
@@ -196,6 +200,4 @@ 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/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
index fd18baf52..a34794a85 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
@@ -33,9 +33,11 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"]
+)
class BlueprintJythonServiceTest {
lateinit var blueprintContext: BluePrintContext
@@ -47,26 +49,27 @@ class BlueprintJythonServiceTest {
blueprintContext = mockk<BluePrintContext>()
every { blueprintContext.rootPath } returns normalizedPathName("target")
}
-
+
@Test
fun testGetAbstractPythonPlugin() {
- val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
- val dependencies: MutableMap<String, Any> = hashMapOf()
+ val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
+ val dependencies: MutableMap<String, Any> = hashMapOf()
- val abstractPythonPlugin = blueprintJythonService
- .jythonInstance<AbstractComponentFunction>(blueprintContext, "SamplePythonComponentNode",
- content, dependencies)
+ val abstractPythonPlugin = blueprintJythonService
+ .jythonInstance<AbstractComponentFunction>(
+ blueprintContext, "SamplePythonComponentNode",
+ content, dependencies
+ )
- assertNotNull(abstractPythonPlugin, "failed to get python component")
+ assertNotNull(abstractPythonPlugin, "failed to get python component")
}
@Test
fun testGetAbstractJythonComponent() {
- val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
-
- val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+ val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
- assertNotNull(abstractJythonComponent, "failed to get Jython component")
+ val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+ assertNotNull(abstractJythonComponent, "failed to get Jython component")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
index 3c3efa252..9a93abe0c 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
@@ -16,21 +16,22 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import org.junit.Test
-
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.assertNotNull
import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
+@TestPropertySource(
+ properties =
+ ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"]
+)
class BlueprintPythonHostTest {
lateinit var blueprintPythonHost: BlueprintPythonHost
@@ -59,4 +60,4 @@ class BlueprintPythonHostTest {
assertNotNull(pythonObject, "failed to get python object")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
index 000d8c09b..31b1a59c8 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleComponent.kt
@@ -18,21 +18,18 @@
* ============LICENSE_END=========================================================
*/
-
package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-
import org.slf4j.LoggerFactory
open class SampleComponent : AbstractComponentFunction() {
val log = LoggerFactory.getLogger(SampleComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
}
@@ -40,20 +37,21 @@ open class SampleComponent : AbstractComponentFunction() {
}
}
-open class SampleRestconfComponent (private var componentFunctionScriptingService: ComponentFunctionScriptingService)
- : AbstractComponentFunction() {
+open class SampleRestconfComponent(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
+ AbstractComponentFunction() {
val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
var scriptComponent: AbstractScriptComponentFunction
scriptComponent = componentFunctionScriptingService
- .scriptInstance<AbstractScriptComponentFunction>(this,
- "internal",
- "org.onap.ccsdk.cds.blueprintsprocessor.services" +
- ".execution.scripts.SampleTest",
- mutableListOf())
+ .scriptInstance<AbstractScriptComponentFunction>(
+ this,
+ "internal",
+ "org.onap.ccsdk.cds.blueprintsprocessor.services" +
+ ".execution.scripts.SampleTest",
+ mutableListOf()
+ )
scriptComponent.executeScript(executionServiceInput)
}
@@ -65,11 +63,9 @@ open class SampleScriptComponent : AbstractScriptComponentFunction() {
val log = LoggerFactory.getLogger(SampleScriptComponent::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
index 6a95e29e7..b10f08dd4 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/SampleTest.kt
@@ -29,7 +29,6 @@ open class SampleTest : AbstractScriptComponentFunction() {
val log = LoggerFactory.getLogger(SampleTest::class.java)!!
-
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val isPresent = checkDynamicProperties("type")
assertTrue(isPresent)
@@ -39,4 +38,4 @@ open class SampleTest : AbstractScriptComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
index cde919ce8..492b0ba44 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -29,23 +29,25 @@ import org.springframework.stereotype.Service
@Service("bluePrintWorkflowExecutionService")
open class BluePrintWorkflowExecutionServiceImpl(
- private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
- private val dgWorkflowExecutionService: DGWorkflowExecutionService,
- private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService
+ private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
+ private val dgWorkflowExecutionService: DGWorkflowExecutionService,
+ private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService
) : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!!
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val workflowName = executionServiceInput.actionIdentifiers.actionName
// Assign Workflow inputs
- //check if request structure exists
+ // check if request structure exists
if (!executionServiceInput.payload.has("$workflowName-request")) {
throw BluePrintProcessorException("Input request missing the expected '$workflowName-request' block!")
}
@@ -59,7 +61,7 @@ open class BluePrintWorkflowExecutionServiceImpl(
/** If workflow has multiple steps, then it is imperative workflow */
val executionServiceOutput: ExecutionServiceOutput = if (steps.size > 1) {
imperativeWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
} else {
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
@@ -71,15 +73,17 @@ open class BluePrintWorkflowExecutionServiceImpl(
when {
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
componentWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> {
dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
}
else -> {
- throw BluePrintProcessorException("couldn't execute workflow($workflowName) step mapped " +
- "to node template($nodeTemplateName) derived from($derivedFrom)")
+ throw BluePrintProcessorException(
+ "couldn't execute workflow($workflowName) step mapped " +
+ "to node template($nodeTemplateName) derived from($derivedFrom)"
+ )
}
}
}
@@ -93,5 +97,4 @@ open class BluePrintWorkflowExecutionServiceImpl(
executionServiceOutput.payload.set("$workflowName-response", workflowOutputs.asObjectNode())
return executionServiceOutput
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
index a2db8aab7..044e8cf53 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
@@ -48,5 +48,4 @@ class BlueprintSvcLogicContext : SvcLogicContext() {
fun getResponse(): Any {
return this.response!!
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
index df250ae98..9cc325d94 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
@@ -18,14 +18,25 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.sli.core.sli.*
-import org.onap.ccsdk.sli.core.sli.provider.base.*
+import org.onap.ccsdk.sli.core.sli.ExitNodeException
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext
+import org.onap.ccsdk.sli.core.sli.SvcLogicException
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore
+import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.BreakNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ExitNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.Properties
import javax.annotation.PostConstruct
interface BlueprintSvcLogicService : SvcLogicServiceBase {
@@ -54,7 +65,6 @@ interface BlueprintSvcLogicService : SvcLogicServiceBase {
}
}
-
@Service
class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
@@ -88,9 +98,12 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
}
}
- override suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- input: Any): Any {
- //Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
+ override suspend fun execute(
+ graph: SvcLogicGraph,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: Any
+ ): Any {
+ // Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
val blueprintSvcLogicContext = BlueprintSvcLogicContext()
blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
blueprintSvcLogicContext.setRequest(input)
@@ -140,4 +153,4 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
MDC.remove("currentGraph")
return svcLogicContext
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
index 3c474de37..70910e15c 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
-
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
@@ -24,12 +23,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.springframework.stereotype.Service
@Service("componentWorkflowExecutionService")
-open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -38,8 +39,9 @@ open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionSe
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
- return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
- nodeTemplateName, executionServiceInput)
+ return nodeTemplateExecutionService.executeNodeTemplate(
+ bluePrintRuntimeService,
+ nodeTemplateName, executionServiceInput
+ )
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
index 4485800ff..b1847df43 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -26,16 +26,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
-
@Service("dgWorkflowExecutionService")
-open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(DGWorkflowExecutionService::class.java)
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -47,8 +48,10 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)")
// Get the DG file info
- val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
- WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
+ val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(
+ nodeTemplateName,
+ WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH
+ )
// Populate the DG Path
val dgFilePath = normalizedPathName(bluePrintContext.rootPath, artifactDefinition.file)
@@ -59,10 +62,10 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
// Execute the DG
- return blueprintSvcLogicService.execute(graph,
+ return blueprintSvcLogicService.execute(
+ graph,
bluePrintRuntimeService,
- executionServiceInput) as ExecutionServiceOutput
-
+ executionServiceInput
+ ) as ExecutionServiceOutput
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
index d296ec6e6..ebd9d553d 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt
@@ -21,23 +21,35 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asGraph
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel
import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.*
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.AbstractBluePrintWorkFlowService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintWorkFlowService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeExecuteMessage
+import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeSkipMessage
+import org.onap.ccsdk.cds.controllerblueprints.core.service.WorkflowExecuteMessage
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@Service("imperativeWorkflowExecutionService")
class ImperativeWorkflowExecutionService(
- private val imperativeBluePrintWorkflowService: BluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>)
- : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+ private val imperativeBluePrintWorkflowService: BluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>
+) :
+ BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
- override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput,
- properties: MutableMap<String, Any>): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>
+ ): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -45,23 +57,29 @@ class ImperativeWorkflowExecutionService(
val graph = bluePrintContext.workflowByName(workflowName).asGraph()
- return imperativeBluePrintWorkflowService.executeWorkflow(graph, bluePrintRuntimeService,
- executionServiceInput)
+ return imperativeBluePrintWorkflowService.executeWorkflow(
+ graph, bluePrintRuntimeService,
+ executionServiceInput
+ )
}
}
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : AbstractBluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>() {
+open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ AbstractBluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>() {
+
val log = logger(ImperativeBluePrintWorkflowService::class)
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var executionServiceInput: ExecutionServiceInput
lateinit var workflowName: String
- override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- input: ExecutionServiceInput): ExecutionServiceOutput {
+ override suspend fun executeWorkflow(
+ graph: Graph,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: ExecutionServiceInput
+ ): ExecutionServiceOutput {
this.graph = graph
this.bluePrintRuntimeService = bluePrintRuntimeService
this.executionServiceInput = input
@@ -103,8 +121,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
}
}
- override suspend fun prepareNodeExecutionMessage(node: Graph.Node)
- : NodeExecuteMessage<ExecutionServiceInput, ExecutionServiceOutput> {
+ override suspend fun prepareNodeExecutionMessage(node: Graph.Node):
+ NodeExecuteMessage<ExecutionServiceInput, ExecutionServiceOutput> {
val nodeOutput = ExecutionServiceOutput().apply {
commonHeader = executionServiceInput.commonHeader
actionIdentifiers = executionServiceInput.actionIdentifiers
@@ -112,8 +130,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
return NodeExecuteMessage(node, executionServiceInput, nodeOutput)
}
- override suspend fun prepareNodeSkipMessage(node: Graph.Node)
- : NodeSkipMessage<ExecutionServiceInput, ExecutionServiceOutput> {
+ override suspend fun prepareNodeSkipMessage(node: Graph.Node):
+ NodeSkipMessage<ExecutionServiceInput, ExecutionServiceOutput> {
val nodeOutput = ExecutionServiceOutput().apply {
commonHeader = executionServiceInput.commonHeader
actionIdentifiers = executionServiceInput.actionIdentifiers
@@ -121,15 +139,18 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
return NodeSkipMessage(node, executionServiceInput, nodeOutput)
}
- override suspend fun executeNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun executeNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
log.info("Executing workflow($workflowName[${this.workflowId}])'s step($${node.id})")
val step = bluePrintRuntimeService.bluePrintContext().workflowStepByName(this.workflowName, node.id)
checkNotEmpty(step.target) { "couldn't get step target for workflow(${this.workflowName})'s step(${node.id})" }
val nodeTemplateName = step.target!!
/** execute node template */
val executionServiceOutput = nodeTemplateExecutionService
- .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput)
+ .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput)
return when (executionServiceOutput.status.message) {
BluePrintConstants.STATUS_FAILURE -> EdgeLabel.FAILURE
@@ -137,18 +158,27 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS
}
}
- override suspend fun skipNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun skipNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
return EdgeLabel.SUCCESS
}
- override suspend fun cancelNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun cancelNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
TODO("not implemented")
}
- override suspend fun restartNode(node: Graph.Node, nodeInput: ExecutionServiceInput,
- nodeOutput: ExecutionServiceOutput): EdgeLabel {
+ override suspend fun restartNode(
+ node: Graph.Node,
+ nodeInput: ExecutionServiceInput,
+ nodeOutput: ExecutionServiceOutput
+ ): EdgeLabel {
TODO("not implemented")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
index b64177aab..615a31c77 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -33,8 +33,11 @@ open class NodeTemplateExecutionService {
private val log = LoggerFactory.getLogger(NodeTemplateExecutionService::class.java)!!
- suspend fun executeNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ suspend fun executeNodeTemplate(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ executionServiceInput: ExecutionServiceInput
+ ): ExecutionServiceOutput {
// Get the Blueprint Context
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
@@ -47,12 +50,14 @@ open class NodeTemplateExecutionService {
val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
val nodeTemplateImplementation = blueprintContext
- .nodeTemplateOperationImplementation(nodeTemplateName, interfaceName, operationName)
+ .nodeTemplateOperationImplementation(nodeTemplateName, interfaceName, operationName)
val timeout: Int = nodeTemplateImplementation?.timeout ?: 180
- log.info("executing node template($nodeTemplateName) component($componentName) " +
- "interface($interfaceName) operation($operationName) with timeout($timeout) sec.")
+ log.info(
+ "executing node template($nodeTemplateName) component($componentName) " +
+ "interface($interfaceName) operation($operationName) with timeout($timeout) sec."
+ )
// Get the Component Instance
val plugin = BluePrintDependencyService.instance<AbstractComponentFunction>(componentName)
@@ -82,5 +87,4 @@ open class NodeTemplateExecutionService {
// Get the Request from the Context and Set to the Function Input and Invoke the function
return plugin.applyNB(clonedExecutionServiceInput)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
index 67f13f760..c1bcc649f 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
@@ -23,9 +23,8 @@ import org.springframework.context.annotation.Configuration
@ComponentScan
open class WorkflowServiceConfiguration
-
class WorkflowServiceConstants {
companion object {
const val ARTIFACT_TYPE_DIRECTED_GRAPH = "artifact-directed-graph"
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index b6e767503..8c4e2d215 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -31,14 +31,14 @@ import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@Service
-open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
- : ExecuteNodeExecutor() {
+open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService) :
+ ExecuteNodeExecutor() {
private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
@Throws(SvcLogicException::class)
- override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext)
- : SvcLogicNode = runBlocking {
+ override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext):
+ SvcLogicNode = runBlocking {
var outValue: String
@@ -48,15 +48,16 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService
val executionInput = ctx.getRequest() as ExecutionServiceInput
- try { // Get the Request from the Context and Set to the Function Input and Invoke the function
- val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(ctx.getBluePrintService(),
- nodeTemplateName, executionInput)
+ try { // Get the Request from the Context and Set to the Function Input and Invoke the function
+ val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(
+ ctx.getBluePrintService(),
+ nodeTemplateName, executionInput
+ )
ctx.setResponse(executionOutput)
outValue = executionOutput.status.message
ctx.status = executionOutput.status.message
-
} catch (e: Exception) {
log.error("Could not execute plugin($nodeTemplateName) : ", e)
outValue = "failure"
@@ -65,5 +66,4 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService
getNextNode(node, outValue)
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
index 8f9579230..86934f29a 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
@@ -32,4 +32,4 @@ object SvcGraphUtils {
val svcLogicParser = SvcLogicParser()
return svcLogicParser.parse(fileName).first
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
index 436de1b56..330056221 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -40,7 +40,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
class BluePrintWorkflowExecutionServiceImplTest {
@@ -62,36 +61,48 @@ class BluePrintWorkflowExecutionServiceImplTest {
@Test
fun testBluePrintWorkflowExecutionService() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
@Test
fun testImperativeBluePrintWorkflowExecutionService() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/imperative-test-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/imperative-test-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
@@ -99,16 +110,20 @@ class BluePrintWorkflowExecutionServiceImplTest {
fun `Blueprint fails on missing workflowName-parameters with a useful message`() {
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- //service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input-missing-resource_assignment_request.json",
- ExecutionServiceInput::class.java)!!
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
+ // service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
+ val executionServiceInput =
+ JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input-missing-resource_assignment_request.json",
+ ExecutionServiceInput::class.java
+ )!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
}
}
}
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index 12fd9c7c4..3d44894ee 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -54,47 +54,51 @@ class BlueprintServiceLogicTest {
@Test
fun testExecuteGraphWithSingleComponent() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
val executionServiceOutput = dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
-
}
@Test
fun testExecuteGraphWithMultipleComponents() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("assign-activate-request")
bluePrintRuntimeService.assignWorkflowInputs("assign-activate", input)
-
val executionServiceOutput = dgWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
}
@Test
@@ -118,5 +122,4 @@ class BlueprintServiceLogicTest {
assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
}
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
index 3ac5cd864..86d3be26b 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
@@ -44,7 +44,6 @@ class DGWorkflowExecutionServiceTest {
@Autowired
lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
-
@Before
fun init() {
BluePrintDependencyService.inject(applicationContext)
@@ -54,25 +53,28 @@ class DGWorkflowExecutionServiceTest {
fun testExecuteDirectedGraph() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput = JacksonReactorUtils
- .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
- val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService,
- executionServiceInput, mutableMapOf())
+ val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(
+ bluePrintRuntimeService,
+ executionServiceInput, mutableMapOf()
+ )
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
-
}
-
-
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
index b7fcae1d1..415f11d58 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
@@ -56,18 +56,36 @@ class ImperativeWorkflowExecutionServiceTest {
}
fun mockServiceTemplate(): ServiceTemplate {
- return serviceTemplate("imperative-test", "1.0.0",
- "brindasanth@onap.com", "tosca") {
+ return serviceTemplate(
+ "imperative-test", "1.0.0",
+ "brindasanth@onap.com", "tosca"
+ ) {
topologyTemplate {
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("resolve-config",
- "cba.wt.imperative.test.ResolveConfig"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config",
- "cba.wt.imperative.test.ActivateConfig"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config-rollback",
- "cba.wt.imperative.test.ActivateConfigRollback"))
- nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-licence",
- "cba.wt.imperative.test.ActivateLicence"))
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "resolve-config",
+ "cba.wt.imperative.test.ResolveConfig"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-config",
+ "cba.wt.imperative.test.ActivateConfig"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-config-rollback",
+ "cba.wt.imperative.test.ActivateConfigRollback"
+ )
+ )
+ nodeTemplate(
+ mockNodeTemplateComponentScriptExecutor(
+ "activate-licence",
+ "cba.wt.imperative.test.ActivateLicence"
+ )
+ )
workflow("imperative-test-wf", "Test Imperative flow") {
step("resolve-config", "resolve-config", "") {
@@ -95,17 +113,19 @@ class ImperativeWorkflowExecutionServiceTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("12345", bluePrintContext)
val executionServiceInput = JacksonUtils
- .readValueFromClassPathFile("execution-input/imperative-test-input.json",
- ExecutionServiceInput::class.java)!!
+ .readValueFromClassPathFile(
+ "execution-input/imperative-test-input.json",
+ ExecutionServiceInput::class.java
+ )!!
val bluePrintWorkFlowService = ImperativeBluePrintWorkflowService(NodeTemplateExecutionService())
val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(bluePrintWorkFlowService)
val output = imperativeWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(output, "failed to get imperative workflow output")
assertNotNull(output.status, "failed to get imperative workflow output status")
assertEquals(output.status.message, BluePrintConstants.STATUS_SUCCESS)
assertEquals(output.status.eventType, EventType.EVENT_COMPONENT_EXECUTED.name)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
index 24d96629e..1f51a6aae 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
@@ -38,6 +38,7 @@ import kotlin.test.assertNotNull
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
class NodeTemplateExecutionServiceTest {
+
@Before
fun init() {
mockkObject(BluePrintDependencyService)
@@ -52,11 +53,15 @@ class NodeTemplateExecutionServiceTest {
@Test
fun testExecuteNodeTemplate() {
runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile(
+ "execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java
+ )!!
// Assign Workflow inputs Mock
val input = executionServiceInput.payload.get("resource-assignment-request")
@@ -65,11 +70,13 @@ class NodeTemplateExecutionServiceTest {
val nodeTemplate = "resource-assignment"
val nodeTemplateExecutionService = NodeTemplateExecutionService()
val executionServiceOutput = nodeTemplateExecutionService
- .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput)
+ .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput)
assertNotNull(executionServiceOutput, "failed to get response")
- assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ assertEquals(
+ BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response"
+ )
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
index 44751b5b5..9c3727288 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
@@ -29,8 +29,10 @@ import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
-fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor(id,
- "mock($id) component function") {
+fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id,
+ "mock($id) component function"
+) {
definedOperation("") {
inputs {
type("kotlin")
@@ -55,8 +57,10 @@ class MockComponentFunction : AbstractComponentFunction() {
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
log.info("Processing component : $operationInputs")
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- "assignment-params", "params".asJsonPrimitive())
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive()
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
@@ -92,4 +96,4 @@ class PrototypeComponentFunction : AbstractComponentFunction() {
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
log.info("Recovering component..")
}
-} \ No newline at end of file
+}