2 * Copyright © 2017-2018 AT&T Intellectual Property.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
19 import com.fasterxml.jackson.databind.JsonNode
20 import com.fasterxml.jackson.databind.node.JsonNodeFactory
22 import org.junit.runner.RunWith
23 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
24 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
25 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
26 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
27 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
28 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
29 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
30 import org.springframework.beans.factory.annotation.Autowired
31 import org.springframework.test.context.ContextConfiguration
32 import org.springframework.test.context.TestPropertySource
33 import org.springframework.test.context.junit4.SpringRunner
35 @RunWith(SpringRunner::class)
36 @ContextConfiguration(classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class])
37 @TestPropertySource(properties =
38 ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
39 "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
40 class ComponentJythonExecutorTest {
43 lateinit var componentJythonExecutor: ComponentJythonExecutor
46 fun testPythonComponentInjection() {
47 val executionServiceInput = ExecutionServiceInput()
48 executionServiceInput.payload = JsonNodeFactory.instance.objectNode()
50 val commonHeader = CommonHeader()
51 commonHeader.requestId = "1234"
52 executionServiceInput.commonHeader = commonHeader
54 val actionIdentifiers = ActionIdentifiers()
55 actionIdentifiers.blueprintName = "baseconfiguration"
56 actionIdentifiers.blueprintVersion = "1.0.0"
57 actionIdentifiers.actionName = "activate"
58 executionServiceInput.actionIdentifiers = actionIdentifiers
61 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
62 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
64 val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
65 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
66 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
67 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
68 bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
70 componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
71 componentJythonExecutor.stepName = "activate-jython"
74 componentJythonExecutor.apply(executionServiceInput)