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.functions.resource.resolution
19 import com.fasterxml.jackson.databind.JsonNode
21 import org.junit.runner.RunWith
22 import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
23 import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
24 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
25 import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
26 import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
27 import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
28 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
29 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
30 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
31 import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
32 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
33 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
34 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
35 import org.springframework.beans.factory.annotation.Autowired
36 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
37 import org.springframework.context.annotation.ComponentScan
38 import org.springframework.test.context.ContextConfiguration
39 import org.springframework.test.context.TestPropertySource
40 import org.springframework.test.context.junit4.SpringRunner
42 @RunWith(SpringRunner::class)
43 @ContextConfiguration(classes = [ResourceResolutionService::class,
44 InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
45 PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
46 CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
47 BlueprintPropertyConfiguration::class, BluePrintProperties::class,
48 BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
49 @TestPropertySource(locations = ["classpath:application-test.properties"])
50 @ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
51 @EnableAutoConfiguration
52 class ResourceResolutionComponentTest {
55 lateinit var resourceResolutionComponent: ResourceResolutionComponent
60 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
61 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
63 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
64 ExecutionServiceInput::class.java)!!
67 PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
69 val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
70 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
71 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
72 stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
73 bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
75 resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
76 resourceResolutionComponent.stepName = "resource-assignment"
77 resourceResolutionComponent.apply(executionServiceInput)