c333911fcc4480629c5db10a5278ab7cf7be105b
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / functional / CpsDataServiceIntegrationSpec.groovy
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2023 Nordix Foundation
4  *  Modifications Copyright (C) 2023 TechMahindra Ltd.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the 'License');
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an 'AS IS' BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 package org.onap.cps.integration.functional
23
24 import org.onap.cps.integration.base.FunctionalSpecBase
25 import org.onap.cps.spi.FetchDescendantsOption
26
27 class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
28
29     def objectUnderTest
30
31     def setup() { objectUnderTest = cpsDataService }
32
33     def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() {
34         when: 'get data nodes for bookstore container'
35             def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '/bookstore', fetchDescendantsOption)
36         then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes'
37             assert countDataNodesInTree(result) == expectNumberOfDataNodes
38         and: 'the top level data node has the expected attribute and value'
39             assert result.leaves['bookstore-name'] == ['Easons']
40         where: 'the following option is used'
41             fetchDescendantsOption                         || expectNumberOfDataNodes
42             FetchDescendantsOption.OMIT_DESCENDANTS        || 1
43             FetchDescendantsOption.DIRECT_CHILDREN_ONLY    || 4
44             FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 8
45             new FetchDescendantsOption(2)                  || 8
46     }
47 }