summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/services/workflow-service/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/workflow-service/src/test')
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt49
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt56
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/imperative-test-input.json4
3 files changed, 70 insertions, 39 deletions
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
index 3c740725e..436de1b56 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -16,12 +16,17 @@
package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
+import io.mockk.every
+import io.mockk.mockkObject
+import io.mockk.unmockkAll
import kotlinx.coroutines.runBlocking
+import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.MockComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
@@ -29,7 +34,6 @@ 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 org.springframework.beans.factory.annotation.Autowired
-import org.springframework.context.ApplicationContext
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertEquals
@@ -42,31 +46,52 @@ import kotlin.test.assertNotNull
class BluePrintWorkflowExecutionServiceImplTest {
@Autowired
- lateinit var applicationContext: ApplicationContext
-
- @Autowired
lateinit var bluePrintWorkflowExecutionService: BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>
@Before
fun init() {
- BluePrintDependencyService.inject(applicationContext)
+ mockkObject(BluePrintDependencyService)
+ every { BluePrintDependencyService.applicationContext.getBean(any()) } returns MockComponentFunction()
+ }
+
+ @After
+ fun afterTests() {
+ unmockkAll()
}
@Test
fun testBluePrintWorkflowExecutionService() {
runBlocking {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
+ ExecutionServiceInput::class.java)!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
assertNotNull(executionServiceOutput, "failed to get response")
assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
- "failed to get successful response")
+ "failed to get successful response")
+ }
+ }
+
+ @Test
+ fun testImperativeBluePrintWorkflowExecutionService() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/imperative-test-input.json",
+ ExecutionServiceInput::class.java)!!
+
+ val executionServiceOutput = bluePrintWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
}
}
@@ -75,13 +100,13 @@ class BluePrintWorkflowExecutionServiceImplTest {
assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
runBlocking {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
//service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input-missing-resource_assignment_request.json",
- ExecutionServiceInput::class.java)!!
+ ExecutionServiceInput::class.java)!!
val executionServiceOutput = bluePrintWorkflowExecutionService
- .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
}
}
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
index 301fc34c0..becd22857 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionServiceTest.kt
@@ -27,7 +27,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeCompone
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.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
@@ -37,6 +39,7 @@ import kotlin.test.Test
import kotlin.test.assertNotNull
class ImperativeWorkflowExecutionServiceTest {
+ val log = logger(ImperativeWorkflowExecutionServiceTest::class)
@Before
fun init() {
@@ -49,37 +52,40 @@ class ImperativeWorkflowExecutionServiceTest {
unmockkAll()
}
- @Test
- fun testImperativeExecutionService() {
- runBlocking {
- val serviceTemplate = serviceTemplate("imperative-test", "1.0.0",
- "brindasanth@onap.com", "tosca") {
+ fun mockServiceTemplate(): ServiceTemplate {
+ 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"))
+ 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"))
- workflow("test-wf", "Test Imperative flow") {
- step("resolve-config", "resolve-config", "") {
- success("activate-config")
- }
- step("activate-config", "activate-config", "") {
- success("activate-licence")
- failure("activate-config-rollback")
- }
- step("activate-config-rollback", "activate-config-rollback", "")
- step("activate-licence", "activate-licence", "")
+ workflow("imperative-test-wf", "Test Imperative flow") {
+ step("resolve-config", "resolve-config", "") {
+ success("activate-config")
}
+ step("activate-config", "activate-config", "") {
+ success("activate-licence")
+ failure("activate-config-rollback")
+ }
+ step("activate-config-rollback", "activate-config-rollback", "")
+ step("activate-licence", "activate-licence", "")
}
- nodeType(BluePrintTypes.nodeTypeComponentScriptExecutor())
}
+ nodeType(BluePrintTypes.nodeTypeComponentScriptExecutor())
+ }
+ }
+ @Test
+ fun testImperativeExecutionService() {
+ runBlocking {
+ val serviceTemplate = mockServiceTemplate()
val bluePrintContext = BluePrintContext(serviceTemplate)
bluePrintContext.rootPath = normalizedPathName(".")
bluePrintContext.entryDefinition = "cba.imperative.test.ImperativeTestDefinitions.kt"
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/imperative-test-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/imperative-test-input.json
index 188e84083..d3495c456 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/imperative-test-input.json
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/imperative-test-input.json
@@ -7,11 +7,11 @@
"actionIdentifiers": {
"blueprintName": "imperative-test",
"blueprintVersion": "1.0.0",
- "actionName": "test-wf",
+ "actionName": "imperative-test-wf",
"mode": "sync"
},
"payload": {
- "test-wf-request": {
+ "imperative-test-wf-request": {
"hostname": "localhost"
}
}