2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Modifications Copyright © 2019 IBM, Bell Canada.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
21 import com.fasterxml.jackson.databind.JsonNode
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.resource.resolution.ResourceResolutionServiceImpl
26 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
27 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
28 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
29 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
30 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
31 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
32 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
33 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
34 import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
35 import org.springframework.beans.factory.annotation.Autowired
36 import org.springframework.test.context.ContextConfiguration
37 import org.springframework.test.context.TestPropertySource
38 import org.springframework.test.context.junit4.SpringRunner
40 @RunWith(SpringRunner::class)
41 @ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
42 BluePrintScriptsServiceImpl::class, ComponentFunctionScriptingService::class,
43 ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
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 class ComponentNetconfExecutorTest {
50 lateinit var componentNetconfExecutor: ComponentNetconfExecutor
54 fun testComponentNetconfExecutor() {
56 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
57 ExecutionServiceInput::class.java)!!
59 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
60 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
62 val executionContext = bluePrintRuntimeService.getExecutionContext()
65 componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
67 //TODO("Set Attribute properties")
68 val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
69 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf")
70 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor")
71 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
72 // Set Step Inputs in Blueprint Runtime Service
73 bluePrintRuntimeService.put("activate-netconf-step-inputs", stepMetaData.asJsonNode())
75 componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
76 componentNetconfExecutor.stepName = "activate-netconf"
77 componentNetconfExecutor.apply(executionServiceInput)