Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / python-executor / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / python / executor / scripts / BlueprintPythonHostTest.kt
1 /*
2  * Copyright © 2019 IBM, Bell Canada.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.scripts
17
18 import org.junit.Test
19 import org.junit.runner.RunWith
20 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
21 import org.springframework.beans.factory.annotation.Autowired
22 import org.springframework.test.context.ContextConfiguration
23 import org.springframework.test.context.TestPropertySource
24 import org.springframework.test.context.junit4.SpringRunner
25 import kotlin.test.BeforeTest
26 import kotlin.test.assertNotNull
27
28 @RunWith(SpringRunner::class)
29 @ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::class])
30 @TestPropertySource(
31     properties =
32         [
33             "blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
34             "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"
35         ]
36 )
37 class BlueprintPythonHostTest {
38
39     lateinit var blueprintPythonHost: BlueprintPythonHost
40
41     @Autowired
42     lateinit var pythonExecutorProperty: PythonExecutorProperty
43
44     @BeforeTest
45     fun init() {
46         val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
47         val pythonPath: MutableList<String> = arrayListOf()
48         pythonPath.add(blueprintBasePath)
49         pythonPath.addAll(pythonExecutorProperty.modulePaths)
50
51         blueprintPythonHost = BlueprintPythonHost(BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf()))
52     }
53
54     @Test
55     fun testGetPythonComponent() {
56         val content = JacksonUtils.getContent("./src/test/resources/PythonTestScript.py")
57
58         val pythonClassName = "PythonTestScript"
59         val dependencies: MutableMap<String, Any> = hashMapOf()
60
61         val pythonObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencies)
62
63         assertNotNull(pythonObject, "failed to get python object")
64     }
65 }