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 org.junit.Assert
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.service.PrimaryDBLibGenericService
28 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
29 import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
30 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
31 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
32 import org.slf4j.LoggerFactory
33 import org.springframework.beans.factory.annotation.Autowired
34 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
35 import org.springframework.context.annotation.ComponentScan
36 import org.springframework.test.context.ContextConfiguration
37 import org.springframework.test.context.TestPropertySource
38 import org.springframework.test.context.junit4.SpringRunner
39 import kotlin.test.assertNotNull
40 import kotlin.test.assertTrue
43 * ResourceResolutionServiceTest
45 * @author Brinda Santh DATE : 8/15/2018
47 @RunWith(SpringRunner::class)
48 @ContextConfiguration(classes = [ResourceResolutionService::class,
49 InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
50 PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
51 CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
52 BlueprintPropertyConfiguration::class, BluePrintProperties::class,
53 BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
54 @TestPropertySource(locations = ["classpath:application-test.properties"])
55 @ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
56 @EnableAutoConfiguration
57 class ResourceResolutionServiceTest {
59 private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
62 lateinit var resourceResolutionService: ResourceResolutionService
65 fun testRegisteredSource() {
66 val sources = resourceResolutionService.registeredResourceSources()
67 assertNotNull(sources, "failed to get registered sources")
68 assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "primary-config-data")), "failed to get registered sources")
72 @Throws(Exception::class)
73 fun testResolveResource() {
75 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
77 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
78 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
80 val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
81 ExecutionServiceInput::class.java)!!
84 PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
86 resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")