summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-04-02 18:10:23 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-02 18:10:23 +0000
commitadd0df2429c787de6de8238f8f87eb71a26a9be7 (patch)
tree0f5b96c5c35ebe4aa30281e37ccd9278f5cc5b61 /ms
parent5e4720c9a7698ee29f74c81666b2b56bf16b46c3 (diff)
parente8db37654457e9a83136da39006e962048295cf5 (diff)
Merge "Complementary Junit test coverage"
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt27
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt49
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt42
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt75
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt64
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt64
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt68
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties18
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt61
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt7
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt31
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt62
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt48
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/PythonTestScript.py9
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt61
18 files changed, 687 insertions, 32 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index feec74058..cd51b338e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -1,7 +1,10 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ *
* Modifications Copyright © 2018 IBM.
*
+ * Modifications Copyright © 2019 IBM, Bell Canada.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -79,4 +82,28 @@ class ResourceResolutionComponentTest {
resourceResolutionComponent.applyNB(executionServiceInput)
}
}
+
+ @Test
+ fun testRecover() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceResolutionComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
+
+ resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
+ resourceResolutionComponent.stepName = "resource-assignment"
+ resourceResolutionComponent.recoverNB(RuntimeException("TEST PASSED"), executionServiceInput)
+ }
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 5ad9b3ace..4a82dbd21 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -1,7 +1,10 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ *
* Modifications Copyright © 2018 IBM.
*
+ * Modifications Copyright © 2019 IBM, Bell Canada.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -91,4 +94,50 @@ class ResourceResolutionServiceTest {
}
}
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResources() {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ val artefactNames = listOf("baseconfig", "another")
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", artefactNames, mapOf())
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResourcesWithMappingAndTemplate() {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ val artifactPrefix = "another"
+
+ // Velocity Artifact Definition Name
+ val artifactTemplate = "$artifactPrefix-template"
+ // Resource Assignment Artifact Definition Name
+ val artifactMapping = "$artifactPrefix-mapping"
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", artifactMapping, artifactTemplate)
+
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
new file mode 100644
index 000000000..22e043b11
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock
+
+import io.mockk.mockk
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+open class MockDatabaseConfiguration {
+
+ @Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration", "PrimaryDatabaseConfiguration"])
+ open fun createDatabaseConfiguration(): BluePrintDBLibGenericService {
+ return mockk<BluePrintDBLibGenericService>()
+ }
+}
+
+@Configuration
+open class MockBlueprintProcessorCatalogServiceImpl {
+
+ @Bean(name = ["blueprintProcessorCatalogServiceImpl"])
+ open fun createBlueprintProcessorCatalogServiceImpl(): BluePrintValidatorService {
+ return mockk<BluePrintValidatorService>()
+ }
+
+
+} \ No newline at end of file
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 489d971a5..2af15c2be 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
@@ -120,8 +120,8 @@ class CapabilityResourceResolutionProcessorTest {
val processorName = capabilityResourceResolutionProcessor.processNB(resourceAssignment)
assertNotNull(processorName, "couldn't get Jython script resource assignment processor name")
+ println(processorName)
}
-
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
new file mode 100644
index 000000000..f76d95a11
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintProcessorProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBlueprintProcessorCatalogServiceImpl
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockDatabaseConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+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.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DatabaseResourceAssignmentProcessor::class, BlueprintPropertyConfiguration::class,
+ BluePrintProperties::class, BluePrintDBLibPropertySevice::class, BluePrintDBLibConfiguration::class,
+ BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
+ BlueprintProcessorProperties::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class DatabaseResourceResolutionProcessorTest {
+
+ @Autowired
+ lateinit var databaseResourceAssignmentProcessor: DatabaseResourceAssignmentProcessor
+
+ @Test
+ fun `test database resource resolution`() {
+ runBlocking {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
+
+ databaseResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ databaseResourceAssignmentProcessor.resourceDictionaries = hashMapOf()
+
+ val resourceAssignment = ResourceAssignment().apply {
+ name = "rr-name"
+ dictionaryName = "rr-dict-name"
+ dictionarySource = "primary-db"
+ property = PropertyDefinition().apply {
+ type = "string"
+ }
+ }
+
+ val processorName = databaseResourceAssignmentProcessor.applyNB(resourceAssignment)
+ assertNotNull(processorName, "couldn't get Database resource assignment processor name")
+ println(processorName)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
new file mode 100644
index 000000000..093a3347a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+
+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.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+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.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DefaultResourceResolutionProcessor::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class DefaultResourceResolutionProcessorTest {
+
+ @Autowired
+ lateinit var defaultResourceResolutionProcessor: DefaultResourceResolutionProcessor
+
+ @Test
+ fun `test default resource resolution`() {
+ runBlocking {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
+
+ defaultResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ defaultResourceResolutionProcessor.resourceDictionaries = hashMapOf()
+
+ val resourceAssignment = ResourceAssignment().apply {
+ name = "rr-name"
+ dictionaryName = "rr-dict-name"
+ dictionarySource = "default"
+ property = PropertyDefinition().apply {
+ type = "string"
+ }
+ }
+
+ val processorName = defaultResourceResolutionProcessor.applyNB(resourceAssignment)
+ assertNotNull(processorName, "couldn't get Default resource assignment processor name")
+ println(processorName)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
new file mode 100644
index 000000000..68ef4d20b
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+
+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.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+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.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [InputResourceResolutionProcessor::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class InputResourceResolutionProcessorTest {
+
+ @Autowired
+ lateinit var inputResourceResolutionProcessor: InputResourceResolutionProcessor
+
+ @Test
+ fun `test input resource resolution`() {
+ runBlocking {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
+
+ inputResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ inputResourceResolutionProcessor.resourceDictionaries = hashMapOf()
+
+ val resourceAssignment = ResourceAssignment().apply {
+ name = "rr-name"
+ dictionaryName = "rr-dict-name"
+ dictionarySource = "input"
+ property = PropertyDefinition().apply {
+ type = "string"
+ }
+ }
+
+ val processorName = inputResourceResolutionProcessor.applyNB(resourceAssignment)
+ assertNotNull(processorName, "couldn't get Input resource assignment processor name")
+ println(processorName)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
new file mode 100644
index 000000000..a4636f141
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+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.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [RestResourceResolutionProcessor::class, BluePrintRestLibPropertyService::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class RestResourceResolutionProcessorTest {
+
+ @Autowired
+ lateinit var restResourceResolutionProcessor: RestResourceResolutionProcessor
+
+ @Test
+ fun `test rest resource resolution`() {
+ runBlocking {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
+
+ restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ restResourceResolutionProcessor.resourceDictionaries = hashMapOf()
+
+ val resourceAssignment = ResourceAssignment().apply {
+ name = "rr-name"
+ dictionaryName = "rr-dict-name"
+ dictionarySource = "primary-config-data"
+ property = PropertyDefinition().apply {
+ type = "string"
+ }
+ }
+
+ val processorName = restResourceResolutionProcessor.applyNB(resourceAssignment)
+ assertNotNull(processorName, "couldn't get Rest resource assignment processor name")
+ println(processorName)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
index 3f37d1b9e..071b27afc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
@@ -2,8 +2,6 @@
#
# Copyright © 2017-2018 AT&T Intellectual Property.
#
-# Modifications Copyright © 2019 IBM, Bell Canada.
-#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -16,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
blueprintsprocessor.db.primary.username=sa
blueprintsprocessor.db.primary.password=
blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
@@ -27,17 +25,7 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
# Controller Blueprints Core Configuration
blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
-
-blueprintsprocessor.restclient.primary-config-data.type=basic-auth
-blueprintsprocessor.restclient.primary-config-data.url=http://127.0.0.1:9111
-blueprintsprocessor.restclient.primary-config-data.userId=sampleuser
-blueprintsprocessor.restclient.primary-config-data.token=sampletoken
-
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
# Python executor
blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
-blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
-
-
-# CBA examples for tests cases
-controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprint
-controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/blueprint-model/test-blueprint \ No newline at end of file
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
index 2fda15906..e40efd0c4 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
@@ -1,6 +1,8 @@
/*
* Copyright (C) 2019 Bell Canada.
*
+ * Copyright (C) 2019 IBM, Bell Canada.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -21,11 +23,18 @@ import org.junit.runner.RunWith
import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCatalogServiceImpl
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
+import java.io.File
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.assertTrue
@@ -33,15 +42,29 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@EnableAutoConfiguration
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
+@ContextConfiguration(classes = [BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class,
+ MockBlueprintProcessorCatalogServiceImpl::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BlueprintProcessorCatalogServiceImplTest {
@Autowired
lateinit var blueprintCatalog: BluePrintCatalogService
+ @Autowired
+ lateinit var blueprintProcessorCatalogServiceImpl: BlueprintProcessorCatalogServiceImpl
+
+ @Autowired
+ lateinit var blueprintCoreConfiguration: BluePrintCoreConfiguration
+
+ private lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
+ private val blueprintId = "1234"
+
@BeforeTest
fun setup() {
deleteDir("target", "blueprints")
+ bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId,
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
}
@AfterTest
@@ -51,6 +74,7 @@ class BlueprintProcessorCatalogServiceImplTest {
@Test
fun `test catalog service`() {
+ //TODO: I thing this test function should be remve and replace by the other one.
runBlocking {
//FIXME("Create ZIP from test blueprints")
@@ -58,11 +82,46 @@ class BlueprintProcessorCatalogServiceImplTest {
assertTrue(file.exists(), "couldn't get file ${file.absolutePath}")
blueprintCatalog.saveToDatabase("1234", file)
-
blueprintCatalog.getFromDatabase("baseconfiguration", "1.0.0")
blueprintCatalog.deleteFromDatabase("baseconfiguration", "1.0.0")
+ }
+ }
+
+ @Test
+ fun `test save function`() {
+ runBlocking {
+ val file = normalizedFile("./src/test/resources/test-cba.zip")
+ assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+ metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId
+ blueprintProcessorCatalogServiceImpl.save(metadata, file)
+ }
+ }
+
+ @Test
+ fun `test get function`() {
+ runBlocking {
+ val file = normalizedFile("./src/test/resources/test-cba.zip")
+ assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+ metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId
+
+ blueprintProcessorCatalogServiceImpl.save(metadata, file)
+ blueprintProcessorCatalogServiceImpl.get("baseconfiguration", "1.0.0", true)
+ }
+
+ assertTrue(File(blueprintCoreConfiguration.bluePrintPathConfiguration().blueprintArchivePath +
+ "/baseconfiguration").deleteRecursively(),"Couldn't get blueprint archive " +
+ "${blueprintCoreConfiguration.bluePrintPathConfiguration().blueprintArchivePath}/baseconfiguration " +
+ "from data base.")
+ }
+
+ @Test
+ fun `test delete function`() {
+ runBlocking {
+ blueprintProcessorCatalogServiceImpl.delete("baseconfiguration", "1.0.0")
}
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
new file mode 100644
index 000000000..08de33270
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/mock/MockBlueprintProcessorCatalogServiceImpl.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.db.mock
+
+import io.mockk.mockk
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+@Configuration
+open class MockBlueprintProcessorCatalogServiceImpl {
+
+ @Bean(name = ["blueprintProcessorCatalogServiceImpl"])
+ open fun createBlueprintProcessorCatalogServiceImpl(): BluePrintValidatorService {
+ return mockk<BluePrintValidatorService>()
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index 2a4509033..586888bab 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -33,7 +33,7 @@ import java.io.File
@Service
class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
- private val applicationContext: ApplicationContext) {
+ private val applicationContext: ApplicationContext) {
val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java)
@@ -57,7 +57,6 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
BlueprintFunctionNode<*, *> {
- val blueprintBasePath: String = bluePrintContext.rootPath
val pythonFileName = bluePrintContext.rootPath
.plus(File.separator)
@@ -68,10 +67,6 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val content: String = JacksonUtils.getContent(pythonFileName)
- val pythonPath: MutableList<String> = arrayListOf()
- pythonPath.add(blueprintBasePath)
- pythonPath.addAll(pythonExecutorProperty.modulePaths)
-
val jythonInstances: MutableMap<String, Any> = hashMapOf()
jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
index 430692ce0..658b0c291 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
@@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import java.io.File
-import java.util.*
+import java.util.Properties
@Configuration
@ComponentScan
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
index c8c9f0b6a..ceb824d13 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
@@ -30,6 +30,7 @@ import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
+import kotlin.test.BeforeTest
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
@@ -38,25 +39,39 @@ import kotlin.test.assertNotNull
"blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
class BlueprintJythonServiceTest {
+ lateinit var blueprintContext: BluePrintContext
@Autowired
private lateinit var blueprintJythonService: BlueprintJythonService
+ @BeforeTest
+ fun init() {
+ blueprintContext = mockk<BluePrintContext>()
+ every { blueprintContext.rootPath } returns normalizedPathName("target")
+ }
+
@Test
fun testGetAbstractPythonPlugin() {
- val bluePrintContext = mockk<BluePrintContext>()
- every { bluePrintContext.rootPath } returns normalizedPathName("target")
-
- val dependencies: MutableMap<String, Any> = hashMapOf()
val content = JacksonUtils.getClassPathFileContent("scripts/SamplePythonComponentNode.py")
+ val dependencies: MutableMap<String, Any> = hashMapOf()
- val abstractComponentFunction = blueprintJythonService
- .jythonInstance<AbstractComponentFunction>(bluePrintContext, "SamplePythonComponentNode",
+ val abstractPythonPlugin = blueprintJythonService
+ .jythonInstance<AbstractComponentFunction>(blueprintContext, "SamplePythonComponentNode",
content, dependencies)
- assertNotNull(abstractComponentFunction, "failed to get python component")
+ assertNotNull(abstractPythonPlugin, "failed to get python component")
+
+ abstractPythonPlugin.process(ExecutionServiceInput())
+
+ }
+
+ @Test
+ fun testGetAbstractJythonComponent() {
+
+ val scriptInstance = "test-classes/scripts/SamplePythonComponentNode.py"
- abstractComponentFunction.process(ExecutionServiceInput())
+ val abstractJythonComponent = blueprintJythonService.jythonComponentInstance(blueprintContext, scriptInstance)
+ assertNotNull(abstractJythonComponent, "failed to get Jython component")
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
new file mode 100644
index 000000000..3c3efa252
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonHostTest.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+
+import org.junit.Test
+
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+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.assertNotNull
+import kotlin.test.BeforeTest
+
+@RunWith(SpringRunner::class)
+@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"])
+class BlueprintPythonHostTest {
+
+ lateinit var blueprintPythonHost: BlueprintPythonHost
+
+ @Autowired
+ lateinit var pythonExecutorProperty: PythonExecutorProperty
+
+ @BeforeTest
+ fun init() {
+ val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ val pythonPath: MutableList<String> = arrayListOf()
+ pythonPath.add(blueprintBasePath)
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+ blueprintPythonHost = BlueprintPythonHost(BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf()))
+ }
+
+ @Test
+ fun testGetPythonComponent() {
+ val content = JacksonUtils.getContent("./src/test/resources/PythonTestScript.py")
+
+ val pythonClassName = "PythonTestScript"
+ val dependencies: MutableMap<String, Any> = hashMapOf()
+
+ val pythonObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencies)
+
+ assertNotNull(pythonObject, "failed to get python object")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt
new file mode 100644
index 000000000..12ef9733a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt
@@ -0,0 +1,48 @@
+package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+import kotlin.test.assertNotNull
+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.BeforeTest
+
+@RunWith(SpringRunner::class)
+@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"])
+class BlueprintPythonInterpreterProxyTest {
+
+ lateinit var blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
+
+ @Autowired
+ lateinit var pythonExecutorProperty: PythonExecutorProperty
+
+ @BeforeTest
+ fun init() {
+ val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ val pythonPath: MutableList<String> = arrayListOf()
+ pythonPath.add(blueprintBasePath)
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
+ val pythonClassName = "PythonTestScript"
+ val content = JacksonUtils.getContent("./src/test/resources/PythonTestScript.py")
+
+ val blueprintPython = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
+ blueprintPython.content = content
+ blueprintPython.pythonClassName = pythonClassName
+ blueprintPython.moduleName = "Unit test - Blueprint Python Script [Class Name = $pythonClassName]"
+
+ blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(blueprintPython)
+ }
+
+ @Test
+ fun getPythonInterpreter() {
+ val pythonObject = blueprintPythonInterpreterProxy.getPythonInstance(hashMapOf())
+ assertNotNull(pythonObject, "failed to get python interpreter")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/PythonTestScript.py b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/PythonTestScript.py
new file mode 100644
index 000000000..42b611b88
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/PythonTestScript.py
@@ -0,0 +1,9 @@
+class PythonTestScript():
+
+ def process(self, execution_request):
+ print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
new file mode 100644
index 000000000..05cd99785
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/NodeTemplateExecutionServiceTest.kt
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2019 IBM, Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
+
+class NodeTemplateExecutionServiceTest {
+ @Autowired
+ lateinit var nodeTemplateExecutionService: NodeTemplateExecutionService
+
+ @Test
+ fun testExecuteNodeTemplate() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Assign Workflow inputs Mock
+ val input = executionServiceInput.payload.get("resource-assignment-request")
+ bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
+
+ val nodeTemplate = "resource-assignment"
+
+ val executionServiceOutput = nodeTemplateExecutionService
+ .executeNodeTemplate(bluePrintRuntimeService, nodeTemplate, executionServiceInput)
+
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
+ }
+ }
+} \ No newline at end of file