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 org.onap.cps.spi.model.DataNodeBuilder
24 import spock.lang.Specification
25
26 class DataNodeBaseSpec extends Specification {
27
28     def leaves1 = [status:'PENDING', cmHandleId:'CMHandle3', details:'Subscription forwarded to dmi plugin'] as Map
29     def dataNode1 = createDataNodeWithLeaves(leaves1)
30
31     def leaves2 = [status:'ACCEPTED', cmHandleId:'CMHandle2', details:''] as Map
32     def dataNode2 = createDataNodeWithLeaves(leaves2)
33
34     def leaves3 = [status:'REJECTED', cmHandleId:'CMHandle1', details:'Cm handle does not exist'] as Map
35     def dataNode3 = createDataNodeWithLeaves(leaves3)
36
37     def leaves4 = [datastore:'passthrough-running'] as Map
38     def dataNode4 = createDataNodeWithLeavesAndChildDataNodes(leaves4, [dataNode1, dataNode2, dataNode3])
39
40     static def createDataNodeWithLeaves(leaves) {
41         return new DataNodeBuilder().withDataspace('NCMP-Admin')
42             .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
43             .withLeaves(leaves).build()
44     }
45
46     static def createDataNodeWithLeavesAndChildDataNodes(leaves, dataNodes) {
47         return new DataNodeBuilder().withDataspace('NCMP-Admin')
48             .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
49             .withLeaves(leaves).withChildDataNodes(dataNodes)
50             .build()
51     }
52 }