aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2019-07-19 13:26:14 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2019-07-19 13:26:14 -0400
commit257dff5659f752d98dfe9421e9761aa5d84bd294 (patch)
treedeef619c4c90a6947c884819e5c46ce0548c6c32 /ms/controllerblueprints/modules/blueprint-core/src/test/kotlin
parentb52a648f3c77a495539d64bba1e43fcbbdaa0364 (diff)
Improve service template access through cache.
Change-Id: Ibcff2a27f338c6fd019545dac5457943eff4b024 Issue-ID: CCSDK-1503 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test/kotlin')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt16
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt21
2 files changed, 36 insertions, 1 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt
index 9d4ef69bb..66fec7553 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +20,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts
import kotlinx.coroutines.runBlocking
import org.junit.Test
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import kotlin.script.experimental.jvm.util.classpathFromClass
@@ -51,10 +54,21 @@ class BluePrintScriptsServiceImplTest {
val bluePrintScriptsService = BluePrintScriptsServiceImpl()
val basePath = normalizedPathName("src/test/resources/compile")
+ /** Load the Definitions */
+ val bluePrintDefinitions = bluePrintScriptsService
+ .scriptInstance<BluePrintDefinitions>(basePath,
+ "cba.scripts.ActivateBlueprintDefinitions", true)
+ assertNotNull(bluePrintDefinitions, "failed to get blueprint definitions")
+
+ val serviceTemplate = bluePrintDefinitions.serviceTemplate()
+ assertNotNull(serviceTemplate, "failed to get service template")
+
+ val customDataType = bluePrintDefinitions.otherDefinition<DataType>("datatype-custom-datatype")
+ assertNotNull(customDataType, "failed to get custom definitions")
val instance = bluePrintScriptsService
.scriptInstance<BlueprintFunctionNode<String, String>>(basePath,
- "cba.scripts.SampleBlueprintFunctionNode", true)
+ "cba.scripts.SampleBlueprintFunctionNode", false)
assertNotNull(instance, "failed to get compiled instance")
val cachedInstance = bluePrintScriptsService
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
index 1a6ccfa17..6c0c30e3d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
@@ -21,9 +21,12 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
+import kotlin.test.assertTrue
class BluePrintMetadataUtilsTest {
@@ -45,6 +48,24 @@ class BluePrintMetadataUtilsTest {
}
@Test
+ fun testKotlinBluePrintContext() {
+ val path = normalizedPathName("src/test/resources/compile")
+ val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path)
+ assertNotNull(blueprintContext, "failed to get blueprint context")
+ assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+ assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+ assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions")
+
+ var cachePresent = BluePrintCompileCache.hasClassLoader(path)
+ assertTrue(cachePresent, "failed to generate cache key ($path)")
+
+ /** Cleaning Cache */
+ BluePrintCompileCache.cleanClassLoader(path)
+ cachePresent = BluePrintCompileCache.hasClassLoader(path)
+ assertTrue(!cachePresent, "failed to remove cache key ($path)")
+ }
+
+ @Test
fun environmentDataTest() {
val environmentPath = "./src/test/resources/environments"