summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>2019-07-16 21:11:51 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-16 21:11:51 +0000
commite41a8960c9eb56e79ab9105218d256cfe4f83ef3 (patch)
tree01e46dd29a4d8cdfe7d4af98065639df36b89761 /ms/blueprintsprocessor
parent22494ac1155031e9df5860f6909eb630c1391ff9 (diff)
parent7eabc157204d2b027ac1a699dd0c3b5b18e117fb (diff)
Merge "better errMsg for request block missing"
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt6
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt27
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input-missing-resource_assignment_request.json23
3 files changed, 50 insertions, 6 deletions
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
index 8ae128d4b..fcf0558c7 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -44,6 +44,10 @@ open class BluePrintWorkflowExecutionServiceImpl(
val workflowName = executionServiceInput.actionIdentifiers.actionName
// Assign Workflow inputs
+ //check if request structure exists
+ if (!executionServiceInput.payload.has("$workflowName-request")) {
+ throw BluePrintProcessorException("Input request missing the expected '$workflowName-request' block!")
+ }
val input = executionServiceInput.payload.get("$workflowName-request")
bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
@@ -80,4 +84,4 @@ open class BluePrintWorkflowExecutionServiceImpl(
return executionServiceOutput
}
-} \ No newline at end of file
+}
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 59be9406e..c15c054db 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
@@ -22,6 +22,7 @@ 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.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
@@ -43,18 +45,33 @@ class BluePrintWorkflowExecutionServiceImplTest {
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 `Blueprint fails on missing workflowName-parameters with a useful message`() {
+ assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../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)!!
+
+ val executionServiceOutput = bluePrintWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+ }
}
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input-missing-resource_assignment_request.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input-missing-resource_assignment_request.json
new file mode 100644
index 000000000..a44e171a3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input-missing-resource_assignment_request.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "resource-assignment",
+ "mode": "sync"
+ },
+ "payload": {
+ "resource-assignment-mislabeled-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "resource-assignment",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+}