From daab14bd058de198c80b71d63e108fd788b7f5ee Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Mon, 26 Jul 2021 12:00:59 -0400 Subject: Revert "Renaming Files having BluePrint to have Blueprint" The renaming in CCSDK-3098 caused breaking changes to the grpc api and compile issues for kotlin scripts. Issue-ID: CCSDK-3385 Change-Id: I0d745cb858371678eabcb2284671c1fd76a1ab6d Signed-off-by: Jozsef Csongvai --- .../execution/AbstractComponentFunction.kt | 38 ++--- .../execution/AbstractScriptComponentFunction.kt | 26 +-- .../services/execution/AbstractServiceFunction.kt | 4 +- .../execution/ComponentFunctionScriptingService.kt | 24 +-- .../execution/ComponentRemoteScriptExecutor.kt | 12 +- .../execution/ComponentRemoteScriptExecutorDSL.kt | 34 ++-- .../execution/ComponentScriptExecutorDSL.kt | 38 ++--- .../execution/RemoteScriptExecutionService.kt | 8 +- .../execution/StreamingRemoteExecutionService.kt | 22 +-- .../execution/scripts/BlueprintJythonService.kt | 10 +- .../execution/ComponentRemoteScriptExecutorTest.kt | 24 +-- .../execution/MockBluePrintProcessingServer.kt | 107 ++++++++++++ .../execution/MockBlueprintProcessingServer.kt | 107 ------------ .../StreamingRemoteExecutionServiceTest.kt | 8 +- .../scripts/AbstractComponentFunctionTest.kt | 34 ++-- .../BluePrintWorkflowExecutionServiceImpl.kt | 111 +++++++++++++ .../services/workflow/BlueprintSvcLogicContext.kt | 8 +- .../services/workflow/BlueprintSvcLogicService.kt | 8 +- .../BlueprintWorkflowExecutionServiceImpl.kt | 111 ------------- .../workflow/ComponentWorkflowExecutionService.kt | 10 +- .../workflow/DGWorkflowExecutionService.kt | 10 +- .../workflow/ImperativeWorkflowExecutionService.kt | 44 ++--- .../workflow/NodeTemplateExecutionService.kt | 20 +-- .../executor/ComponentExecuteNodeExecutor.kt | 2 +- .../BluePrintWorkflowExecutionServiceImplTest.kt | 185 +++++++++++++++++++++ .../services/workflow/BlueprintServiceLogicTest.kt | 24 +-- .../BlueprintWorkflowExecutionServiceImplTest.kt | 185 --------------------- .../workflow/DGWorkflowExecutionServiceTest.kt | 18 +- .../ImperativeWorkflowExecutionServiceTest.kt | 24 +-- .../workflow/NodeTemplateExecutionServiceTest.kt | 18 +- .../workflow/mock/MockComponentFunction.kt | 4 +- 31 files changed, 639 insertions(+), 639 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt delete mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt delete mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintWorkflowExecutionServiceImpl.kt create mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt delete mode 100644 ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintWorkflowExecutionServiceImplTest.kt (limited to 'ms/blueprintsprocessor/modules/services') 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 f85b6424d..2186d470b 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 @@ -24,11 +24,11 @@ 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.blueprintsprocessor.core.cluster.executeWithLock -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.core.service.CDS_LOCK_GROUP import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.checkNotBlank import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty @@ -38,8 +38,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunction 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.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService import org.slf4j.LoggerFactory /** @@ -53,8 +53,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode - lateinit var bluePrintClusterService: BlueprintClusterService + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintClusterService: BluePrintClusterService lateinit var implementation: Implementation lateinit var processId: String lateinit var workflowName: String @@ -88,13 +88,13 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode { 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 3cb46ed44..8b46ae693 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 @@ -19,9 +19,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode 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.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.slf4j.LoggerFactory abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { @@ -47,7 +47,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { @Deprecated("Dependencies will be resolved dynamically") open fun 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 { @@ -60,7 +60,7 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { suspend fun executeScript(executionServiceInput: ExecutionServiceInput) { return when (scriptType) { - BlueprintConstants.SCRIPT_JYTHON -> { + BluePrintConstants.SCRIPT_JYTHON -> { executeScriptBlocking(executionServiceInput) } else -> { @@ -97,34 +97,34 @@ abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { */ final override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - throw BlueprintException("Not Implemented, use applyNB method") + throw BluePrintException("Not Implemented, use applyNB method") } final override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput { - throw BlueprintException("Not Implemented required") + throw BluePrintException("Not Implemented required") } final override fun prepareResponse(): ExecutionServiceOutput { - throw BlueprintException("Not Implemented required") + throw BluePrintException("Not Implemented required") } final override suspend fun applyNB(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - throw BlueprintException("Not Implemented required") + throw BluePrintException("Not Implemented required") } final override suspend fun prepareRequestNB(executionRequest: ExecutionServiceInput): ExecutionServiceInput { - throw BlueprintException("Not Implemented required") + throw BluePrintException("Not Implemented required") } final override suspend fun prepareResponseNB(): ExecutionServiceOutput { - throw BlueprintException("Not Implemented required") + throw BluePrintException("Not Implemented required") } override fun process(executionRequest: ExecutionServiceInput) { - throw BlueprintException("Not Implemented, child class will implement this") + throw BluePrintException("Not Implemented, child class will implement this") } override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - throw BlueprintException("Not Implemented, child class will implement this") + throw BluePrintException("Not Implemented, child class will implement this") } } 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 41e26e4ab..33f5d749f 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 @@ -21,7 +21,7 @@ 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.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse import org.onap.ccsdk.cds.controllerblueprints.core.logger @@ -79,7 +79,7 @@ abstract class AbstractServiceFunction : BlueprintFunctionNode> scriptInstance( - bluePrintContext: BlueprintContext, + bluePrintContext: BluePrintContext, scriptType: String, scriptClassReference: String ): T { var scriptComponent: T? = null when (scriptType) { - BlueprintConstants.SCRIPT_INTERNAL -> { - val bluePrintScriptsService: BlueprintScriptsService = BlueprintScriptsServiceImpl() + BluePrintConstants.SCRIPT_INTERNAL -> { + val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl() scriptComponent = bluePrintScriptsService.scriptInstance(scriptClassReference) } - BlueprintConstants.SCRIPT_KOTLIN -> { - val bluePrintScriptsService: BlueprintScriptsService = BlueprintScriptsServiceImpl() + BluePrintConstants.SCRIPT_KOTLIN -> { + val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl() scriptComponent = bluePrintScriptsService.scriptInstance( bluePrintContext.rootPath, bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false ) } - BlueprintConstants.SCRIPT_JYTHON -> { + BluePrintConstants.SCRIPT_JYTHON -> { scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T } else -> { - throw BlueprintProcessorException("script type($scriptType) is not supported") + throw BluePrintProcessorException("script type($scriptType) is not supported") } } return scriptComponent diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt index 5a552e32a..2581e5628 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutor.kt @@ -22,8 +22,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createActionIdentifiersProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createCommonHeaderProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createExecutionServiceInputProto -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope @@ -70,7 +70,7 @@ open class ComponentRemoteScriptExecutor( val txId = UUID.randomUUID().toString() val commonHeader = createCommonHeaderProto( executionRequest.commonHeader.subRequestId, - txId, BlueprintConstants.APP_NAME + txId, BluePrintConstants.APP_NAME ) val actionIdentifier = createActionIdentifiersProto(blueprintName, blueprintVersion, blueprintAction) @@ -92,11 +92,11 @@ open class ComponentRemoteScriptExecutor( /** set node template attribute */ val statusMessage = executionServiceOutputProto.status.message - if (statusMessage == BlueprintConstants.STATUS_SUCCESS) { - setAttribute(ATTRIBUTE_STATUS, BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive()) + if (statusMessage == BluePrintConstants.STATUS_SUCCESS) { + setAttribute(ATTRIBUTE_STATUS, BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive()) } else { val errorMessage = executionServiceOutputProto.status.errorMessage ?: "failed in remote execution" - throw BlueprintProcessorException(errorMessage) + throw BluePrintProcessorException(errorMessage) } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt index 4263768b9..7bb071501 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate @@ -31,24 +31,24 @@ import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType /** Component Extensions **/ fun ServiceTemplateBuilder.nodeTypeComponentRemoteScriptExecutor() { - val nodeType = BlueprintTypes.nodeTypeComponentRemoteScriptExecutor() + val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BlueprintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { +fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { return nodeType( - id = "component-remote-script-executor", version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, + id = "component-remote-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER, + derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, description = "Generic Remote Script Component Executor" ) { /** Attribute definitions */ attribute( - ComponentRemoteScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BlueprintConstants.DATA_TYPE_JSON, false, + ComponentRemoteScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false, "Remote executed response data." ) attribute( - ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS, BlueprintConstants.DATA_TYPE_STRING, true, + ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true, "Remote execution status." ) @@ -56,35 +56,35 @@ fun BlueprintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType { operation("ComponentRemoteScriptExecutor", "ComponentRemoteScriptExecutor Operation") { inputs { property( - ComponentRemoteScriptExecutor.INPUT_SELECTOR, BlueprintConstants.DATA_TYPE_JSON, + ComponentRemoteScriptExecutor.INPUT_SELECTOR, BluePrintConstants.DATA_TYPE_JSON, true, "Remote GRPC selector or DSL reference or GRPC Json config." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME, BlueprintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME, BluePrintConstants.DATA_TYPE_STRING, true, "Blueprint name." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION, BlueprintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION, BluePrintConstants.DATA_TYPE_STRING, true, "Blueprint version." ) property( - ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION, BlueprintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION, BluePrintConstants.DATA_TYPE_STRING, true, "Blueprint action name." ) property( - ComponentRemoteScriptExecutor.INPUT_TIMEOUT, BlueprintConstants.DATA_TYPE_INTEGER, + ComponentRemoteScriptExecutor.INPUT_TIMEOUT, BluePrintConstants.DATA_TYPE_INTEGER, true, "Remote execution timeout in sec." ) { defaultValue(180) } property( - ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, BlueprintConstants.DATA_TYPE_JSON, + ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, BluePrintConstants.DATA_TYPE_JSON, false, "Dynamic Json Content or DSL Json reference." ) } outputs { property( - ComponentRemoteScriptExecutor.OUTPUT_STATUS, BlueprintConstants.DATA_TYPE_STRING, + ComponentRemoteScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING, true, "Status of the Component Execution ( success or failure )" ) } @@ -98,7 +98,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor( description: String, block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit ) { - val nodeTemplate = BlueprintTypes.nodeTemplateComponentRemoteScriptExecutor( + val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor( id, description, block ) @@ -106,7 +106,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor( nodeTemplates!![nodeTemplate.id!!] = nodeTemplate } -fun BlueprintTypes.nodeTemplateComponentRemoteScriptExecutor( +fun BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor( id: String, description: String, block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit 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 08a964b55..8592ce62b 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 @@ -17,8 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate @@ -32,53 +32,53 @@ import kotlin.reflect.KClass /** Component Extensions **/ fun ServiceTemplateBuilder.nodeTypeComponentScriptExecutor() { - val nodeType = BlueprintTypes.nodeTypeComponentScriptExecutor() + val nodeType = BluePrintTypes.nodeTypeComponentScriptExecutor() if (this.nodeTypes == null) this.nodeTypes = hashMapOf() this.nodeTypes!![nodeType.id!!] = nodeType } -fun BlueprintTypes.nodeTypeComponentScriptExecutor(): NodeType { +fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType { return nodeType( - id = "component-script-executor", version = BlueprintConstants.DEFAULT_VERSION_NUMBER, - derivedFrom = BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, + 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) + 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, + ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING, true, "Script Type" ) { - defaultValue(BlueprintConstants.SCRIPT_INTERNAL) + defaultValue(BluePrintConstants.SCRIPT_INTERNAL) constrain { validValues( listOf( - BlueprintConstants.SCRIPT_INTERNAL.asJsonPrimitive(), - BlueprintConstants.SCRIPT_JYTHON.asJsonPrimitive(), - BlueprintConstants.SCRIPT_KOTLIN.asJsonPrimitive() + BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(), + BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(), + BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive() ) ) } } property( - ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BlueprintConstants.DATA_TYPE_STRING, + 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, + 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, + ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false, "Output Response" ) property( - ComponentScriptExecutor.OUTPUT_STATUS, BlueprintConstants.DATA_TYPE_STRING, + ComponentScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING, true, "Status of the Component Execution ( success or failure )" ) } @@ -92,7 +92,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor( description: String, block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit ) { - val nodeTemplate = BlueprintTypes.nodeTemplateComponentScriptExecutor( + val nodeTemplate = BluePrintTypes.nodeTemplateComponentScriptExecutor( id, description, block ) @@ -100,7 +100,7 @@ fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor( nodeTemplates!![nodeTemplate.id!!] = nodeTemplate } -fun BlueprintTypes.nodeTemplateComponentScriptExecutor( +fun BluePrintTypes.nodeTemplateComponentScriptExecutor( id: String, description: String, block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit 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 7e3f16f39..ff6027341 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 @@ -29,8 +29,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutio import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptExecutionOutput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.RemoteScriptUploadBlueprintOutput 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.blueprintsprocessor.grpc.service.BluePrintGrpcClientService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService 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 @@ -63,7 +63,7 @@ interface RemoteScriptExecutionService { havingValue = "true", matchIfMissing = false ) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BlueprintGrpcLibPropertyService) : +class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) : RemoteScriptExecutionService { private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!! @@ -73,7 +73,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi override suspend fun init(selector: Any) { // Get the GRPC Client Service based on selector - val grpcClientService: BlueprintGrpcClientService = if (selector is JsonNode) { + val grpcClientService: BluePrintGrpcClientService = if (selector is JsonNode) { bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector) } else { bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector.toString()) 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 e28a8c405..d765edeaf 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 @@ -30,12 +30,12 @@ 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 +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -59,7 +59,7 @@ interface StreamingRemoteExecutionService { prefix = "blueprintsprocessor.streamingRemoteExecution", name = ["enabled"], havingValue = "true", matchIfMissing = false ) -class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BlueprintGrpcLibPropertyService) : +class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertyService: BluePrintGrpcLibPropertyService) : StreamingRemoteExecutionService { private val log = logger(StreamingRemoteExecutionServiceImpl::class) @@ -85,12 +85,12 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe val grpcChannel = grpcChannel(selector) /** Get Send and Receive Channel for bidirectional process method*/ - val channels = clientCallBidiStreaming(BlueprintProcessingServiceGrpc.getProcessMethod(), grpcChannel) + val channels = clientCallBidiStreaming(BluePrintProcessingServiceGrpc.getProcessMethod(), grpcChannel) commChannels[txId] = channels } 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)") @@ -103,7 +103,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) @@ -128,7 +128,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe /** 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 */ @@ -187,7 +187,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe } suspend fun createGrpcChannel(grpcProperties: GrpcClientProperties): ManagedChannel { - val grpcClientService: BlueprintGrpcClientService = bluePrintGrpcLibPropertyService + val grpcClientService: BluePrintGrpcClientService = bluePrintGrpcLibPropertyService .blueprintGrpcClientService(grpcProperties) return grpcClientService.channel() } @@ -204,7 +204,7 @@ class StreamingRemoteExecutionServiceImpl(private val bluePrintGrpcLibPropertySe selector } else -> { - throw BlueprintException("couldn't process selector($selector)") + throw BluePrintException("couldn't process selector($selector)") } } } 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 69cb0b6eb..2f1ae2fc5 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 @@ -16,9 +16,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.springframework.stereotype.Service // TODO("After Jython depreciation, this interface will be removed") @@ -26,15 +26,15 @@ import org.springframework.stereotype.Service @Deprecated("CDS won's support Jython services") interface BlueprintJythonService { - fun jythonComponentInstance(bluePrintContext: BlueprintContext, scriptClassReference: String): + fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String): BlueprintFunctionNode<*, *> } @Service open class DeprecatedBlueprintJythonService : BlueprintJythonService { - override fun jythonComponentInstance(bluePrintContext: BlueprintContext, scriptClassReference: String): + override fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String): BlueprintFunctionNode<*, *> { - throw BlueprintProcessorException("Include python-executor module for Jython support") + throw BluePrintProcessorException("Include python-executor module for Jython support") } } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt index 5ef62d0bc..b3a0a5892 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt @@ -32,15 +32,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createExecutionServiceOutputProto import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.createStatus import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.toProto -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput import kotlin.test.assertNotNull @@ -48,7 +48,7 @@ class ComponentRemoteScriptExecutorTest { @Test fun testNodeComponentRemoteScriptExecutorType() { - val nodeType = BlueprintTypes.nodeTypeComponentRemoteScriptExecutor() + val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor() assertNotNull(nodeType, "failed to generate nodeType Component Remote Script Executor") } @@ -96,7 +96,7 @@ class ComponentRemoteScriptExecutorTest { fun testComponentRemoteScriptExecutor() { runBlocking { /** Mock blueprint context */ - val blueprintContext = mockk() + val blueprintContext = mockk() every { blueprintContext.rootPath } returns normalizedPathName("target") every { blueprintContext.nodeTemplateOperationImplementation( @@ -104,7 +104,7 @@ class ComponentRemoteScriptExecutorTest { ) } returns Implementation() - val bluePrintRuntime = mockk("1234") + val bluePrintRuntime = mockk("1234") every { bluePrintRuntime.bluePrintContext() } returns blueprintContext val mockExecutionServiceInput = mockExecutionServiceInput(bluePrintRuntime) @@ -130,7 +130,7 @@ class ComponentRemoteScriptExecutorTest { } } - private fun mockExecutionServiceInput(bluePrintRuntime: DefaultBlueprintRuntimeService): ExecutionServiceInput { + private fun mockExecutionServiceInput(bluePrintRuntime: DefaultBluePrintRuntimeService): ExecutionServiceInput { val mapper = ObjectMapper() val requestNode = mapper.createObjectNode() @@ -138,10 +138,10 @@ class ComponentRemoteScriptExecutorTest { requestNode.put("type", "grpc") val operationInputs = hashMapOf() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "remote-execute".asJsonPrimitive() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_INTERFACE] = + operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "remote-execute".asJsonPrimitive() + operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "ComponentRemoteScriptExecutor".asJsonPrimitive() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_OPERATION] = "process".asJsonPrimitive() + operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "process".asJsonPrimitive() operationInputs[ComponentRemoteScriptExecutor.INPUT_SELECTOR] = "remote-script-executor".asJsonPrimitive() operationInputs[ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME] = "sample-blueprint".asJsonPrimitive() @@ -205,7 +205,7 @@ class ComponentRemoteScriptExecutorTest { return createExecutionServiceOutputProto( executionServiceInput.commonHeader.toProto(), executionServiceInput.actionIdentifiers.toProto(), - createStatus(BlueprintConstants.STATUS_SUCCESS, 200), + createStatus(BluePrintConstants.STATUS_SUCCESS, 200), responsePayload ) } 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 new file mode 100644 index 000000000..8edea46f6 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBluePrintProcessingServer.kt @@ -0,0 +1,107 @@ +/* + * Copyright © 2018-2019 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import io.grpc.ServerBuilder +import io.grpc.stub.StreamObserver +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcServerLoggingInterceptor +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType +import org.onap.ccsdk.cds.controllerblueprints.common.api.Status +import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput + +private val log = logger(MockBluePrintProcessingServer::class) + +class MockBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { + + override fun process(responseObserver: StreamObserver): StreamObserver { + + return object : StreamObserver { + override fun onNext(executionServiceInput: ExecutionServiceInput) { + log.info( + "Received requestId(${executionServiceInput.commonHeader.requestId}) " + + "subRequestId(${executionServiceInput.commonHeader.subRequestId})" + ) + runBlocking { + launch(MDCContext()) { + responseObserver.onNext(buildNotification(executionServiceInput)) + responseObserver.onNext(buildResponse(executionServiceInput)) + log.info("message has sent successfully...") + } + } + responseObserver.onCompleted() + } + + override fun onError(error: Throwable) { + log.debug("Fail to process message", error) + responseObserver.onError( + io.grpc.Status.INTERNAL + .withDescription(error.message) + .asException() + ) + } + + override fun onCompleted() { + log.info("Completed") + } + } + } + + private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput { + val status = Status.newBuilder() + .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION) + .build() + return ExecutionServiceOutput.newBuilder() + .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() + return ExecutionServiceOutput.newBuilder() + .setCommonHeader(input.commonHeader) + .setActionIdentifiers(input.actionIdentifiers) + .setStatus(status) + .build() + } +} + +/** For Integration testing stat this server */ +fun main() { + try { + val server = ServerBuilder + .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() + } +} 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 deleted file mode 100644 index 7ac6134d9..000000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/MockBlueprintProcessingServer.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2018-2019 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts - -import io.grpc.ServerBuilder -import io.grpc.stub.StreamObserver -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.interceptor.GrpcServerLoggingInterceptor -import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.common.api.Status -import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext -import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BlueprintProcessingServiceGrpc -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput - -private val log = logger(MockBlueprintProcessingServer::class) - -class MockBlueprintProcessingServer : BlueprintProcessingServiceGrpc.BlueprintProcessingServiceImplBase() { - - override fun process(responseObserver: StreamObserver): StreamObserver { - - return object : StreamObserver { - override fun onNext(executionServiceInput: ExecutionServiceInput) { - log.info( - "Received requestId(${executionServiceInput.commonHeader.requestId}) " + - "subRequestId(${executionServiceInput.commonHeader.subRequestId})" - ) - runBlocking { - launch(MDCContext()) { - responseObserver.onNext(buildNotification(executionServiceInput)) - responseObserver.onNext(buildResponse(executionServiceInput)) - log.info("message has sent successfully...") - } - } - responseObserver.onCompleted() - } - - override fun onError(error: Throwable) { - log.debug("Fail to process message", error) - responseObserver.onError( - io.grpc.Status.INTERNAL - .withDescription(error.message) - .asException() - ) - } - - override fun onCompleted() { - log.info("Completed") - } - } - } - - private fun buildNotification(input: ExecutionServiceInput): ExecutionServiceOutput { - val status = Status.newBuilder() - .setEventType(EventType.EVENT_COMPONENT_NOTIFICATION) - .build() - return ExecutionServiceOutput.newBuilder() - .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() - return ExecutionServiceOutput.newBuilder() - .setCommonHeader(input.commonHeader) - .setActionIdentifiers(input.actionIdentifiers) - .setStatus(status) - .build() - } -} - -/** For Integration testing stat this server */ -fun main() { - try { - val server = ServerBuilder - .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() - } -} 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 0d3e42a5e..28e2b11b2 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 @@ -35,8 +35,8 @@ import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BlueprintGrpcLibPropertyService -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.MockBlueprintProcessingServer +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.MockBluePrintProcessingServer import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType @@ -67,11 +67,11 @@ class StreamingRemoteExecutionServiceTest { @ExperimentalCoroutinesApi @FlowPreview fun testStreamingChannel() { - grpcCleanup.register(serverBuilder.addService(MockBlueprintProcessingServer()).build().start()) + grpcCleanup.register(serverBuilder.addService(MockBluePrintProcessingServer()).build().start()) val channel = grpcCleanup.register(channelBuilder.maxInboundMessageSize(1024).build()) runBlocking { - val bluePrintGrpcLibPropertyService = BlueprintGrpcLibPropertyService(mockk()) + val bluePrintGrpcLibPropertyService = BluePrintGrpcLibPropertyService(mockk()) val streamingRemoteExecutionService = StreamingRemoteExecutionServiceImpl(bluePrintGrpcLibPropertyService) 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 3438821c7..b5757812c 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 @@ -34,23 +34,23 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.core.service.CDS_LOCK_GROUP import org.onap.ccsdk.cds.blueprintsprocessor.core.service.ClusterLock import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeComponentScriptExecutor -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintError -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation import org.onap.ccsdk.cds.controllerblueprints.core.data.LockAssignment import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintScriptsServiceImpl -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration @@ -66,14 +66,14 @@ import kotlin.test.assertNotNull @ContextConfiguration( classes = [ ComponentFunctionScriptingService::class, - BlueprintScriptsServiceImpl::class, DeprecatedBlueprintJythonService::class + BluePrintScriptsServiceImpl::class, DeprecatedBlueprintJythonService::class ] ) class AbstractComponentFunctionTest { - lateinit var bluePrintRuntimeService: DefaultBlueprintRuntimeService - lateinit var blueprintContext: BlueprintContext - lateinit var blueprintClusterService: BlueprintClusterService + lateinit var bluePrintRuntimeService: DefaultBluePrintRuntimeService + lateinit var blueprintContext: BluePrintContext + lateinit var blueprintClusterService: BluePrintClusterService @Autowired lateinit var compSvc: ComponentFunctionScriptingService @@ -92,7 +92,7 @@ class AbstractComponentFunctionTest { ) } returns Implementation() - every { bluePrintRuntimeService.getBlueprintError() } returns BlueprintError() + every { bluePrintRuntimeService.getBluePrintError() } returns BluePrintError() } @Test @@ -152,7 +152,7 @@ class AbstractComponentFunctionTest { @Test fun testComponentScriptExecutorNodeType() { - val componentScriptExecutor = BlueprintTypes.nodeTypeComponentScriptExecutor() + val componentScriptExecutor = BluePrintTypes.nodeTypeComponentScriptExecutor() assertNotNull(componentScriptExecutor.interfaces, "failed to get interface operations") } @@ -277,7 +277,7 @@ class AbstractComponentFunctionTest { /** * Mocked input for abstract function test. */ - private fun getMockedInput(bluePrintRuntime: DefaultBlueprintRuntimeService): + private fun getMockedInput(bluePrintRuntime: DefaultBluePrintRuntimeService): ExecutionServiceInput { val mapper = ObjectMapper() @@ -286,11 +286,11 @@ class AbstractComponentFunctionTest { rootNode.put("type", "rest") val operationInputs = hashMapOf() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = + operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "activate-restconf".asJsonPrimitive() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_INTERFACE] = + operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive() - operationInputs[BlueprintConstants.PROPERTY_CURRENT_OPERATION] = + operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive() operationInputs["dynamic-properties"] = rootNode 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 new file mode 100644 index 000000000..0f8007658 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt @@ -0,0 +1,111 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow + +import com.fasterxml.jackson.databind.JsonNode +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.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Service + +@Service("bluePrintWorkflowExecutionService") +open class BluePrintWorkflowExecutionServiceImpl( + private val componentWorkflowExecutionService: ComponentWorkflowExecutionService, + private val dgWorkflowExecutionService: DGWorkflowExecutionService, + private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService +) : BluePrintWorkflowExecutionService { + + private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!! + + override suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, + executionServiceInput: ExecutionServiceInput, + properties: MutableMap + ): ExecutionServiceOutput { + + val bluePrintContext = bluePrintRuntimeService.bluePrintContext() + + val workflowName = executionServiceInput.actionIdentifiers.actionName + + // Assign Workflow inputs + // check if request structure exists + if (!executionServiceInput.payload.has("$workflowName-request")) { + throw BluePrintProcessorException("Input request missing the expected '$workflowName-request' block!") + } + val input = executionServiceInput.payload.get("$workflowName-request") + bluePrintRuntimeService.assignWorkflowInputs(workflowName, input) + + val workflow = bluePrintContext.workflowByName(workflowName) + + val steps = workflow.steps ?: throw BluePrintProcessorException("could't get steps for workflow($workflowName)") + + /** If workflow has multiple steps, then it is imperative workflow */ + val executionServiceOutput: ExecutionServiceOutput = if (steps.size > 1) { + imperativeWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) + } else { + // Get the DG Node Template + val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName) + + val derivedFrom = bluePrintContext.nodeTemplateNodeType(nodeTemplateName).derivedFrom + + log.info("Executing workflow($workflowName) NodeTemplate($nodeTemplateName), derived from($derivedFrom)") + /** Return ExecutionServiceOutput based on DG node or Component Node */ + when { + derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> { + componentWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) + } + derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> { + dgWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) + } + else -> { + throw BluePrintProcessorException( + "couldn't execute workflow($workflowName) step mapped " + + "to node template($nodeTemplateName) derived from($derivedFrom)" + ) + } + } + } + executionServiceOutput.commonHeader = executionServiceInput.commonHeader + executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers + + // Resolve Workflow Outputs + var workflowOutputs: MutableMap? = null + try { + workflowOutputs = bluePrintRuntimeService.resolveWorkflowOutputs(workflowName) + } catch (e: RuntimeException) { + log.error("Failed to resolve outputs for workflow: $workflowName", e) + e.message?.let { bluePrintRuntimeService.getBluePrintError().addError(it, "workflow") } + } + + // Set the Response Payload + executionServiceOutput.payload = JacksonUtils.objectMapper.createObjectNode() + executionServiceOutput.payload.set( + "$workflowName-response", + workflowOutputs?.asObjectNode() ?: JacksonUtils.objectMapper.createObjectNode() + ) + 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 64bb70e63..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 @@ -16,20 +16,20 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.sli.core.sli.SvcLogicContext class BlueprintSvcLogicContext : SvcLogicContext() { - private var bluePrintRuntimeService: BlueprintRuntimeService<*>? = null + private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null private var request: Any? = null private var response: Any? = null - fun getBlueprintService(): BlueprintRuntimeService<*> { + fun getBluePrintService(): BluePrintRuntimeService<*> { return this.bluePrintRuntimeService!! } - fun setBlueprintRuntimeService(bluePrintRuntimeService: BlueprintRuntimeService<*>) { + fun setBluePrintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { this.bluePrintRuntimeService = bluePrintRuntimeService } 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 ebad1501b..4efe9f12d 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 @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.sli.core.sli.ExitNodeException import org.onap.ccsdk.sli.core.sli.SvcLogicContext import org.onap.ccsdk.sli.core.sli.SvcLogicException @@ -47,7 +47,7 @@ interface BlueprintSvcLogicService : SvcLogicServiceBase { fun unRegisterExecutors(name: String) - suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BlueprintRuntimeService<*>, input: Any): Any + suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any override fun execute(module: String, rpc: String, version: String, mode: String, ctx: SvcLogicContext): SvcLogicContext { TODO("not implemented") @@ -104,12 +104,12 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { override suspend fun execute( graph: SvcLogicGraph, - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any ): Any { // Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request val blueprintSvcLogicContext = BlueprintSvcLogicContext() - blueprintSvcLogicContext.setBlueprintRuntimeService(bluePrintRuntimeService) + blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) blueprintSvcLogicContext.setRequest(input) // Execute the Graph execute(graph, blueprintSvcLogicContext) 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 deleted file mode 100644 index 5a175b056..000000000 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintWorkflowExecutionServiceImpl.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow - -import com.fasterxml.jackson.databind.JsonNode -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.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintWorkflowExecutionService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Service - -@Service("bluePrintWorkflowExecutionService") -open class BlueprintWorkflowExecutionServiceImpl( - private val componentWorkflowExecutionService: ComponentWorkflowExecutionService, - private val dgWorkflowExecutionService: DGWorkflowExecutionService, - private val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService -) : BlueprintWorkflowExecutionService { - - private val log = LoggerFactory.getLogger(BlueprintWorkflowExecutionServiceImpl::class.java)!! - - override suspend fun executeBlueprintWorkflow( - bluePrintRuntimeService: BlueprintRuntimeService<*>, - executionServiceInput: ExecutionServiceInput, - properties: MutableMap - ): ExecutionServiceOutput { - - val bluePrintContext = bluePrintRuntimeService.bluePrintContext() - - val workflowName = executionServiceInput.actionIdentifiers.actionName - - // Assign Workflow inputs - // check if request structure exists - if (!executionServiceInput.payload.has("$workflowName-request")) { - throw BlueprintProcessorException("Input request missing the expected '$workflowName-request' block!") - } - val input = executionServiceInput.payload.get("$workflowName-request") - bluePrintRuntimeService.assignWorkflowInputs(workflowName, input) - - val workflow = bluePrintContext.workflowByName(workflowName) - - val steps = workflow.steps ?: throw BlueprintProcessorException("could't get steps for workflow($workflowName)") - - /** If workflow has multiple steps, then it is imperative workflow */ - val executionServiceOutput: ExecutionServiceOutput = if (steps.size > 1) { - imperativeWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) - } else { - // Get the DG Node Template - val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName) - - val derivedFrom = bluePrintContext.nodeTemplateNodeType(nodeTemplateName).derivedFrom - - log.info("Executing workflow($workflowName) NodeTemplate($nodeTemplateName), derived from($derivedFrom)") - /** Return ExecutionServiceOutput based on DG node or Component Node */ - when { - derivedFrom.startsWith(BlueprintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> { - componentWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) - } - derivedFrom.startsWith(BlueprintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> { - dgWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, properties) - } - else -> { - throw BlueprintProcessorException( - "couldn't execute workflow($workflowName) step mapped " + - "to node template($nodeTemplateName) derived from($derivedFrom)" - ) - } - } - } - executionServiceOutput.commonHeader = executionServiceInput.commonHeader - executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers - - // Resolve Workflow Outputs - var workflowOutputs: MutableMap? = null - try { - workflowOutputs = bluePrintRuntimeService.resolveWorkflowOutputs(workflowName) - } catch (e: RuntimeException) { - log.error("Failed to resolve outputs for workflow: $workflowName", e) - e.message?.let { bluePrintRuntimeService.getBlueprintError().addError(it, "workflow") } - } - - // Set the Response Payload - executionServiceOutput.payload = JacksonUtils.objectMapper.createObjectNode() - executionServiceOutput.payload.set( - "$workflowName-response", - workflowOutputs?.asObjectNode() ?: JacksonUtils.objectMapper.createObjectNode() - ) - return executionServiceOutput - } -} 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 322180893..397dd3ffd 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 @@ -18,16 +18,16 @@ 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 -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.springframework.stereotype.Service @Service("componentWorkflowExecutionService") open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) : - BlueprintWorkflowExecutionService { + BluePrintWorkflowExecutionService { - override suspend fun executeBlueprintWorkflow( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + override suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput, properties: MutableMap ): ExecutionServiceOutput { 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 efcae4aee..d40b8f144 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 @@ -21,20 +21,20 @@ 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.StepData import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.utils.SvcGraphUtils -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintWorkflowExecutionService +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service("dgWorkflowExecutionService") open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService) : - BlueprintWorkflowExecutionService { + BluePrintWorkflowExecutionService { private val log = LoggerFactory.getLogger(DGWorkflowExecutionService::class.java) - override suspend fun executeBlueprintWorkflow( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + override suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput, properties: MutableMap ): ExecutionServiceOutput { 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 29019b7cc..b8350f4f1 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 @@ -22,19 +22,19 @@ 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.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext 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.interfaces.BluePrintWorkflowExecutionService import org.onap.ccsdk.cds.controllerblueprints.core.isAcyclic 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.AbstractBluePrintWorkFlowService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService 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 @@ -45,10 +45,10 @@ import kotlin.coroutines.CoroutineContext class ImperativeWorkflowExecutionService( private val nodeTemplateExecutionService: NodeTemplateExecutionService ) : - BlueprintWorkflowExecutionService { + BluePrintWorkflowExecutionService { - override suspend fun executeBlueprintWorkflow( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + override suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput, properties: MutableMap ): ExecutionServiceOutput { @@ -60,11 +60,11 @@ class ImperativeWorkflowExecutionService( val graph = bluePrintContext.workflowByName(workflowName).asGraph() if (!graph.isAcyclic()) { - throw BlueprintException("Imperative workflow must be acyclic. Check on_success/on_failure for circular references") + throw BluePrintException("Imperative workflow must be acyclic. Check on_success/on_failure for circular references") } return coroutineScope { - ImperativeBlueprintWorkflowService( + ImperativeBluePrintWorkflowService( nodeTemplateExecutionService, this.coroutineContext[MDCContext] ) @@ -72,21 +72,21 @@ class ImperativeWorkflowExecutionService( } } -open class ImperativeBlueprintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService, private val mdcContext: CoroutineContext?) : - AbstractBlueprintWorkFlowService() { +open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService, private val mdcContext: CoroutineContext?) : + AbstractBluePrintWorkFlowService() { final override val coroutineContext: CoroutineContext get() = mdcContext?.let { super.coroutineContext + it } ?: super.coroutineContext - val log = logger(ImperativeBlueprintWorkflowService::class) + val log = logger(ImperativeBluePrintWorkflowService::class) - lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*> + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var executionServiceInput: ExecutionServiceInput lateinit var workflowName: String override suspend fun executeWorkflow( graph: Graph, - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, input: ExecutionServiceInput ): ExecutionServiceOutput { this.graph = graph @@ -100,7 +100,7 @@ open class ImperativeBlueprintWorkflowService(private val nodeTemplateExecutionS if (!workflowActor.isClosedForSend) { workflowActor.send(startMessage) } else { - throw BlueprintProcessorException("workflow($workflowActor) actor is closed") + throw BluePrintProcessorException("workflow($workflowActor) actor is closed") } return output.await() } @@ -114,12 +114,12 @@ open class ImperativeBlueprintWorkflowService(private val nodeTemplateExecutionS if (exceptions.isNotEmpty()) { exceptions.forEach { val errorMessage = it.message ?: "" - bluePrintRuntimeService.getBlueprintError().addError(errorMessage, "workflow") + bluePrintRuntimeService.getBluePrintError().addError(errorMessage, "workflow") log.error("workflow($workflowId) exception :", it) } - message = BlueprintConstants.STATUS_FAILURE + message = BluePrintConstants.STATUS_FAILURE } else { - message = BlueprintConstants.STATUS_SUCCESS + message = BluePrintConstants.STATUS_SUCCESS } eventType = EventType.EVENT_COMPONENT_EXECUTED.name } @@ -162,9 +162,9 @@ open class ImperativeBlueprintWorkflowService(private val nodeTemplateExecutionS val executionServiceOutput = nodeTemplateExecutionService .executeNodeTemplate(bluePrintRuntimeService, node.id, nodeTemplateName, nodeInput) - if (executionServiceOutput.status.message == BlueprintConstants.STATUS_FAILURE) { + if (executionServiceOutput.status.message == BluePrintConstants.STATUS_FAILURE) { // Clear step errors so that the workflow does not fail - bluePrintRuntimeService.getBlueprintError().stepErrors(node.id)?.clear() + bluePrintRuntimeService.getBluePrintError().stepErrors(node.id)?.clear() return EdgeLabel.FAILURE } 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 ff8f5b8cf..88799d102 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 @@ -20,23 +20,23 @@ import com.fasterxml.jackson.databind.JsonNode 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.blueprintsprocessor.core.api.data.StepData -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service -open class NodeTemplateExecutionService(private val bluePrintClusterService: BlueprintClusterService) { +open class NodeTemplateExecutionService(private val bluePrintClusterService: BluePrintClusterService) { private val log = LoggerFactory.getLogger(NodeTemplateExecutionService::class.java)!! suspend fun executeNodeTemplate( - bluePrintRuntimeService: BlueprintRuntimeService<*>, + bluePrintRuntimeService: BluePrintRuntimeService<*>, stepName: String, nodeTemplateName: String, executionServiceInput: ExecutionServiceInput @@ -63,7 +63,7 @@ open class NodeTemplateExecutionService(private val bluePrintClusterService: Blu ) // Get the Component Instance - val plugin = BlueprintDependencyService.instance(componentName) + val plugin = BluePrintDependencyService.instance(componentName) // Set the Blueprint Services plugin.bluePrintRuntimeService = bluePrintRuntimeService plugin.bluePrintClusterService = bluePrintClusterService @@ -79,9 +79,9 @@ open class NodeTemplateExecutionService(private val bluePrintClusterService: Blu // Populate Step Meta Data val stepInputs: MutableMap = hashMapOf() - stepInputs[BlueprintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = nodeTemplateName.asJsonPrimitive() - stepInputs[BlueprintConstants.PROPERTY_CURRENT_INTERFACE] = interfaceName.asJsonPrimitive() - stepInputs[BlueprintConstants.PROPERTY_CURRENT_OPERATION] = operationName.asJsonPrimitive() + stepInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = nodeTemplateName.asJsonPrimitive() + stepInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = interfaceName.asJsonPrimitive() + stepInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = operationName.asJsonPrimitive() val stepInputData = StepData().apply { name = stepName properties = stepInputs 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 2e3f78a69..8ef74152c 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 @@ -52,7 +52,7 @@ open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService try { // Get the Request from the Context and Set to the Function Input and Invoke the function val executionOutput = nodeTemplateExecutionService.executeNodeTemplate( - ctx.getBlueprintService(), stepName, nodeTemplateName, executionInput + ctx.getBluePrintService(), stepName, nodeTemplateName, executionInput ) ctx.setResponse(executionOutput) 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 new file mode 100644 index 000000000..c28e36acc --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt @@ -0,0 +1,185 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ObjectNode +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.unmockkAll +import kotlinx.coroutines.runBlocking +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader +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.blueprintsprocessor.core.service.BluePrintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType +import org.onap.ccsdk.cds.controllerblueprints.core.data.Step +import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertNotNull + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [WorkflowServiceConfiguration::class]) +class BluePrintWorkflowExecutionServiceImplTest { + + @Autowired + lateinit var bluePrintWorkflowExecutionService: BluePrintWorkflowExecutionService + + @MockBean + lateinit var bluePrintClusterService: BluePrintClusterService + + @Before + fun init() { + mockkObject(BluePrintDependencyService) + every { BluePrintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() + } + + @After + fun afterTests() { + unmockkAll() + } + + @Test + fun testBluePrintWorkflowExecutionService() { + runBlocking { + 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 executionServiceOutput = bluePrintWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + + assertNotNull(executionServiceOutput, "failed to get 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 executionServiceInput = JacksonUtils.readValueFromClassPathFile( + "execution-input/imperative-test-input.json", + ExecutionServiceInput::class.java + )!! + + val executionServiceOutput = bluePrintWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + + assertNotNull(executionServiceOutput, "failed to get response") + assertEquals( + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + "failed to get successful response" + ) + } + } + + @Test + 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 executionServiceOutput = bluePrintWorkflowExecutionService + .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) + } + } + } + + @Test + fun `Should handle errors from resolve workflow output`() { + val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService = mockk() + val bluePrintWorkflowExecutionServiceImpl = BluePrintWorkflowExecutionServiceImpl( + mockk(), mockk(), imperativeWorkflowExecutionService + ) + val bluePrintRuntimeService: BluePrintRuntimeService> = mockk() + val bluePrintContext: BluePrintContext = mockk() + val executionServiceInput = ExecutionServiceInput().apply { + this.actionIdentifiers = ActionIdentifiers().apply { this.actionName = "config-assign" } + this.commonHeader = CommonHeader() + this.payload = """{"config-assign-request": {}}""".asJsonType() as ObjectNode + } + val workflow = Workflow().apply { + this.steps = mutableMapOf("one" to Step(), "two" to Step()) + } + val blueprintError = BluePrintError() + + every { bluePrintRuntimeService.bluePrintContext() } returns bluePrintContext + every { bluePrintRuntimeService.assignWorkflowInputs(any(), any()) } returns Unit + every { bluePrintContext.workflowByName(any()) } returns workflow + every { + bluePrintRuntimeService.resolveWorkflowOutputs(any()) + } throws RuntimeException("failed to resolve property...") + every { + runBlocking { + imperativeWorkflowExecutionService.executeBluePrintWorkflow(any(), any(), any()) + } + } returns ExecutionServiceOutput() + every { bluePrintRuntimeService.getBluePrintError() } returns blueprintError + + runBlocking { + val output = bluePrintWorkflowExecutionServiceImpl.executeBluePrintWorkflow( + bluePrintRuntimeService, executionServiceInput, mutableMapOf() + ) + assertEquals("failed to resolve property...", blueprintError.allErrors()[0]) + assertEquals("""{"config-assign-response":{}}""".asJsonType(), output.payload) + } + } +} 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 e7dd9dedb..d391050a6 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 @@ -22,13 +22,13 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.mock.mockito.MockBean @@ -49,17 +49,17 @@ class BlueprintServiceLogicTest { lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService @MockBean - lateinit var bluePrintClusterService: BlueprintClusterService + lateinit var bluePrintClusterService: BluePrintClusterService @Before fun init() { - BlueprintDependencyService.inject(applicationContext) + BluePrintDependencyService.inject(applicationContext) } @Test fun testExecuteGraphWithSingleComponent() { runBlocking { - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime( + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( "1234", "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -72,10 +72,10 @@ class BlueprintServiceLogicTest { 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, + BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, "failed to get successful response" ) } @@ -84,7 +84,7 @@ class BlueprintServiceLogicTest { @Test fun testExecuteGraphWithMultipleComponents() { runBlocking { - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime( + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( "1234", "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -97,10 +97,10 @@ class BlueprintServiceLogicTest { 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, + 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/BlueprintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintWorkflowExecutionServiceImplTest.kt deleted file mode 100644 index b7087b338..000000000 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintWorkflowExecutionServiceImplTest.kt +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow - -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.ObjectNode -import io.mockk.every -import io.mockk.mockk -import io.mockk.mockkObject -import io.mockk.unmockkAll -import kotlinx.coroutines.runBlocking -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader -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.blueprintsprocessor.core.service.BlueprintClusterService -import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintError -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType -import org.onap.ccsdk.cds.controllerblueprints.core.data.Step -import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintWorkflowExecutionService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith -import kotlin.test.assertNotNull - -@RunWith(SpringRunner::class) -@ContextConfiguration(classes = [WorkflowServiceConfiguration::class]) -class BlueprintWorkflowExecutionServiceImplTest { - - @Autowired - lateinit var bluePrintWorkflowExecutionService: BlueprintWorkflowExecutionService - - @MockBean - lateinit var bluePrintClusterService: BlueprintClusterService - - @Before - fun init() { - mockkObject(BlueprintDependencyService) - every { BlueprintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() - } - - @After - fun afterTests() { - unmockkAll() - } - - @Test - fun testBlueprintWorkflowExecutionService() { - runBlocking { - 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 executionServiceOutput = bluePrintWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) - - assertNotNull(executionServiceOutput, "failed to get 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 executionServiceInput = JacksonUtils.readValueFromClassPathFile( - "execution-input/imperative-test-input.json", - ExecutionServiceInput::class.java - )!! - - val executionServiceOutput = bluePrintWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) - - assertNotNull(executionServiceOutput, "failed to get response") - assertEquals( - BlueprintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, - "failed to get successful response" - ) - } - } - - @Test - 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 executionServiceOutput = bluePrintWorkflowExecutionService - .executeBlueprintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf()) - } - } - } - - @Test - fun `Should handle errors from resolve workflow output`() { - val imperativeWorkflowExecutionService: ImperativeWorkflowExecutionService = mockk() - val bluePrintWorkflowExecutionServiceImpl = BlueprintWorkflowExecutionServiceImpl( - mockk(), mockk(), imperativeWorkflowExecutionService - ) - val bluePrintRuntimeService: BlueprintRuntimeService> = mockk() - val bluePrintContext: BlueprintContext = mockk() - val executionServiceInput = ExecutionServiceInput().apply { - this.actionIdentifiers = ActionIdentifiers().apply { this.actionName = "config-assign" } - this.commonHeader = CommonHeader() - this.payload = """{"config-assign-request": {}}""".asJsonType() as ObjectNode - } - val workflow = Workflow().apply { - this.steps = mutableMapOf("one" to Step(), "two" to Step()) - } - val blueprintError = BlueprintError() - - every { bluePrintRuntimeService.bluePrintContext() } returns bluePrintContext - every { bluePrintRuntimeService.assignWorkflowInputs(any(), any()) } returns Unit - every { bluePrintContext.workflowByName(any()) } returns workflow - every { - bluePrintRuntimeService.resolveWorkflowOutputs(any()) - } throws RuntimeException("failed to resolve property...") - every { - runBlocking { - imperativeWorkflowExecutionService.executeBlueprintWorkflow(any(), any(), any()) - } - } returns ExecutionServiceOutput() - every { bluePrintRuntimeService.getBlueprintError() } returns blueprintError - - runBlocking { - val output = bluePrintWorkflowExecutionServiceImpl.executeBlueprintWorkflow( - bluePrintRuntimeService, executionServiceInput, mutableMapOf() - ) - assertEquals("failed to resolve property...", blueprintError.allErrors()[0]) - assertEquals("""{"config-assign-response":{}}""".asJsonType(), output.payload) - } - } -} 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 355939cdd..cc1bfee7f 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 @@ -22,11 +22,11 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.mock.mockito.MockBean @@ -47,18 +47,18 @@ class DGWorkflowExecutionServiceTest { lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService @MockBean - lateinit var bluePrintClusterService: BlueprintClusterService + lateinit var bluePrintClusterService: BluePrintClusterService @Before fun init() { - BlueprintDependencyService.inject(applicationContext) + BluePrintDependencyService.inject(applicationContext) } @Test fun testExecuteDirectedGraph() { runBlocking { - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime( + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( "1234", "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -70,14 +70,14 @@ class DGWorkflowExecutionServiceTest { val input = executionServiceInput.payload.get("resource-assignment-request") bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input) - val executionServiceOutput = dgWorkflowExecutionService.executeBlueprintWorkflow( + val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow( bluePrintRuntimeService, executionServiceInput, mutableMapOf() ) assertNotNull(executionServiceOutput, "failed to get response") assertEquals( - BlueprintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + 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 9ba607cd4..2367422a7 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 @@ -28,15 +28,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeCompone import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.mockNodeTemplateComponentScriptExecutor import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import kotlin.test.Test import kotlin.test.assertEquals @@ -48,8 +48,8 @@ class ImperativeWorkflowExecutionServiceTest { @Before fun init() { - mockkObject(BlueprintDependencyService) - every { BlueprintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() + mockkObject(BluePrintDependencyService) + every { BluePrintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() } @After @@ -101,7 +101,7 @@ class ImperativeWorkflowExecutionServiceTest { step("activate-licence", "activate-licence", "") } } - nodeType(BlueprintTypes.nodeTypeComponentScriptExecutor()) + nodeType(BluePrintTypes.nodeTypeComponentScriptExecutor()) } } @@ -109,10 +109,10 @@ class ImperativeWorkflowExecutionServiceTest { fun testImperativeExecutionService() { runBlocking { val serviceTemplate = mockServiceTemplate() - val bluePrintContext = BlueprintContext(serviceTemplate) + val bluePrintContext = BluePrintContext(serviceTemplate) bluePrintContext.rootPath = normalizedPathName(".") bluePrintContext.entryDefinition = "cba.imperative.test.ImperativeTestDefinitions.kt" - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime("12345", bluePrintContext) + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("12345", bluePrintContext) val executionServiceInput = JacksonUtils .readValueFromClassPathFile( @@ -122,10 +122,10 @@ class ImperativeWorkflowExecutionServiceTest { val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(NodeTemplateExecutionService(mockk())) 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.message, BluePrintConstants.STATUS_SUCCESS) assertEquals(output.status.eventType, EventType.EVENT_COMPONENT_EXECUTED.name) } } 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 b113987e5..783939880 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 @@ -24,11 +24,11 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BlueprintClusterService +import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.test.context.ContextConfiguration @@ -42,12 +42,12 @@ import kotlin.test.assertNotNull class NodeTemplateExecutionServiceTest { @MockBean - lateinit var bluePrintClusterService: BlueprintClusterService + lateinit var bluePrintClusterService: BluePrintClusterService @Before fun init() { - mockkObject(BlueprintDependencyService) - every { BlueprintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() + mockkObject(BluePrintDependencyService) + every { BluePrintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction() } @After @@ -58,7 +58,7 @@ class NodeTemplateExecutionServiceTest { @Test fun testExecuteNodeTemplate() { runBlocking { - val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime( + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( "1234", "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" ) @@ -81,7 +81,7 @@ class NodeTemplateExecutionServiceTest { assertNotNull(executionServiceOutput, "failed to get response") assertEquals( - BlueprintConstants.STATUS_SUCCESS, executionServiceOutput.status.message, + 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/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt index e2bc0f131..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 @@ -20,7 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock 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.nodeTemplateComponentScriptExecutor -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory @@ -29,7 +29,7 @@ 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( +fun mockNodeTemplateComponentScriptExecutor(id: String, script: String) = BluePrintTypes.nodeTemplateComponentScriptExecutor( id, "mock($id) component function" ) { -- cgit 1.2.3-korg