aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/test/groovy/org/onap/cps/spi
diff options
context:
space:
mode:
authorrajesh.kumar <rk00747546@techmahindra.com>2023-04-25 11:58:35 +0530
committerrajesh.kumar <rk00747546@techmahindra.com>2023-08-02 18:15:16 +0530
commitf248b5d9b794d5bdff59145406e0398d6fdcafa4 (patch)
treef99670f0911b4c6e5f13ec5590fe15eb205f0dc3 /cps-service/src/test/groovy/org/onap/cps/spi
parent7fcffe5ae6753bfb6746d18d41ec536092603a76 (diff)
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 <rk00747546@techmahindra.com>
Diffstat (limited to 'cps-service/src/test/groovy/org/onap/cps/spi')
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/spi/PaginationOptionSpec.groovy41
1 files changed, 41 insertions, 0 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/spi/PaginationOptionSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/PaginationOptionSpec.groovy
new file mode 100644
index 000000000..9d74a1722
--- /dev/null
+++ b/cps-service/src/test/groovy/org/onap/cps/spi/PaginationOptionSpec.groovy
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022-2023 Nordix Foundation
+ * Modifications Copyright (C) 2023 TechMahindra Ltd.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi
+
+import spock.lang.Specification
+
+class PaginationOptionSpec extends Specification {
+
+ def 'Pagination validation with: #scenario'() {
+ given: 'pagination option with pageIndex and pageSize'
+ def paginationOption = new PaginationOption(pageIndex, pageSize)
+ expect: 'validation returns expected result'
+ assert paginationOption.isValidPaginationOption() == expectedIsValidPaginationOption
+ where: 'following parameters are used'
+ scenario | pageIndex | pageSize || expectedIsValidPaginationOption
+ 'valid pagination' | 1 | 1 || true
+ 'negative index' | -1 | 1 || false
+ 'negative size' | 1 | -1 || false
+ 'zero index' | 0 | 1 || false
+ 'zero size' | 1 | 0 || false
+ }
+}