Remove service annotation for ImperativeBluePrintWorkflowService
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / services / workflow-service / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / services / workflow / ImperativeWorkflowExecutionServiceTest.kt
index becd228..c200f4a 100644 (file)
@@ -17,6 +17,7 @@
 package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
 
 import io.mockk.every
+import io.mockk.mockk
 import io.mockk.mockkObject
 import io.mockk.unmockkAll
 import kotlinx.coroutines.runBlocking
@@ -26,6 +27,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeComponentScriptExecutor
 import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction
 import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.mockNodeTemplateComponentScriptExecutor
+import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
@@ -36,6 +39,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyS
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import kotlin.test.Test
+import kotlin.test.assertEquals
 import kotlin.test.assertNotNull
 
 class ImperativeWorkflowExecutionServiceTest {
@@ -53,18 +57,36 @@ class ImperativeWorkflowExecutionServiceTest {
     }
 
     fun mockServiceTemplate(): ServiceTemplate {
-        return serviceTemplate("imperative-test", "1.0.0",
-                "brindasanth@onap.com", "tosca") {
+        return serviceTemplate(
+            "imperative-test", "1.0.0",
+            "brindasanth@onap.com", "tosca"
+        ) {
 
             topologyTemplate {
-                nodeTemplate(mockNodeTemplateComponentScriptExecutor("resolve-config",
-                        "cba.wt.imperative.test.ResolveConfig"))
-                nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config",
-                        "cba.wt.imperative.test.ActivateConfig"))
-                nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-config-rollback",
-                        "cba.wt.imperative.test.ActivateConfigRollback"))
-                nodeTemplate(mockNodeTemplateComponentScriptExecutor("activate-licence",
-                        "cba.wt.imperative.test.ActivateLicence"))
+                nodeTemplate(
+                    mockNodeTemplateComponentScriptExecutor(
+                        "resolve-config",
+                        "cba.wt.imperative.test.ResolveConfig"
+                    )
+                )
+                nodeTemplate(
+                    mockNodeTemplateComponentScriptExecutor(
+                        "activate-config",
+                        "cba.wt.imperative.test.ActivateConfig"
+                    )
+                )
+                nodeTemplate(
+                    mockNodeTemplateComponentScriptExecutor(
+                        "activate-config-rollback",
+                        "cba.wt.imperative.test.ActivateConfigRollback"
+                    )
+                )
+                nodeTemplate(
+                    mockNodeTemplateComponentScriptExecutor(
+                        "activate-licence",
+                        "cba.wt.imperative.test.ActivateLicence"
+                    )
+                )
 
                 workflow("imperative-test-wf", "Test Imperative flow") {
                     step("resolve-config", "resolve-config", "") {
@@ -92,14 +114,18 @@ class ImperativeWorkflowExecutionServiceTest {
             val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("12345", bluePrintContext)
 
             val executionServiceInput = JacksonUtils
-                    .readValueFromClassPathFile("execution-input/imperative-test-input.json",
-                            ExecutionServiceInput::class.java)!!
+                .readValueFromClassPathFile(
+                    "execution-input/imperative-test-input.json",
+                    ExecutionServiceInput::class.java
+                )!!
 
-            val bluePrintWorkFlowService = ImperativeBluePrintWorkflowService(NodeTemplateExecutionService())
-            val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(bluePrintWorkFlowService)
+            val imperativeWorkflowExecutionService = ImperativeWorkflowExecutionService(NodeTemplateExecutionService(mockk()))
             val output = imperativeWorkflowExecutionService
-                    .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
-            assertNotNull(output)
+                .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+            assertNotNull(output, "failed to get imperative workflow output")
+            assertNotNull(output.status, "failed to get imperative workflow output status")
+            assertEquals(output.status.message, BluePrintConstants.STATUS_SUCCESS)
+            assertEquals(output.status.eventType, EventType.EVENT_COMPONENT_EXECUTED.name)
         }
     }
-}
\ No newline at end of file
+}