2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Modifications Copyright © 2019 IBM, Bell Canada.
5 * Modifications Copyright © 2019 IBM.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
22 import com.fasterxml.jackson.databind.JsonNode
23 import kotlinx.coroutines.runBlocking
25 import org.junit.runner.RunWith
26 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
27 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
28 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
29 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
30 import org.onap.ccsdk.cds.controllerblueprints.core.putJsonElement
31 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
32 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
33 import org.springframework.beans.factory.annotation.Autowired
34 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
35 import org.springframework.context.annotation.ComponentScan
36 import org.springframework.test.annotation.DirtiesContext
37 import org.springframework.test.context.TestPropertySource
38 import org.springframework.test.context.junit4.SpringRunner
40 @RunWith(SpringRunner::class)
41 @EnableAutoConfiguration
42 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
44 @TestPropertySource(properties =
45 ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
46 "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"],
47 locations = ["classpath:application-test.properties"])
48 class ComponentNetconfExecutorTest {
51 lateinit var componentNetconfExecutor: ComponentNetconfExecutor
55 fun testComponentNetconfExecutor() {
58 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
59 ExecutionServiceInput::class.java)!!
61 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
62 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
64 val executionContext = bluePrintRuntimeService.getExecutionContext()
67 componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
69 //TODO("Set Attribute properties")
70 val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
71 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf")
72 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor")
73 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
74 // Set Step Inputs in Blueprint Runtime Service
75 componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
76 val stepInputData = StepData().apply {
77 name = "activate-netconf"
78 properties = stepMetaData
80 executionServiceInput.stepData = stepInputData
81 componentNetconfExecutor.applyNB(executionServiceInput)