From f248b5d9b794d5bdff59145406e0398d6fdcafa4 Mon Sep 17 00:00:00 2001 From: "rajesh.kumar" Date: Tue, 25 Apr 2023 11:58:35 +0530 Subject: Support pagination in query across all anchors(ep4) Add pagination query parameters in query across all anchors API pagination parameters (pageIndex and pageSize) are optional default is to query all fragments each pageSize represents number of records(number of anchors) TotalRecords is returned in response header to find number of pages. - If pagination option is provided in request then query number of anchors equal to pageSize. pageIndex is used for setting offset. - return number of records(one anchor per record) as per pagesize and pageSize Issue-ID: CPS-1605 Change-ID: I73f97f986a817d423f93a8d922dcd9647b2504bc Signed-off-by: rajesh.kumar --- .../groovy/org/onap/cps/spi/impl/utils/CpsValidatorSpec.groovy | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cps-ri/src/test/groovy/org/onap') diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/utils/CpsValidatorSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/utils/CpsValidatorSpec.groovy index 345089c931..8d348443c7 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/utils/CpsValidatorSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/utils/CpsValidatorSpec.groovy @@ -20,6 +20,7 @@ package org.onap.cps.spi.impl.utils +import org.onap.cps.spi.PaginationOption import org.onap.cps.spi.exceptions.DataValidationException import spock.lang.Specification @@ -64,4 +65,13 @@ class CpsValidatorSpec extends Specification { then: 'a data validation exception is thrown' thrown(DataValidationException) } + + def 'Validate Pagination option with invalid page index and size.'() { + when: 'the pagination option is validated using invalid options' + objectUnderTest.validatePaginationOption(new PaginationOption(-5, -2)) + then: 'a data validation exception is thrown' + def exceptionThrown = thrown(DataValidationException) + and: 'the error was encountered at the following index in #scenario' + assert exceptionThrown.getDetails().contains("Invalid page index or size") + } } -- cgit 1.2.3-korg