2  * Copyright © 2017-2018 AT&T Intellectual Property.
 
   3  * Modifications Copyright © 2018 IBM.
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *     http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  18 package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
 
  20 import com.fasterxml.jackson.databind.JsonNode
 
  22 import org.junit.runner.RunWith
 
  23 import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
 
  24 import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
 
  25 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 
  26 import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
 
  27 import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
 
  28 import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
 
  29 import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
 
  30 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 
  31 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
 
  32 import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
 
  33 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 
  34 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 
  35 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 
  36 import org.springframework.beans.factory.annotation.Autowired
 
  37 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
 
  38 import org.springframework.context.annotation.ComponentScan
 
  39 import org.springframework.test.context.ContextConfiguration
 
  40 import org.springframework.test.context.TestPropertySource
 
  41 import org.springframework.test.context.junit4.SpringRunner
 
  43 @RunWith(SpringRunner::class)
 
  44 @ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
 
  45     InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
 
  46     DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
 
  47     CapabilityResourceResolutionProcessor::class, DBLibGenericService::class,
 
  48     BlueprintPropertyConfiguration::class, BluePrintProperties::class,
 
  49     BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
 
  50 @TestPropertySource(locations = ["classpath:application-test.properties"])
 
  51 @ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
 
  52 @EnableAutoConfiguration
 
  53 class ResourceResolutionComponentTest {
 
  56     lateinit var resourceResolutionComponent: ResourceResolutionComponent
 
  61         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
 
  62                 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
 
  64         val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
 
  65                 ExecutionServiceInput::class.java)!!
 
  68         PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
 
  70         val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
 
  71         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
 
  72         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceResolutionComponent")
 
  73         stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
 
  74         bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
 
  76         resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
 
  77         resourceResolutionComponent.stepName = "resource-assignment"
 
  78         resourceResolutionComponent.apply(executionServiceInput)