2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
23 import kotlinx.coroutines.runBlocking
24 import org.junit.Assert
25 import org.junit.Before
27 import org.junit.runner.RunWith
28 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
29 import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils
30 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.MockCapabilityScriptRA
31 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
32 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
33 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
34 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
35 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
36 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
37 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
38 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
39 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResolutionSummary
40 import org.slf4j.LoggerFactory
41 import org.springframework.beans.factory.annotation.Autowired
42 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
43 import org.springframework.context.ApplicationContext
44 import org.springframework.context.annotation.ComponentScan
45 import org.springframework.test.context.ContextConfiguration
46 import org.springframework.test.context.TestPropertySource
47 import org.springframework.test.context.junit4.SpringRunner
48 import kotlin.test.assertEquals
49 import kotlin.test.assertNotNull
50 import kotlin.test.assertTrue
53 * ResourceResolutionServiceTest
55 * @author Brinda Santh DATE : 8/15/2018
57 @RunWith(SpringRunner::class)
58 @ContextConfiguration(
59 classes = [TestDatabaseConfiguration::class]
61 @TestPropertySource(locations = ["classpath:application-test.properties"])
62 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
63 @EnableAutoConfiguration
64 class ResourceResolutionServiceTest {
66 private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
69 lateinit var resourceResolutionService: ResourceResolutionService
71 private val props = hashMapOf<String, Any>()
72 private val resolutionKey = "resolutionKey"
73 private val resourceId = "1"
74 private val resourceType = "ServiceInstance"
75 private val occurrence = 0
79 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = true
80 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = resolutionKey
81 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] = resourceId
82 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] = resourceType
83 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
84 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY] = false
88 fun testRegisteredSource() {
89 val sources = resourceResolutionService.registeredResourceSources()
90 assertNotNull(sources, "failed to get registered sources")
94 "source-input", "source-default", "source-db",
95 "source-rest", "source-capability"
98 "failed to get registered sources : $sources"
103 @Throws(Exception::class)
104 fun testResolveResource() {
107 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
109 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
111 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
114 val executionServiceInput =
115 JacksonUtils.readValueFromClassPathFile(
116 "payload/requests/sample-resourceresolution-request.json",
117 ExecutionServiceInput::class.java
120 val resourceAssignmentRuntimeService =
121 ResourceAssignmentUtils.transformToRARuntimeService(
122 bluePrintRuntimeService,
123 "testResolveResource"
127 PayloadUtils.prepareInputsFromWorkflowPayload(
128 bluePrintRuntimeService,
129 executionServiceInput.payload,
130 "resource-assignment"
133 resourceResolutionService.resolveResources(
134 resourceAssignmentRuntimeService,
135 "resource-assignment",
139 }.let { (templateMap, assignmentList) ->
140 assertEquals("This is Sample Velocity Template", templateMap)
142 val expectedAssignmentList = mutableListOf(
143 "service-instance-id" to "siid_1234",
144 "vnf-id" to "vnf_1234",
145 "vnf_name" to "temp_vnf"
147 assertEquals(expectedAssignmentList.size, assignmentList.size)
149 val areEqual = expectedAssignmentList.zip(assignmentList).all { (it1, it2) ->
150 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
152 assertEquals(true, areEqual)
157 @Throws(Exception::class)
158 fun testResolveResourceWithTransform() {
161 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
163 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
165 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
168 val executionServiceInput =
169 JacksonUtils.readValueFromClassPathFile(
170 "payload/requests/sample-resourceresolution-request.json",
171 ExecutionServiceInput::class.java
174 val resourceAssignmentRuntimeService =
175 ResourceAssignmentUtils.transformToRARuntimeService(
176 bluePrintRuntimeService,
177 "testResolveResourceWithTransform"
181 PayloadUtils.prepareInputsFromWorkflowPayload(
182 bluePrintRuntimeService,
183 executionServiceInput.payload,
184 "resource-assignment"
187 resourceResolutionService.resolveResources(
188 resourceAssignmentRuntimeService,
189 "resource-assignment",
193 }.let { (templateMap, assignmentList) ->
194 assertEquals("This is Sample Velocity Template", templateMap)
196 val expectedAssignmentList = mutableListOf(
197 "service-instance-id" to "siid_1234",
198 "vnf-id" to "vnf_1234",
199 "vnf_name" to "temp_vnf",
200 "private_net_id" to "temp_vnf_private2"
202 assertEquals(expectedAssignmentList.size, assignmentList.size)
204 val areEqual = expectedAssignmentList.zip(assignmentList).all { (it1, it2) ->
205 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
207 assertEquals(true, areEqual)
212 * Always perform new resolution even if resolution exists in the database.
215 @Throws(Exception::class)
216 fun testResolveResourceAlwaysPerformNewResolution() {
218 // Occurrence <= 0 indicates to perform new resolution even if resolution exists in the database.
219 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = -1
220 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
222 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
224 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
228 val executionServiceInput =
229 JacksonUtils.readValueFromClassPathFile(
230 "payload/requests/sample-resourceresolution-request.json",
231 ExecutionServiceInput::class.java
234 val resourceAssignmentRuntimeService =
235 ResourceAssignmentUtils.transformToRARuntimeService(
236 bluePrintRuntimeService,
237 "testResolveResource"
240 // Prepare inputs from Request#1
241 PayloadUtils.prepareInputsFromWorkflowPayload(
242 bluePrintRuntimeService,
243 executionServiceInput.payload,
244 "resource-assignment"
247 // Resolve resources as per Request#1
248 resourceResolutionService.resolveResources(
249 resourceAssignmentRuntimeService,
250 "resource-assignment",
256 val executionServiceInput2 =
257 JacksonUtils.readValueFromClassPathFile(
258 "payload/requests/sample-resourceresolution-request2.json",
259 ExecutionServiceInput::class.java
262 // Prepare inputs from Request#2
263 PayloadUtils.prepareInputsFromWorkflowPayload(
264 bluePrintRuntimeService,
265 executionServiceInput2.payload,
266 "resource-assignment"
269 // Resolve resources as per Request#2
270 resourceResolutionService.resolveResources(
271 resourceAssignmentRuntimeService,
272 "resource-assignment",
276 }.let { (templateMap, assignmentList) ->
277 assertEquals("This is Sample Velocity Template", templateMap)
279 val assignmentListForRequest1 = mutableListOf(
280 "service-instance-id" to "siid_1234",
281 "vnf-id" to "vnf_1234",
282 "vnf_name" to "temp_vnf"
284 val assignmentListForRequest2 = mutableListOf(
285 "service-instance-id" to "siid_new_resolution",
286 "vnf-id" to "vnf_new_resolution",
287 "vnf_name" to "temp_vnf_new_resolution"
289 assertEquals(assignmentListForRequest1.size, assignmentList.size)
290 assertEquals(assignmentListForRequest2.size, assignmentList.size)
292 // AlwaysPerformNewResolution use case - resolution request #2 should returns the resolution as per
293 // assignmentListForRequest2 since new resolution is performed.
294 var areEqual = assignmentListForRequest1.zip(assignmentList).all { (it1, it2) ->
295 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
297 assertEquals(false, areEqual)
299 areEqual = assignmentListForRequest2.zip(assignmentList).all { (it1, it2) ->
300 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
302 assertEquals(true, areEqual)
307 * Always perform new resolution even if resolution exists in the database.
310 @Throws(Exception::class)
311 fun testResolveResourcesForMaxOccurrence() {
313 // Occurrence <= 0 indicates to perform new resolution even if resolution exists in the database.
314 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = -1
315 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
317 // Run time for Request#1
318 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
320 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
324 val executionServiceInput =
325 JacksonUtils.readValueFromClassPathFile(
326 "payload/requests/sample-resourceresolution-request.json",
327 ExecutionServiceInput::class.java
330 // Prepare inputs from Request#1
331 PayloadUtils.prepareInputsFromWorkflowPayload(
332 bluePrintRuntimeService,
333 executionServiceInput.payload,
334 "resource-assignment"
337 val resourceAssignmentRuntimeService =
338 ResourceAssignmentUtils.transformToRARuntimeService(
339 bluePrintRuntimeService,
340 "testResolveResource"
343 // Resolve resources as per Request#1
344 resourceResolutionService.resolveResources(
345 resourceAssignmentRuntimeService,
346 "resource-assignment",
351 // Run time for Request#2
352 val bluePrintRuntimeService2 = BluePrintMetadataUtils.getBluePrintRuntime(
354 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
358 val executionServiceInput2 =
359 JacksonUtils.readValueFromClassPathFile(
360 "payload/requests/sample-resourceresolution-request2.json",
361 ExecutionServiceInput::class.java
364 val resourceAssignmentRuntimeService2 =
365 ResourceAssignmentUtils.transformToRARuntimeService(
366 bluePrintRuntimeService2,
367 "testResolveResource"
370 // Prepare inputs from Request#2
371 PayloadUtils.prepareInputsFromWorkflowPayload(
372 bluePrintRuntimeService2,
373 executionServiceInput2.payload,
374 "resource-assignment"
377 // Resolve resources as per Request#2
378 resourceResolutionService.resolveResources(
379 resourceAssignmentRuntimeService2,
380 "resource-assignment",
384 }.let { (template, assignmentList) ->
385 assertEquals("This is maxoccurrence Velocity Template", template)
387 val assignmentListForRequest1 = mutableListOf(
388 "firmware-version" to "firmware-version-0",
389 "ip-address" to "192.0.0.1"
391 val assignmentListForRequest2 = mutableListOf(
392 "firmware-version" to "firmware-version-1",
393 "ip-address" to "192.0.0.1"
395 assertEquals(assignmentListForRequest1.size, assignmentList.size)
396 assertEquals(assignmentListForRequest2.size, assignmentList.size)
398 // firmware-version has max-occurrence = 0 means perform new resolution all the time.
399 // ip-address has max-occurrence = 1 so its resolution should only be done once.
401 // AlwaysPerformNewResolution + max-occurrence feature use case - resolution request #2 should returns
402 // the resolution as per assignmentListForRequest2 since new resolution is only performed for
403 // firmware-version and not for ip-address.
404 var areEqual = assignmentListForRequest1.zip(assignmentList).all { (it1, it2) ->
405 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
407 assertEquals(false, areEqual)
409 areEqual = assignmentListForRequest2.zip(assignmentList).all { (it1, it2) ->
410 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
412 assertEquals(true, areEqual)
417 * Don't perform new resolution in case resolution already exists in the database.
420 @Throws(Exception::class)
421 fun testResolveResourceNoNewResolution() {
423 // Occurrence > 0 indicates to not perform new resolution if resolution exists in the database.
424 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = 1
425 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
427 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
429 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
433 val executionServiceInput =
434 JacksonUtils.readValueFromClassPathFile(
435 "payload/requests/sample-resourceresolution-request.json",
436 ExecutionServiceInput::class.java
439 val resourceAssignmentRuntimeService =
440 ResourceAssignmentUtils.transformToRARuntimeService(
441 bluePrintRuntimeService,
442 "testResolveResource"
445 // Prepare inputs from Request#1
446 PayloadUtils.prepareInputsFromWorkflowPayload(
447 bluePrintRuntimeService,
448 executionServiceInput.payload,
449 "resource-assignment"
451 // Resolve resources as per Request#1
452 resourceResolutionService.resolveResources(
453 resourceAssignmentRuntimeService,
454 "resource-assignment",
460 val executionServiceInput2 =
461 JacksonUtils.readValueFromClassPathFile(
462 "payload/requests/sample-resourceresolution-request2.json",
463 ExecutionServiceInput::class.java
466 // Prepare inputs from Request#2
467 PayloadUtils.prepareInputsFromWorkflowPayload(
468 bluePrintRuntimeService,
469 executionServiceInput2.payload,
470 "resource-assignment"
473 // Resolve resources as per Request#2
474 resourceResolutionService.resolveResources(
475 resourceAssignmentRuntimeService,
476 "resource-assignment",
480 }.let { (templateMap, assignmentList) ->
481 assertEquals("This is Sample Velocity Template", templateMap)
483 val assignmentListForRequest1 = mutableListOf(
484 "service-instance-id" to "siid_1234",
485 "vnf-id" to "vnf_1234",
486 "vnf_name" to "temp_vnf"
488 val assignmentListForRequest2 = mutableListOf(
489 "service-instance-id" to "siid_new_resolution",
490 "vnf-id" to "vnf_new_resolution",
491 "vnf_name" to "temp_vnf_new_resolution"
493 assertEquals(assignmentListForRequest1.size, assignmentList.size)
494 assertEquals(assignmentListForRequest2.size, assignmentList.size)
496 // NoNewResolution use case - resolution for request #2 returns the same resolution as
497 // assignmentListForRequest1 since no new resolution is/was actually performed.
498 var areEqual = assignmentListForRequest1.zip(assignmentList).all { (it1, it2) ->
499 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
501 assertEquals(true, areEqual)
503 areEqual = assignmentListForRequest2.zip(assignmentList).all { (it1, it2) ->
504 it1.first == it2.name && it1.second == it2.property?.value?.asText() ?: null
506 assertEquals(false, areEqual)
511 @Throws(Exception::class)
512 fun testResolveResources() {
513 val artifactNames = listOf("baseconfig", "another")
515 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
517 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
519 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
522 val executionServiceInput =
523 JacksonUtils.readValueFromClassPathFile(
524 "payload/requests/sample-resourceresolution-request.json",
525 ExecutionServiceInput::class.java
529 PayloadUtils.prepareInputsFromWorkflowPayload(
530 bluePrintRuntimeService,
531 executionServiceInput.payload,
532 "resource-assignment"
535 resourceResolutionService.resolveResources(
536 bluePrintRuntimeService,
537 "resource-assignment",
543 assertEquals(artifactNames.toSet(), it.templateMap.keys)
544 assertEquals(artifactNames.toSet(), it.assignmentMap.keys)
546 assertEquals("This is Sample Velocity Template", it.templateMap["another"])
547 assertEquals("vnf_1234", it.assignmentMap["another"]!!["vnf-id"]!!.asText())
552 @Throws(Exception::class)
553 fun testResolveResourcesWithMappingAndTemplate() {
555 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
557 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
559 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
562 val executionServiceInput =
563 JacksonUtils.readValueFromClassPathFile(
564 "payload/requests/sample-resourceresolution-request.json",
565 ExecutionServiceInput::class.java
568 val resourceAssignmentRuntimeService =
569 ResourceAssignmentUtils.transformToRARuntimeService(
570 bluePrintRuntimeService,
571 "testResolveResourcesWithMappingAndTemplate"
574 val artifactPrefix = "another"
577 PayloadUtils.prepareInputsFromWorkflowPayload(
578 bluePrintRuntimeService,
579 executionServiceInput.payload,
580 "resource-assignment"
584 resourceResolutionService.resolveResources(
585 resourceAssignmentRuntimeService,
586 "resource-assignment",
590 "Couldn't Resolve Resources for artifact $artifactPrefix"
596 @Throws(Exception::class)
597 fun testResolveResourcesResolutionSummary() {
599 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY] = true
600 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
602 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
604 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
607 val executionServiceInput =
608 JacksonUtils.readValueFromClassPathFile(
609 "payload/requests/sample-resourceresolution-request.json",
610 ExecutionServiceInput::class.java
613 val resourceAssignmentRuntimeService =
614 ResourceAssignmentUtils.transformToRARuntimeService(
615 bluePrintRuntimeService,
616 "testResolveResourcesWithMappingAndTemplate"
619 val artifactPrefix = "notemplate"
622 PayloadUtils.prepareInputsFromWorkflowPayload(
623 bluePrintRuntimeService,
624 executionServiceInput.payload,
625 "resource-assignment"
628 resourceResolutionService.resolveResources(
629 resourceAssignmentRuntimeService,
630 "resource-assignment",
635 val summaries = JacksonUtils.jsonNode(it.first)["resolution-summary"]
636 val list = JacksonUtils.getListFromJsonNode(summaries, ResolutionSummary::class.java)
637 assertEquals(list.size, 3)
642 @Throws(Exception::class)
643 fun testResolveResourcesWithoutTemplate() {
644 val artifactPrefix = "notemplate"
646 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
648 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
650 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
653 val executionServiceInput =
654 JacksonUtils.readValueFromClassPathFile(
655 "payload/requests/sample-resourceresolution-request.json",
656 ExecutionServiceInput::class.java
659 val resourceAssignmentRuntimeService =
660 ResourceAssignmentUtils.transformToRARuntimeService(
661 bluePrintRuntimeService,
662 "testResolveResourcesWithMappingAndTemplate"
666 PayloadUtils.prepareInputsFromWorkflowPayload(
667 bluePrintRuntimeService,
668 executionServiceInput.payload,
669 "resource-assignment"
672 resourceResolutionService.resolveResources(
673 resourceAssignmentRuntimeService,
674 "resource-assignment",
682 "service-instance-id" : "siid_1234",
683 "vnf-id" : "vnf_1234",
684 "vnf_name" : "temp_vnf"
689 val areEqual = it.second.first().name == "service-instance-id" &&
690 "siid_1234" == it.second.first().property?.value?.asText() ?: null
691 assertEquals(true, areEqual)
696 fun testResolveResourcesWithResourceIdAndResourceType() {
697 props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = ""
699 Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
701 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
703 "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
706 val executionServiceInput =
707 JacksonUtils.readValueFromClassPathFile(
708 "payload/requests/sample-resourceresolution-request.json",
709 ExecutionServiceInput::class.java
712 val resourceAssignmentRuntimeService =
713 ResourceAssignmentUtils.transformToRARuntimeService(
714 bluePrintRuntimeService,
715 "testResolveResourcesWithMappingAndTemplate"
718 val artifactPrefix = "another"
721 PayloadUtils.prepareInputsFromWorkflowPayload(
722 bluePrintRuntimeService,
723 executionServiceInput.payload,
724 "resource-assignment"
728 resourceResolutionService.resolveResources(
729 resourceAssignmentRuntimeService,
730 "resource-assignment",
734 "Couldn't Resolve Resources for artifact $artifactPrefix"
740 fun testResourceResolutionForDefinition() {
741 val resourceDefinitions = BluePrintTypes.resourceDefinitions {
742 resourceDefinition(name = "port-speed", description = "Port Speed") {
743 property(type = "string", required = true)
745 sourceCapability(id = "sdno", description = "SDNO Source") {
747 type(BluePrintConstants.SCRIPT_KOTLIN)
748 scriptClassReference(MockCapabilityScriptRA::class.qualifiedName!!)
749 keyDependencies(arrayListOf("device-id"))
752 sourceDb(id = "sdnc", description = "SDNC Controller") {
754 endpointSelector("processor-db")
755 query("SELECT PORT_SPEED FROM XXXX WHERE DEVICE_ID = :device_id")
757 map("device_id", "\$device-id")
759 keyDependencies(arrayListOf("device-id"))
764 resourceDefinition(name = "device-id", description = "Device Id") {
765 property(type = "string", required = true) {
767 sourceInput(id = "input", description = "Dependency Source") {}
773 val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
774 every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
775 every { raRuntimeService.getBluePrintError() } returns BluePrintError()
776 every { raRuntimeService.setBluePrintError(any()) } returns Unit
777 every { raRuntimeService.getInputValue("device-id") } returns "123456".asJsonPrimitive()
778 every { raRuntimeService.putResolutionStore(any(), any()) } returns Unit
780 val applicationContext = mockk<ApplicationContext>()
781 every { applicationContext.getBean("rr-processor-source-capability") } returns MockCapabilityScriptRA()
782 every { applicationContext.getBean("rr-processor-source-db") } returns MockCapabilityScriptRA()
783 every { applicationContext.getBean("rr-processor-source-input") } returns MockCapabilityScriptRA()
785 val sources = arrayListOf<String>("sdno", "sdnc")
787 val resourceResolutionService = ResourceResolutionServiceImpl(applicationContext, mockk(), mockk(), mockk())
788 val resolvedResources = resourceResolutionService.resolveResourceDefinition(
790 resourceDefinitions, "port-speed", sources
792 assertNotNull(resolvedResources, "failed to resolve the resources")