diff options
author | juhi arora <j.arora@cgi.com> | 2022-05-19 14:14:17 -0400 |
---|---|---|
committer | JUHI ARORA <juhi.arora1@bell.ca> | 2022-05-24 18:27:15 +0000 |
commit | 9500d29a3edceee521d16bb1256974222cf37214 (patch) | |
tree | 43bd0151df680c86b631d1cb3d4049704df8fdb4 /ms/blueprintsprocessor/functions/resource-resolution/src/test | |
parent | c3943fbc70105c4ce38d66c7cbe227ddec35d535 (diff) |
Extend Template API to retrieve resolutions by occurrence
Add new endpoints - template to get firstN, lastN and by Range (begin, end) of 'occurrence' to get the templates
Issue-ID: CCSDK-3666
Change-Id: I242626e826022ed8b70a0abc287560ea634121b7
Signed-off-by: juhi arora <juhi.arora1@bell.ca>
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/TemplateResolutionServiceTest.kt | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt index 71d895574..a2550ed5f 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt @@ -12,6 +12,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.springframework.dao.EmptyResultDataAccessException import kotlin.test.assertEquals +import kotlin.test.assertNotEquals class TemplateResolutionServiceTest { @@ -96,6 +97,75 @@ class TemplateResolutionServiceTest { } @Test + fun findFirstNOccurrencesTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val tr1 = TemplateResolution() + val tr2 = TemplateResolution() + val list = listOf(tr1, tr2) + every { + templateResolutionRepository.findFirstNOccurrences( + any(), any(), any(), any(), 1 + ) + } returns list + runBlocking { + val res = + templateResolutionService.findFirstNOccurrences( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey, 1 + ) + assertEquals(false, res.isEmpty(), "find first N occurrences test failed") + assertEquals(1, res.size) + assertNotEquals(null, res[1]) + res[1]?.let { assertEquals(2, it.size) } + } + } + + @Test + fun findLastNOccurrencesTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val tr1 = TemplateResolution() + val tr2 = TemplateResolution() + val list = listOf(tr1, tr2) + every { + templateResolutionRepository.findLastNOccurrences( + any(), any(), any(), any(), 1 + ) + } returns list + runBlocking { + val res = + templateResolutionService.findLastNOccurrences( + blueprintName, blueprintVersion, artifactPrefix, resolutionKey, 1 + ) + assertEquals(false, res.isEmpty(), "find last N occurrences test failed") + assertEquals(1, res.size) + assertNotEquals(null, res[1]) + res[1]?.let { assertEquals(2, it.size) } + } + } + + @Test + fun findOccurrencesWithinRangeTest() { + props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence + val tr1 = TemplateResolution() + val tr2 = TemplateResolution() + val list = listOf(tr1, tr2) + every { + templateResolutionRepository.findOccurrencesWithinRange( + any(), any(), any(), any(), 0, 1 + ) + } returns list + runBlocking { + val res = + templateResolutionService.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[1]) + res[1]?.let { assertEquals(2, it.size) } + } + } + + @Test fun writeWithResolutionKeyExistingTest() { val tr = TemplateResolution() runBlocking { |