diff options
author | rajesh.kumar <rk00747546@techmahindra.com> | 2022-12-06 11:47:24 +0000 |
---|---|---|
committer | rajesh.kumar <rk00747546@techmahindra.com> | 2023-01-23 05:22:04 +0000 |
commit | cc21a025308153e8f187cd3e82cf828191d7b387 (patch) | |
tree | e33b4fb9725481bdf2526e2a3246f12984bcac73 /cps-service/src/test/groovy | |
parent | 5b00ef4d6ab15006b880a22dc69a936e4f784623 (diff) |
Added depth parameter in query nodes API.
Issue-ID: CPS-1381
Change-ID: I73f97f986a817d423f93a8d922dcd9647b1206bb
Signed-off-by: rajesh.kumar <rk00747546@techmahindra.com>
Diffstat (limited to 'cps-service/src/test/groovy')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/api/impl/CpsQueryServiceImplSpec.groovy | 4 | ||||
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/spi/FetchDescendantsOptionSpec.groovy | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsQueryServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsQueryServiceImplSpec.groovy index 8b232b420d..60286b6643 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsQueryServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsQueryServiceImplSpec.groovy @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 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. @@ -43,7 +44,8 @@ class CpsQueryServiceImplSpec extends Specification { and: 'the CpsValidator is called on the dataspaceName, schemaSetName and anchorName' 1 * mockCpsValidator.validateNameCharacters(dataspaceName, anchorName) where: 'all fetch descendants options are supported' - fetchDescendantsOption << [FetchDescendantsOption.OMIT_DESCENDANTS, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS] + fetchDescendantsOption << [FetchDescendantsOption.OMIT_DESCENDANTS, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS, + FetchDescendantsOption.FETCH_DIRECT_CHILDREN_ONLY, new FetchDescendantsOption(10)] } } diff --git a/cps-service/src/test/groovy/org/onap/cps/spi/FetchDescendantsOptionSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/FetchDescendantsOptionSpec.groovy index 627383561a..c4d3dd8b7b 100644 --- a/cps-service/src/test/groovy/org/onap/cps/spi/FetchDescendantsOptionSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/spi/FetchDescendantsOptionSpec.groovy @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2022 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. @@ -20,7 +21,7 @@ package org.onap.cps.spi - +import org.onap.cps.spi.exceptions.DataValidationException import spock.lang.Specification class FetchDescendantsOptionSpec extends Specification { @@ -72,4 +73,18 @@ class FetchDescendantsOptionSpec extends Specification { then: 'exception thrown' thrown IllegalArgumentException } + + def 'Create fetch descendant option with descendant using #scenario'() { + when: 'the next level of depth is not allowed' + def FetchDescendantsOption fetchDescendantsOption = FetchDescendantsOption.getFetchDescendantsOption(fetchDescendantsOptionAsString) + then: 'fetch descendant object created' + assert fetchDescendantsOption.depth == expectedDepth + where: 'following parameters are used' + scenario | fetchDescendantsOptionAsString || expectedDepth + 'all descendants using number' | '-1' || -1 + 'all descendants using all' | 'all' || -1 + 'No descendants by default' | '' || 0 + 'No descendants using none' | 'none' || 0 + 'til 10th descendants using number' | '10' || 10 + } } |