summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/execution-service/src
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
committerBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
commitba75d2fad2b0111a510f4ee4cc87e658fb32ac4b (patch)
tree92c50b5bea79bb6c424aab6b0ac2e805a9e36e07 /ms/blueprintsprocessor/modules/services/execution-service/src
parent1fdaf4953daf15970afe6ee10491dfa2d0a76753 (diff)
Flexible DSL Types and Templates definition.
Easy search definitions Types and Templates inside ServiceTemplate DSL builder. Unit test modifications to support this change. Issue-ID: CCSDK-1054 Signed-off-by: Brinda Santh <bs2796@att.com> Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/execution-service/src')
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt23
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt30
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt52
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt62
4 files changed, 142 insertions, 25 deletions
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
index 0210e88ea..7bb071501 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorDSL.kt
@@ -25,9 +25,16 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.ServiceTemplateBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.TopologyTemplateBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
/** Component Extensions **/
+fun ServiceTemplateBuilder.nodeTypeComponentRemoteScriptExecutor() {
+ val nodeType = BluePrintTypes.nodeTypeComponentRemoteScriptExecutor()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType {
return nodeType(
@@ -86,12 +93,24 @@ fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType {
}
/** Component Builder */
+fun TopologyTemplateBuilder.nodeTemplateComponentRemoteScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit
+) {
+ val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
+ id, description,
+ block
+ )
+ if (nodeTemplates == null) nodeTemplates = hashMapOf()
+ nodeTemplates!![nodeTemplate.id!!] = nodeTemplate
+}
+
fun BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
id: String,
description: String,
block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit
-):
- NodeTemplate {
+): NodeTemplate {
return ComponentRemoteScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
index d4ca0f487..8592ce62b 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
@@ -25,10 +25,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.ServiceTemplateBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.TopologyTemplateBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
import kotlin.reflect.KClass
/** Component Extensions **/
+fun ServiceTemplateBuilder.nodeTypeComponentScriptExecutor() {
+ val nodeType = BluePrintTypes.nodeTypeComponentScriptExecutor()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
return nodeType(
@@ -80,19 +87,31 @@ fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
}
/** Component Builder */
+fun TopologyTemplateBuilder.nodeTemplateComponentScriptExecutor(
+ id: String,
+ description: String,
+ block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
+) {
+ val nodeTemplate = BluePrintTypes.nodeTemplateComponentScriptExecutor(
+ id, description,
+ block
+ )
+ if (nodeTemplates == null) nodeTemplates = hashMapOf()
+ nodeTemplates!![nodeTemplate.id!!] = nodeTemplate
+}
+
fun BluePrintTypes.nodeTemplateComponentScriptExecutor(
id: String,
description: String,
block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit
-):
- NodeTemplate {
+): NodeTemplate {
return ComponentScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String) :
AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
- ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
+ ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
id, "component-script-executor",
"ComponentScriptExecutor",
description
@@ -110,7 +129,8 @@ class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String
scriptClassReference(scriptClassReference.qualifiedName!!)
}
- fun scriptClassReference(scriptClassReference: String) = scriptClassReference(scriptClassReference.asJsonPrimitive())
+ fun scriptClassReference(scriptClassReference: String) =
+ scriptClassReference(scriptClassReference.asJsonPrimitive())
fun scriptClassReference(scriptClassReference: JsonNode) {
property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, scriptClassReference)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
index 2091e0366..0125cd8d9 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentRemoteScriptExecutorTest.kt
@@ -36,6 +36,7 @@ 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.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
@@ -54,26 +55,41 @@ class ComponentRemoteScriptExecutorTest {
@Test
fun testNodeTemplateComponentRemoteScriptExecutor() {
- val nodeTemplate = BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
- "remote-sample",
- "This is sample node template"
- ) {
- definedOperation(" Sample Operation") {
- implementation(180, "SELF")
- inputs {
- selector("remote-script-executor")
- blueprintName("sample")
- blueprintVersion("1.0.0")
- blueprintAction("sample-action")
- timeout(120)
- requestData("""{"key" :"value"}""")
- }
- outputs {
- status("success")
+ val serviceTemplate = serviceTemplate("remote-script-dsl", "1.0.0", "xx@xx.com", "remote-script-ds") {
+ topologyTemplate {
+ nodeTemplateComponentRemoteScriptExecutor(
+ "remote-sample",
+ "This is sample node template"
+ ) {
+ definedOperation(" Sample Operation") {
+ implementation(180, "SELF")
+ inputs {
+ selector("remote-script-executor")
+ blueprintName("sample")
+ blueprintVersion("1.0.0")
+ blueprintAction("sample-action")
+ timeout(120)
+ requestData("""{"key" :"value"}""")
+ }
+ outputs {
+ status("success")
+ }
+ }
}
}
+ nodeTypeComponentRemoteScriptExecutor()
}
- assertNotNull(nodeTemplate, "failed to generate nodeTemplate Component Remote Script Executor")
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate, "failed to service template")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to service template node Types")
+ assertNotNull(
+ serviceTemplate.nodeTypes!!["component-remote-script-executor"],
+ "failed to service template nodeType(component-remote-script-executor)"
+ )
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates?.get("remote-sample"),
+ "failed to nodeTemplate(remote-sample)"
+ )
}
@Test
@@ -95,7 +111,7 @@ class ComponentRemoteScriptExecutorTest {
val mockStreamingRemoteExecutionService = mockk<StreamingRemoteExecutionService<
org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput,
- org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput>>()
+ ExecutionServiceOutput>>()
coEvery {
mockStreamingRemoteExecutionService.sendNonInteractive(
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt
new file mode 100644
index 000000000..6f957e666
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2018-2019 AT&T Intellectual Property.
+ *
+ * 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
+
+import org.junit.Test
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
+import kotlin.test.assertNotNull
+
+class ComponentScriptExecutorDSLTest {
+
+ @Test
+ fun nodeTemplateComponentScriptExecutor() {
+
+ val serviceTemplate = serviceTemplate("remote-script-dsl", "1.0.0", "xx@xx.com", "remote-script-ds") {
+ topologyTemplate {
+ nodeTemplateComponentScriptExecutor(
+ "script-sample",
+ "This is sample node template"
+ ) {
+ definedOperation(" Sample Operation") {
+ implementation(180, "SELF")
+ inputs {
+ type("kotlin")
+ scriptClassReference("cba.sample.Processor")
+ dynamicProperties("*dynamic-inputs")
+ }
+ outputs {
+ status("success")
+ }
+ }
+ }
+ }
+ nodeTypeComponentScriptExecutor()
+ }
+
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate, "failed to service template")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to service template node Types")
+ assertNotNull(
+ serviceTemplate.nodeTypes!!["component-script-executor"],
+ "failed to service template nodeType(component-script-executor)"
+ )
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates?.get("script-sample"),
+ "failed to nodeTemplate(script-sample)"
+ )
+ }
+}