Merge "Expose endpoint to accept bulk request"
[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.api.CpsDataService
25 import org.onap.cps.integration.base.FunctionalSpecBase
26 import org.onap.cps.spi.FetchDescendantsOption
27
28 class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
29
30     CpsDataService objectUnderTest
31
32     def setup() { objectUnderTest = cpsDataService }
33
34     def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() {
35         when: 'get data nodes for bookstore container'
36             def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '/bookstore', fetchDescendantsOption)
37         then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes'
38             assert countDataNodesInTree(result) == expectNumberOfDataNodes
39         and: 'the top level data node has the expected attribute and value'
40             assert result.leaves['bookstore-name'] == ['Easons']
41         where: 'the following option is used'
42             fetchDescendantsOption                         || expectNumberOfDataNodes
43             FetchDescendantsOption.OMIT_DESCENDANTS        || 1
44             FetchDescendantsOption.DIRECT_CHILDREN_ONLY    || 5
45             FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 14
46             new FetchDescendantsOption(2)                  || 14
47     }
48
49     def 'Read bookstore top-level container(s) has correct dataspace and anchor.'() {
50         when: 'get data nodes for bookstore container'
51             def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '/bookstore', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
52         then: 'the correct dataspace was queried'
53             assert result.dataspace.toSet() == [FUNCTIONAL_TEST_DATASPACE].toSet()
54         and: 'the correct anchor was queried'
55             assert result.anchorName.toSet() == [BOOKSTORE_ANCHOR].toSet()
56     }
57
58 }