2 * Copyright © 2017-2018 AT&T Intellectual Property.
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.apps.blueprintsprocessor.services.workflow
20 import org.junit.runner.RunWith
21 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
22 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
23 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
24 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
25 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
26 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
27 import org.slf4j.LoggerFactory
28 import org.springframework.beans.factory.annotation.Autowired
29 import org.springframework.context.ApplicationContext
30 import org.springframework.test.context.ContextConfiguration
31 import org.springframework.test.context.junit4.SpringRunner
32 import kotlin.test.assertEquals
34 @RunWith(SpringRunner::class)
35 @ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
36 class BlueprintServiceLogicTest {
38 private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
41 lateinit var applicationContext: ApplicationContext
44 lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
47 fun testExecuteGraphWithSingleComponent() {
49 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
50 "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
52 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
55 blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
60 fun testExecuteGraphWithMultipleComponents() {
62 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
63 "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
65 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
67 blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
73 val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
74 singleton1.stepName = "step1"
75 val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
76 assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
80 fun testProtoTypeFunction() {
81 val stepName1 = "step1"
82 val stepName2 = "step2"
83 val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
84 proto1.stepName = stepName1
86 val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
87 proto2.stepName = stepName2
89 assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
90 assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")