From 3365c01de8515e0ea7a0c26fbdfb296661bf6b92 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Dec 2018 20:53:22 -0500 Subject: Add Netconf Executor Function module Change-Id: If264e63d4fc4305bc26dc6b249a462afefcbfe1e Issue-ID: CCSDK-790 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../services/workflow/BlueprintServiceLogicTest.kt | 29 +++++++++++++++++++ .../workflow/mock/MockComponentFunction.kt | 33 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'ms/blueprintsprocessor/modules/services') 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 index 2c1c40c9..7312d2de 100644 --- 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 @@ -20,12 +20,16 @@ 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]) @@ -33,6 +37,9 @@ class BlueprintServiceLogicTest { private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java) + @Autowired + lateinit var applicationContext: ApplicationContext + @Autowired lateinit var blueprintDGExecutionService: BlueprintDGExecutionService @@ -61,4 +68,26 @@ class BlueprintServiceLogicTest { } + @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/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt index 9f7a9c97..1d738eef 100644 --- 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 @@ -20,8 +20,11 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp 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 { @@ -43,6 +46,36 @@ class MockComponentFunction : AbstractComponentFunction() { "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..") } -- cgit 1.2.3-korg