From ba75d2fad2b0111a510f4ee4cc87e658fb32ac4b Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 31 Dec 2019 10:53:59 -0500 Subject: 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 Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7 --- .../execution/ComponentRemoteScriptExecutorTest.kt | 52 +++++++++++------- .../execution/ComponentScriptExecutorDSLTest.kt | 62 ++++++++++++++++++++++ 2 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSLTest.kt (limited to 'ms/blueprintsprocessor/modules/services/execution-service/src/test') 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>() + 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)" + ) + } +} -- cgit 1.2.3-korg