2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock
19 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
20 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
21 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
22 import org.slf4j.LoggerFactory
23 import org.springframework.beans.factory.config.ConfigurableBeanFactory
24 import org.springframework.context.annotation.Bean
25 import org.springframework.context.annotation.Configuration
26 import org.springframework.context.annotation.Scope
27 import org.springframework.stereotype.Component
30 open class MockComponentConfiguration {
32 @Bean(name = ["component-resource-resolution", "component-netconf-executor", "component-jython-executor"])
33 open fun createComponentFunction(): AbstractComponentFunction {
34 return MockComponentFunction()
38 class MockComponentFunction : AbstractComponentFunction() {
40 private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
42 override fun process(executionRequest: ExecutionServiceInput) {
43 log.info("Processing component : $operationInputs")
45 bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
46 "assignment-params", "params".asJsonPrimitive())
49 override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
50 log.info("Recovering component..")
54 @Component("singleton-function")
55 @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
56 class SingletonComponentFunction : AbstractComponentFunction() {
58 private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
60 override fun process(executionRequest: ExecutionServiceInput) {
61 log.info("Processing component : $operationInputs")
64 override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
65 log.info("Recovering component..")
69 @Component("prototype-function")
70 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
71 class PrototypeComponentFunction : AbstractComponentFunction() {
73 private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
75 override fun process(executionRequest: ExecutionServiceInput) {
76 log.info("Processing component : $operationInputs")
79 override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
80 log.info("Recovering component..")