From 1072867dfac0df993cbd3e44bcc11a5cac7465fd Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Tue, 22 Sep 2020 12:16:46 -0400 Subject: Enabling Code Formatter Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8 --- .../python/executor/ComponentJythonExecutorTest.kt | 12 +- .../ComponentRemotePythonExecutorDSLTest.kt | 3 +- .../executor/ComponentRemotePythonExecutorTest.kt | 201 +++++++++++---------- .../executor/scripts/BlueprintPythonHostTest.kt | 6 +- 4 files changed, 115 insertions(+), 107 deletions(-) (limited to 'ms/blueprintsprocessor/functions/python-executor/src/test') diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt index 784c6b7ff..d5fa0b20c 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt @@ -37,13 +37,17 @@ import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class, - ComponentJythonExecutor::class, MockInstanceConfiguration::class] + classes = [ + PythonExecutorConfiguration::class, PythonExecutorProperty::class, + ComponentJythonExecutor::class, MockInstanceConfiguration::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"] + [ + "blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints", + "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints" + ] ) class ComponentJythonExecutorTest { diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt index 5e77937bc..46a3120d5 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSLTest.kt @@ -44,7 +44,8 @@ class ComponentRemotePythonExecutorDSLTest { "prop1" : "1234", "prop2" : true, "prop3" : 23 - }""".trimIndent() + } + """.trimIndent() ) argumentProperties("""["one", "two"]""") packages { diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt index d4edf4bb2..0a0d1659e 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt @@ -49,8 +49,8 @@ class ComponentRemotePythonExecutorTest { val remoteScriptExecutionService = MockRemoteScriptExecutionService() val componentRemotePythonExecutor = ComponentRemotePythonExecutor( - remoteScriptExecutionService, - mockk() + remoteScriptExecutionService, + mockk() ) val executionServiceInput = @@ -93,8 +93,8 @@ class ComponentRemotePythonExecutorTest { runBlocking { val remoteScriptExecutionService = MockRemoteScriptExecutionService() val componentRemotePythonExecutor = ComponentRemotePythonExecutor( - remoteScriptExecutionService, - mockk() + remoteScriptExecutionService, + mockk() ) val bluePrintRuntime = mockk("123456-1000") @@ -112,113 +112,114 @@ class ComponentRemotePythonExecutorTest { */ fun getMockedOutput(svc: DefaultBluePrintRuntimeService): ExecutionServiceInput { - val stepMetaData: MutableMap = hashMapOf() - - stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, - "execute-remote-python" - ) - stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_INTERFACE, - "ComponentRemotePythonExecutor" - ) - stepMetaData.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process" - ) - - val mapper = ObjectMapper() - val rootNode = mapper.createObjectNode() - rootNode.put("ip-address", "0.0.0.0") - rootNode.put("type", "rest") - - val operationalInputs: MutableMap = hashMapOf() - operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, - "execute-remote-python" - ) - operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_INTERFACE, - "ComponentRemotePythonExecutor" - ) - operationalInputs.putJsonElement( - BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process" - ) - operationalInputs.putJsonElement("endpoint-selector", "aai") - operationalInputs.putJsonElement("dynamic-properties", rootNode) - operationalInputs.putJsonElement("command", "./run.sh") - operationalInputs.putJsonElement("packages", "py") - - every { - svc.resolveNodeTemplateInterfaceOperationInputs( - "execute-remote-python", - "ComponentRemotePythonExecutor", "process" - ) - } returns operationalInputs - - val stepInputData = StepData().apply { - name = "execute-remote-python" - properties = stepMetaData - } - - val executionServiceInput = JacksonUtils - .readValueFromClassPathFile( - "payload/requests/sample-remote-python-request.json", - ExecutionServiceInput::class.java - )!! - executionServiceInput.stepData = stepInputData + val stepMetaData: MutableMap = hashMapOf() - val operationOutputs = hashMapOf() - every { - svc.resolveNodeTemplateInterfaceOperationOutputs( - "execute-remote-python", - "ComponentRemotePythonExecutor", "process" + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python" ) - } returns operationOutputs - val bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime( - "123456-1000", - "./../../../../components/model-" + - "catalog/blueprint-model/test-blueprint/" + - "remote_scripts" - ) - every { - svc.resolveNodeTemplateArtifactDefinition( - "execute-remote-python", "component-script" + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor" ) - } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition( - "execute-remote-python", "component-script" - ) - every { - svc.setNodeTemplateAttributeValue( - "execute-remote-python", "prepare-environment-logs", - "prepared successfully".asJsonPrimitive() + stepMetaData.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process" ) - } returns Unit - every { - svc.setNodeTemplateAttributeValue( - "execute-remote-python", - "execute-command-logs", "N/A".asJsonPrimitive() + + val mapper = ObjectMapper() + val rootNode = mapper.createObjectNode() + rootNode.put("ip-address", "0.0.0.0") + rootNode.put("type", "rest") + + val operationalInputs: MutableMap = hashMapOf() + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, + "execute-remote-python" ) - } returns Unit - every { - svc.setNodeTemplateAttributeValue( - "execute-remote-python", - "execute-command-logs", - "processed successfully".asJsonPrimitive() + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_INTERFACE, + "ComponentRemotePythonExecutor" ) - } returns Unit + operationalInputs.putJsonElement( + BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process" + ) + operationalInputs.putJsonElement("endpoint-selector", "aai") + operationalInputs.putJsonElement("dynamic-properties", rootNode) + operationalInputs.putJsonElement("command", "./run.sh") + operationalInputs.putJsonElement("packages", "py") + + every { + svc.resolveNodeTemplateInterfaceOperationInputs( + "execute-remote-python", + "ComponentRemotePythonExecutor", "process" + ) + } returns operationalInputs - every { - svc.resolveDSLExpression("aai") - } returns """{"url" : "http://xxx.com"}""".asJsonType() + val stepInputData = StepData().apply { + name = "execute-remote-python" + properties = stepMetaData + } - every { - svc.bluePrintContext() - } returns bluePrintRuntimeService.bluePrintContext() - return executionServiceInput - } + val executionServiceInput = JacksonUtils + .readValueFromClassPathFile( + "payload/requests/sample-remote-python-request.json", + ExecutionServiceInput::class.java + )!! + executionServiceInput.stepData = stepInputData + + val operationOutputs = hashMapOf() + every { + svc.resolveNodeTemplateInterfaceOperationOutputs( + "execute-remote-python", + "ComponentRemotePythonExecutor", "process" + ) + } returns operationOutputs + val bluePrintRuntimeService = BluePrintMetadataUtils.bluePrintRuntime( + "123456-1000", + "./../../../../components/model-" + + "catalog/blueprint-model/test-blueprint/" + + "remote_scripts" + ) + every { + svc.resolveNodeTemplateArtifactDefinition( + "execute-remote-python", "component-script" + ) + } returns bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition( + "execute-remote-python", "component-script" + ) + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", "prepare-environment-logs", + "prepared successfully".asJsonPrimitive() + ) + } returns Unit + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", + "execute-command-logs", "N/A".asJsonPrimitive() + ) + } returns Unit + every { + svc.setNodeTemplateAttributeValue( + "execute-remote-python", + "execute-command-logs", + "processed successfully".asJsonPrimitive() + ) + } returns Unit + + every { + svc.resolveDSLExpression("aai") + } returns """{"url" : "http://xxx.com"}""".asJsonType() + + every { + svc.bluePrintContext() + } returns bluePrintRuntimeService.bluePrintContext() + return executionServiceInput + } } class MockRemoteScriptExecutionService : RemoteScriptExecutionService { + override suspend fun init(selector: Any) { } diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHostTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHostTest.kt index bec8ccae7..0efaaa113 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHostTest.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/scripts/BlueprintPythonHostTest.kt @@ -29,8 +29,10 @@ import kotlin.test.assertNotNull @ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::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"] + [ + "blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints", + "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints" + ] ) class BlueprintPythonHostTest { -- cgit 1.2.3-korg