From a30e1864fadad70c797ca1248a3c1272300a6e2b Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 19 Nov 2019 14:23:44 -0500 Subject: Separate jython implementation and dependencies. Refactored cds python capabilities to python-executor function, so that it will easy to disable and deprecation This change is not jython depreciation, just separating out Issue-ID: CCSDK-1865 Signed-off-by: Brinda Santh Change-Id: I3727d72d7195c49d670c30a6fc4245f5a8599e3a --- .../CapabilityResourceResolutionProcessorTest.kt | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt index 8f6ac9fd5..d84488d76 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt @@ -24,46 +24,25 @@ import io.mockk.every import io.mockk.mockk import kotlinx.coroutines.runBlocking import org.junit.Test -import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceAssignment import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue -@RunWith(SpringRunner::class) -@ContextConfiguration( - classes = [CapabilityResourceResolutionProcessor::class, ComponentFunctionScriptingService::class, - BluePrintScriptsServiceImpl::class, - BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class] -) -@TestPropertySource( - properties = - ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints", - "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"] -) class CapabilityResourceResolutionProcessorTest { - @Autowired - lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor - @Test fun `test kotlin capability`() { runBlocking { @@ -111,8 +90,17 @@ class CapabilityResourceResolutionProcessorTest { "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_python" ) + val componentFunctionScriptingService = mockk() + coEvery { + componentFunctionScriptingService + .scriptInstance(any(), BluePrintConstants.SCRIPT_JYTHON, any()) + } returns MockCapabilityScriptRA() + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) + val capabilityResourceResolutionProcessor = + CapabilityResourceResolutionProcessor(componentFunctionScriptingService) + capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService val resourceDefinition = JacksonUtils @@ -154,6 +142,11 @@ open class MockCapabilityScriptRA : ResourceAssignmentProcessor() { executionRequest.property!!.value = "assigned-data".asJsonPrimitive() } + override fun process(executionRequest: ResourceAssignment) { + log.info("executing RA mock capability : ${executionRequest.name}") + executionRequest.property!!.value = "assigned-data".asJsonPrimitive() + } + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { TODO("not implemented") // To change body of created functions use File | Settings | File Templates. } -- cgit 1.2.3-korg