Merge "RTD change to document migration to Spring Boot 3.0"
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / utils / DataNodeBaseSpec.groovy
1 /*
2  * ============LICENSE_START========================================================
3  * Copyright (c) 2023 Nordix Foundation.
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an 'AS IS' BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.ncmp.api.impl.utils
22
23 import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
24
25 import org.onap.cps.spi.model.DataNodeBuilder
26 import spock.lang.Specification
27
28 class DataNodeBaseSpec extends Specification {
29
30     def leaves1 = [status:'PENDING', cmHandleId:'CMHandle3', details:'Subscription forwarded to dmi plugin'] as Map
31     def dataNode1 = createDataNodeWithLeaves(leaves1)
32
33     def leaves2 = [status:'ACCEPTED', cmHandleId:'CMHandle2', details:''] as Map
34     def dataNode2 = createDataNodeWithLeaves(leaves2)
35
36     def leaves3 = [status:'REJECTED', cmHandleId:'CMHandle1', details:'Cm handle does not exist'] as Map
37     def dataNode3 = createDataNodeWithLeaves(leaves3)
38
39     def leaves4 = [datastore:'passthrough-running'] as Map
40     def dataNode4 = createDataNodeWithLeavesAndChildDataNodes(leaves4, [dataNode1, dataNode2, dataNode3])
41
42     static def createDataNodeWithLeaves(leaves) {
43         return new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
44             .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
45             .withLeaves(leaves).build()
46     }
47
48     static def createDataNodeWithLeavesAndChildDataNodes(leaves, dataNodes) {
49         return new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
50             .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
51             .withLeaves(leaves).withChildDataNodes(dataNodes)
52             .build()
53     }
54 }