2 * Copyright © 2019 IBM.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow
19 import kotlinx.coroutines.runBlocking
21 import org.junit.runner.RunWith
22 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
23 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
24 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
25 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
26 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
27 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
28 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
29 import org.springframework.beans.factory.annotation.Autowired
30 import org.springframework.test.context.ContextConfiguration
31 import org.springframework.test.context.junit4.SpringRunner
32 import kotlin.test.assertEquals
33 import kotlin.test.assertFailsWith
34 import kotlin.test.assertNotNull
37 @RunWith(SpringRunner::class)
38 @ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
39 class BluePrintWorkflowExecutionServiceImplTest {
42 lateinit var bluePrintWorkflowExecutionService: BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>
45 fun testBluePrintWorkflowExecutionService() {
47 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
48 "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
50 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
51 ExecutionServiceInput::class.java)!!
53 val executionServiceOutput = bluePrintWorkflowExecutionService
54 .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
56 assertNotNull(executionServiceOutput, "failed to get response")
57 assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
58 "failed to get successful response")
63 fun `Blueprint fails on missing workflowName-parameters with a useful message`() {
64 assertFailsWith(exceptionClass = BluePrintProcessorException::class) {
66 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
67 "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
68 //service input will have a mislabeled input params, we are expecting to get an error when that happens with a useful error message
69 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input-missing-resource_assignment_request.json",
70 ExecutionServiceInput::class.java)!!
72 val executionServiceOutput = bluePrintWorkflowExecutionService
73 .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())