aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-10-29 17:10:32 -0400
committerBrinda Santh <bs2796@att.com>2019-10-29 17:10:32 -0400
commitf0ad7cdc6f99b03cba9dcbb38e9116128a1f6d81 (patch)
tree1b3f030cef23b8f2c6e6cb69b70a0719ff5e496e /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test
parent8a26b031f8980b2a93b51e5327df959c6926c034 (diff)
Add remote service function execution.
Issue-ID: CCSDK-1875 Signed-off-by: Brinda Santh <bs2796@att.com> Change-Id: I18279b1d2ff1a0b2962afa74fc616bfd99e93c91
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt84
1 files changed, 84 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
new file mode 100644
index 000000000..293da0da6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
@@ -0,0 +1,84 @@
+/*
+ * 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.selfservice.api
+
+import io.mockk.mockk
+import kotlinx.coroutines.runBlocking
+import org.junit.Before
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.Test
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [MockServiceAction::class])
+class ExecutionServiceHandlerTest {
+
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
+
+ @Before
+ fun init() {
+ BluePrintDependencyService.inject(applicationContext)
+ }
+
+ @Test
+ fun testExecuteServiceFunction() {
+ val executionServiceInput = ExecutionServiceInput().apply {
+ commonHeader = CommonHeader().apply {
+ requestId = "1234"
+ subRequestId = "1234-12"
+ originatorId = "cds-test"
+ }
+ actionIdentifiers = ActionIdentifiers().apply {
+ blueprintName = "default"
+ blueprintVersion = "1.0.0"
+ actionName = "mock-service-action"
+ }
+ }
+ runBlocking {
+ val executionServiceHandler = ExecutionServiceHandler(mockk(), mockk(), mockk())
+ val isServiceFunction = executionServiceHandler.checkServiceFunction(executionServiceInput)
+ assertTrue(isServiceFunction, "failed to checkServiceFunction")
+ val executionServiceOutput = executionServiceHandler.executeServiceFunction(executionServiceInput)
+ assertNotNull(executionServiceOutput, "failed to get executionServiceOutput")
+ }
+ }
+}
+
+@Service("mock-service-action")
+class MockServiceAction : AbstractServiceFunction() {
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ val responsePayload = """{"answer" : "correct"}""".jsonAsJsonType()
+ setResponsePayloadForAction(responsePayload)
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+
+ }
+} \ No newline at end of file