8dfa118da6bbcdd2841a19c306d58aa6e592fc90
[cps.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 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.integration.functional.ncmp
22
23 import org.onap.cps.integration.base.CpsIntegrationSpecBase
24 import org.onap.cps.ncmp.api.data.models.CmResourceAddress
25 import org.onap.cps.ncmp.impl.data.NetworkCmProxyFacade
26 import spock.util.concurrent.PollingConditions
27
28 import static org.onap.cps.ncmp.api.data.models.DatastoreType.PASSTHROUGH_OPERATIONAL
29
30 class CmHandleResourceDataSpec extends CpsIntegrationSpecBase {
31
32     NetworkCmProxyFacade objectUnderTest
33
34     def setup() {
35         dmiDispatcher.moduleNamesPerCmHandleId['ch-1'] = ['M1', 'M2']
36         registerCmHandle(DMI_URL, 'ch-1', NO_MODULE_SET_TAG)
37         objectUnderTest = networkCmProxyFacade
38     }
39
40     def cleanup() {
41         deregisterCmHandle(DMI_URL, 'ch-1')
42     }
43
44     def 'Get resource data having special chars into path & query param value.'() {
45         when: 'getting the resource data'
46             def cmResourceAddress = new CmResourceAddress(PASSTHROUGH_OPERATIONAL.datastoreName, 'ch-1', 'parent/child')
47             objectUnderTest.getResourceDataForCmHandle(cmResourceAddress, '(a=1,b=2)', 'my-client-topic', false, null)
48         then: 'dmi resource data url is encoded correctly'
49             new PollingConditions().within(5, () -> {
50                 assert dmiDispatcher.dmiResourceDataUrl == '/dmi/v1/ch/ch-1/data/ds/ncmp-datastore%3Apassthrough-operational?resourceIdentifier=parent%2Fchild&options=%28a%3D1%2Cb%3D2%29&topic=my-client-topic'
51             })
52     }
53 }