diff options
author | kuldipr <kuldip.rai@amdocs.com> | 2022-03-24 17:13:47 -0400 |
---|---|---|
committer | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2022-05-24 23:26:45 +0000 |
commit | 265ea7b91401e902a840ddd3f62dce5ae7ebc7c5 (patch) | |
tree | a4815aa7ecbebddd0dfa634433e1aec258776307 /ms/blueprintsprocessor/functions/resource-resolution/src/test | |
parent | 414949bd6d65a46f296b3c7a0057a6a58a54db22 (diff) |
API to resolve resources based on optional 'occurrence' options
User can specificy options to get firstN, lastN and by the Range
(begin, end) of 'occurrence' to get the resolutions. If no options
are specified, all the resolutions are returned in decending
oder (latest on top).
Map of resolutions are returned with 'occurrence' as the key to the
corresponding list of resolutions.
Issue-ID: CCSDK-3665
Signed-off-by: kuldipr <kuldip.rai@amdocs.com>
Change-Id: I9ecbfb339bde76510e81cd695e03cc1e061396ee
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test')
-rw-r--r-- | ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt index 635ce0e38..8d4109fcf 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt @@ -187,6 +187,75 @@ open class ResourceResolutionDBServiceTest { } @Test + fun findFirstNOccurrencesTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val rr1 = ResourceResolution() + val rr2 = ResourceResolution() + val list = listOf(rr1, rr2) + every { + resourceResolutionRepository.findFirstNOccurrences( + any(), any(), any(), any(), 1 + ) + } returns list + runBlocking { + val res = + resourceResolutionDBService.findFirstNOccurrences( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey, 1 + ) + assertEquals(false, res.isEmpty(), "find first N occurrences test failed") + assertEquals(1, res.size) + assertNotEquals(null, res[0]) + res[0]?.let { assertEquals(2, it.size) } + } + } + + @Test + fun findLastNOccurrencesTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val rr1 = ResourceResolution() + val rr2 = ResourceResolution() + val list = listOf(rr1, rr2) + every { + resourceResolutionRepository.findLastNOccurrences( + any(), any(), any(), any(), 1 + ) + } returns list + runBlocking { + val res = + resourceResolutionDBService.findLastNOccurrences( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey, 1 + ) + assertEquals(false, res.isEmpty(), "find last N occurrences test failed") + assertEquals(1, res.size) + assertNotEquals(null, res[0]) + res[0]?.let { assertEquals(2, it.size) } + } + } + + @Test + fun findOccurrencesWithinRangeTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val rr1 = ResourceResolution() + val rr2 = ResourceResolution() + val list = listOf(rr1, rr2) + every { + resourceResolutionRepository.findOccurrencesWithinRange( + any(), any(), any(), any(), 0, 1 + ) + } returns list + runBlocking { + val res = + resourceResolutionDBService.findOccurrencesWithinRange( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey, 0, 1 + ) + assertEquals(false, res.isEmpty(), "find occurrences within a range test failed") + assertEquals(1, res.size) + assertNotEquals(null, res[0]) + res[0]?.let { assertEquals(2, it.size) } + } + } + + @Test fun readWithResourceIdAndResourceTypeTest() { val rr1 = ResourceResolution() val rr2 = ResourceResolution() |