5b7b14ad07e3f136ccb6a94f7e1b6357db07fc4e
[ccsdk/cds.git] /
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.apps.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.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
25 import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
26 import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
27 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
28 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
29 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
30 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
31 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
32 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
33 import org.springframework.beans.factory.annotation.Autowired
34 import org.springframework.test.context.ContextConfiguration
35 import org.springframework.test.context.TestPropertySource
36 import org.springframework.test.context.junit4.SpringRunner
37
38 @RunWith(SpringRunner::class)
39 @ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
40     ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
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 class ComponentNetconfExecutorTest {
45
46     @Autowired
47     lateinit var componentNetconfExecutor: ComponentNetconfExecutor
48
49
50     @Test
51     fun testComponentNetconfExecutor() {
52
53         val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
54             ExecutionServiceInput::class.java)!!
55
56         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
57             "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
58
59         val executionContext = bluePrintRuntimeService.getExecutionContext()
60
61
62         componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
63
64
65         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
66         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf")
67         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor")
68         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
69         // Set Step Inputs in Blueprint Runtime Service
70         bluePrintRuntimeService.put("activate-netconf-step-inputs", stepMetaData.asJsonNode())
71
72         componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
73         componentNetconfExecutor.stepName = "activate-netconf"
74         componentNetconfExecutor.apply(executionServiceInput)
75
76     }
77 }
78