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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.integration.functional
24 import org.onap.cps.api.CpsDataService
25 import org.onap.cps.integration.base.FunctionalSpecBase
26 import org.onap.cps.spi.FetchDescendantsOption
28 class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
30 CpsDataService objectUnderTest
32 def setup() { objectUnderTest = cpsDataService }
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_1, BOOKSTORE_ANCHOR_1, '/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 || 6
45 FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 17
46 new FetchDescendantsOption(2) || 17
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_1, BOOKSTORE_ANCHOR_1, '/bookstore', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
52 then: 'the correct dataspace was queried'
53 assert result.dataspace.toSet() == [FUNCTIONAL_TEST_DATASPACE_1].toSet()
54 and: 'the correct anchor was queried'
55 assert result.anchorName.toSet() == [BOOKSTORE_ANCHOR_1].toSet()