aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/workflow-service
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/workflow-service')
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/pom.xml46
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt72
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt52
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt143
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt49
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt70
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt72
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt31
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt69
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt35
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt54
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt99
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt57
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt82
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml35
17 files changed, 1012 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
new file mode 100644
index 000000000..4331eec77
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~ Modifications Copyright © 2018 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>services</artifactId>
+ <version>0.4.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>workflow-service</artifactId>
+ <name>Blueprints Processor Workflow Service</name>
+ <description>Blueprints Processor Workflow Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>blueprint-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>execution-service</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project>
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
new file mode 100644
index 000000000..73f6f497e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -0,0 +1,72 @@
+/*
+ * 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.apps.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service("bluePrintWorkflowExecutionService")
+open class BluePrintWorkflowExecutionServiceImpl(
+ private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
+ private val dgWorkflowExecutionService: DGWorkflowExecutionService
+) : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+
+ private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!!
+
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // 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)")
+
+ val executionServiceOutput: ExecutionServiceOutput = when {
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
+ componentWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ }
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_DG, 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
+ // TODO("Populate Response Payload and status")
+ return executionServiceOutput
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
new file mode 100644
index 000000000..d2648c079
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2017-2018 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.apps.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext
+
+class BlueprintSvcLogicContext : SvcLogicContext() {
+
+ private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ private var request: Any? = null
+ private var response: Any? = null
+
+ fun getBluePrintService(): BluePrintRuntimeService<*> {
+ return this.bluePrintRuntimeService!!
+ }
+
+ fun setBluePrintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ }
+
+ fun setRequest(request: Any) {
+ this.request = request
+ }
+
+ fun getRequest(): Any {
+ return this.request!!
+ }
+
+ fun setResponse(response: Any) {
+ this.response = response
+ }
+
+ fun getResponse(): Any {
+ return this.response!!
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
new file mode 100644
index 000000000..fd7ec45b3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
@@ -0,0 +1,143 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.apps.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.sli.core.sli.*
+import org.onap.ccsdk.sli.core.sli.provider.base.*
+import org.slf4j.LoggerFactory
+import org.slf4j.MDC
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import java.util.*
+import javax.annotation.PostConstruct
+
+interface BlueprintSvcLogicService : SvcLogicServiceBase {
+
+ fun registerDefaultExecutors()
+
+ fun registerExecutors(name: String, svcLogicNodeExecutor: AbstractSvcLogicNodeExecutor)
+
+ fun unRegisterExecutors(name: String)
+
+ suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any
+
+ @Deprecated("Populate Graph Dynamically from Blueprints, No need to get from Database Store ")
+ override fun getStore(): SvcLogicStore {
+ TODO("not implemented")
+ }
+
+ @Deprecated("Not used in Micro service Implementation")
+ override fun hasGraph(module: String, rpc: String, version: String?, mode: String): Boolean {
+ TODO("not implemented")
+ }
+
+ @Deprecated("Not used in Micro service Implementation")
+ override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?): Properties {
+ TODO("not implemented")
+ }
+}
+
+
+@Service
+class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
+
+ private val log = LoggerFactory.getLogger(DefaultBlueprintSvcLogicService::class.java)
+
+ private val nodeExecutors: MutableMap<String, AbstractSvcLogicNodeExecutor> = hashMapOf()
+
+ @Autowired
+ private lateinit var context: ApplicationContext
+
+ @PostConstruct
+ override fun registerDefaultExecutors() {
+
+ val executeNodeExecutor = context.getBean(ExecuteNodeExecutor::class.java)
+ registerExecutors("execute", executeNodeExecutor)
+ registerExecutors("block", BlockNodeExecutor())
+ registerExecutors("return", ReturnNodeExecutor())
+ registerExecutors("break", BreakNodeExecutor())
+ registerExecutors("exit", ExitNodeExecutor())
+ }
+
+ override fun registerExecutors(name: String, svcLogicNodeExecutor: AbstractSvcLogicNodeExecutor) {
+ log.info("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}")
+ nodeExecutors[name] = svcLogicNodeExecutor
+ }
+
+ override fun unRegisterExecutors(name: String) {
+ if (nodeExecutors.containsKey(name)) {
+ log.info("UnRegistering executors($name)")
+ nodeExecutors.remove(name)
+ }
+ }
+
+ override suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: Any): Any {
+ //Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
+ val blueprintSvcLogicContext = BlueprintSvcLogicContext()
+ blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
+ blueprintSvcLogicContext.setRequest(input)
+ // Execute the Graph
+ execute(graph, blueprintSvcLogicContext)
+ // Get the Response
+ return blueprintSvcLogicContext.getResponse()
+ }
+
+ override fun executeNode(node: SvcLogicNode?, ctx: SvcLogicContext): SvcLogicNode? {
+ if (node == null) {
+ return null
+ } else {
+ if (log.isDebugEnabled) {
+ log.debug("Executing node {}", node.nodeId)
+ }
+
+ val executor = this.nodeExecutors[node.nodeType]
+
+ if (executor != null) {
+ log.debug("Executing node executor for node type {} - {}", node.nodeType, executor.javaClass.name)
+ return executor.execute(this, node, ctx)
+ } else {
+ throw SvcLogicException("Attempted to execute a node of type " + node.nodeType + ", but no executor was registered for this type")
+ }
+ }
+ }
+
+ override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext {
+ MDC.put("currentGraph", graph.toString())
+
+ var curNode: SvcLogicNode? = graph.rootNode
+ log.info("About to execute graph {}", graph.toString())
+
+ try {
+ while (curNode != null) {
+ MDC.put("nodeId", curNode.nodeId.toString() + " (" + curNode.nodeType + ")")
+ log.info("About to execute node # {} ({})", curNode.nodeId, curNode.nodeType)
+ val nextNode = this.executeNode(curNode, svcLogicContext)
+ curNode = nextNode
+ }
+ } catch (var5: ExitNodeException) {
+ log.debug("SvcLogicServiceImpl caught ExitNodeException")
+ }
+
+ MDC.remove("nodeId")
+ MDC.remove("currentGraph")
+ return svcLogicContext
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
new file mode 100644
index 000000000..76d0c46b5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -0,0 +1,49 @@
+/*
+ * 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.apps.blueprintsprocessor.services.workflow
+
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+
+@Service("componentWorkflowExecutionService")
+open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
+ : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // Get the DG Node Template
+ val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
+
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
+ return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
+ nodeTemplateName, executionServiceInput)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
new file mode 100644
index 000000000..262b1be19
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.apps.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+
+@Service("dgWorkflowExecutionService")
+open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService)
+ : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+
+ private val log = LoggerFactory.getLogger(DGWorkflowExecutionService::class.java)
+
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // Get the DG Node Template
+ val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
+
+ log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)")
+
+ // Get the DG file info
+ val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
+ WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
+
+ // Populate the DG Path
+ val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
+
+ log.info("Executing directed graph ($dgFilePath)")
+
+ // Create DG instance
+ val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
+
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
+ // Execute the DG
+ return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
+
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
new file mode 100644
index 000000000..6ce4753b8
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -0,0 +1,72 @@
+/*
+ * 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.apps.blueprintsprocessor.services.workflow
+
+import com.fasterxml.jackson.databind.JsonNode
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+open class NodeTemplateExecutionService(private val applicationContext: ApplicationContext) {
+
+ private val log = LoggerFactory.getLogger(NodeTemplateExecutionService::class.java)!!
+
+ suspend fun executeNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ // Get the Blueprint Context
+ val blueprintContext = bluePrintRuntimeService.bluePrintContext()
+ // Get the Component Name, NodeTemplate type is mapped to Component Name
+ val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
+
+ val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+ val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+ log.info("executing node template($nodeTemplateName) component($componentName) " +
+ "interface($interfaceName) operation($operationName)")
+
+ // Get the Component Instance
+ val plugin = applicationContext.getBean(componentName, AbstractComponentFunction::class.java)
+ // Set the Blueprint Service
+ plugin.bluePrintRuntimeService = bluePrintRuntimeService
+ plugin.stepName = nodeTemplateName
+
+ // Populate Step Meta Data
+ val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+ plugin.bluePrintRuntimeService.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+
+ // Get the Request from the Context and Set to the Function Input and Invoke the function
+ return withContext(Dispatchers.Default) {
+ plugin.apply(executionServiceInput)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
new file mode 100644
index 000000000..b3186e849
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2017-2018 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.apps.blueprintsprocessor.services.workflow
+
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+open class WorkflowServiceConfiguration
+
+
+class WorkflowServiceConstants {
+ companion object {
+ const val ARTIFACT_TYPE_DIRECTED_GRAPH = "artifact-directed-graph"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
new file mode 100644
index 000000000..1e856b689
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.apps.blueprintsprocessor.services.workflow.executor
+
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.NodeTemplateExecutionService
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext
+import org.onap.ccsdk.sli.core.sli.SvcLogicException
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
+ : ExecuteNodeExecutor() {
+
+ private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
+
+ @Throws(SvcLogicException::class)
+ override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext)
+ : SvcLogicNode = runBlocking {
+
+ var outValue: String
+
+ val ctx = svcLogicContext as BlueprintSvcLogicContext
+
+ val nodeTemplateName = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx)
+
+ val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+ try { // Get the Request from the Context and Set to the Function Input and Invoke the function
+ val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(ctx.getBluePrintService(),
+ nodeTemplateName, executionInput)
+
+ ctx.setResponse(executionOutput)
+
+ outValue = executionOutput.status.message
+ ctx.status = executionOutput.status.message
+
+ } catch (e: Exception) {
+ log.error("Could not execute plugin($nodeTemplateName) : ", e)
+ outValue = "failure"
+ ctx.status = "failure"
+ }
+
+ getNextNode(node, outValue)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
new file mode 100644
index 000000000..ada36ac0b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2017-2018 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.apps.blueprintsprocessor.services.workflow.utils
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser
+
+object SvcGraphUtils {
+
+ @JvmStatic
+ fun getSvcGraphFromClassPathFile(fileName: String): SvcLogicGraph {
+ val url = SvcGraphUtils::class.java.classLoader.getResource(fileName)
+ return getSvcGraphFromFile(url.path)
+ }
+
+ @JvmStatic
+ fun getSvcGraphFromFile(fileName: String): SvcLogicGraph {
+ val svcLogicParser = SvcLogicParser()
+ return svcLogicParser.parse(fileName).first
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
new file mode 100644
index 000000000..7ac9bc33d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -0,0 +1,54 @@
+/*
+ * 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.apps.blueprintsprocessor.services.workflow
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
+class BluePrintWorkflowExecutionServiceImplTest {
+
+ @Autowired
+ lateinit var bluePrintWorkflowExecutionService: BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>
+
+ @Test
+ fun testBluePrintWorkflowExecutionService() {
+
+ 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)!!
+
+ runBlocking {
+ bluePrintWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput,
+ hashMapOf())
+ }
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
new file mode 100644
index 000000000..b374e7d44
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.apps.blueprintsprocessor.services.workflow
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
+class BlueprintServiceLogicTest {
+
+ private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
+
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
+
+ @Autowired
+ lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
+
+ @Test
+ fun testExecuteGraphWithSingleComponent() {
+
+ 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)!!
+
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
+
+
+ }
+
+ @Test
+ fun testExecuteGraphWithMultipleComponents() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
+
+ }
+
+ @Test
+ fun testSingleton() {
+ val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ singleton1.stepName = "step1"
+ val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
+ }
+
+ @Test
+ fun testProtoTypeFunction() {
+ val stepName1 = "step1"
+ val stepName2 = "step2"
+ val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto1.stepName = stepName1
+
+ val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto2.stepName = stepName2
+
+ assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
+ assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
new file mode 100644
index 000000000..2e36fb5ff
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.apps.blueprintsprocessor.services.workflow
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
+class DGWorkflowExecutionServiceTest {
+
+ private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
+
+ @Autowired
+ lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
+
+
+ @Test
+ fun testExecuteDirectedGraph() {
+
+ 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)!!
+
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
+
+ }
+
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
new file mode 100644
index 000000000..4c1245621
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2017-2018 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.apps.blueprintsprocessor.services.workflow.mock
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Configuration
+open class MockComponentConfiguration {
+
+ @Bean(name = ["component-resource-resolution", "component-netconf-executor", "component-jython-executor"])
+ open fun createComponentFunction(): AbstractComponentFunction {
+ return MockComponentFunction()
+ }
+}
+
+class MockComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : $operationInputs")
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive())
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("singleton-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+class SingletonComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : $operationInputs")
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("prototype-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class PrototypeComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : $operationInputs")
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
new file mode 100644
index 000000000..d63b1d318
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "assign-activate",
+ "mode": "sync"
+ },
+ "payload": {
+ "assign-activate-request": {
+ "assign-activate-properties": {
+ "request-id": "1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
new file mode 100644
index 000000000..ce7bc8e5a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "resource-assignment",
+ "mode": "sync"
+ },
+ "payload": {
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "resource-assignment",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml
new file mode 100644
index 000000000..95947ad3e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ Copyright © 2017-2018 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>