aeca06222caf38b5408dfd186f27e478dfbd3c8c
[cps/ncmp-dmi-plugin.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
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.dmi.service.operation
22
23 import spock.lang.Specification
24
25 class ResourceIdentifierEncoderSpec extends Specification {
26
27     def 'encodeNestedResourcePath should handle valid paths correctly: #scenario'() {
28         when: 'we encode a valid resource path'
29             def result = ResourceIdentifierEncoder.encodeNestedResourcePath(input)
30         then: 'the result matches expectedEncodedString encoded format'
31             assert result == expectedEncodedString
32         where: 'following scenarios are used'
33             scenario                                     | input                                            || expectedEncodedString
34             'simple path without leading path separator' | 'container'                                      || 'container'
35             'list entry with space in key value'         | '/list-name=My Container/leaf=leaf with space'   || '/list-name=My%20Container/leaf=leaf%20with%20space'
36             'key value containing path separator'        | '/container/list=id/with/slashes/leaf=Some Leaf' || '/container/list=id%2Fwith%2Fslashes/leaf=Some%20Leaf'
37             'equals signs in key value'                  | '/list=Key=Value=Another'                        || '/list=Key%3DValue%3DAnother'
38     }
39 }