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