b876288f80dd61af6d254dadd84a926761a81c7f
[smo/teiv.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 Ericsson
4  *  Modifications Copyright (C) 2024-2025 OpenInfra Foundation Europe
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21 package contracts.classifier
22
23 import org.springframework.cloud.contract.spec.Contract
24
25 [
26     Contract.make {
27         description "SUCCESS - 200: Get classifiers using getRelationshipsByType - EQUALS"
28         request {
29             method GET()
30             url "/topology-inventory/v1/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&targetFilter=/classifiers&scopeFilter=/classifiers[@item='test-app-module:Rural']"
31         }
32         response {
33             status OK()
34             headers {
35                 contentType('application/json')
36             }
37             body('''{
38                 "items": [
39                     {
40                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
41                             {
42                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10,ODUFunction=10",
43                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10",
44                                 "classifiers": [
45                                     "test-app-module:Rural",
46                                     "test-app-module:Weekend"
47                                 ],
48                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=661A89AD3C2702233CD9E96E97E738C05C35EC5FDF32DC78D149B773726350067315B72448D004C938BCD0263F0C4BCCC8A5F9CDD145B9B740983D1523664328"
49                             }
50                         ]
51                     },
52                     {
53                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
54                             {
55                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16",
56                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16",
57                                 "classifiers": [
58                                     "test-app-module:Indoor",
59                                     "test-app-module:Rural",
60                                     "test-app-module:Weekend"
61                                 ],
62                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=D67357F682531C7B068486313B0FDAC3E719A166229520196FB9CE917E0236754226A5BCBF7BB7240E516D7ED3FEA852855EC3F121DD4BAFEC5646F2A37F57EE"
63                             }
64                         ]
65                     }
66                 ],
67                 "self": {
68                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural']&targetFilter=/classifiers"
69                 },
70                 "first": {
71                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural']&targetFilter=/classifiers"
72                 },
73                 "prev": {
74                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural']&targetFilter=/classifiers"
75                 },
76                 "next": {
77                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural']&targetFilter=/classifiers"
78                 },
79                 "last": {
80                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural']&targetFilter=/classifiers"
81                 },
82                 "totalCount": 2
83             }''')
84             bodyMatchers {
85                 jsonPath('$.items', byType {
86                     occurrence(2)
87                 })
88                 jsonPath('$.items[0].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
89                 jsonPath('$.items[1].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
90             }
91         }
92     },
93     Contract.make {
94         description "SUCCESS - 200: Get classifiers using getRelationshipsByType - EQUALS(AND)"
95         request {
96             method GET()
97             url "/topology-inventory/v1/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&targetFilter=/classifiers&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']"
98         }
99         response {
100             status OK()
101             headers {
102                 contentType('application/json')
103             }
104             body('''{
105                 "items": [
106                     {
107                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
108                             {
109                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10,ODUFunction=10",
110                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10",
111                                 "classifiers": [
112                                     "test-app-module:Rural",
113                                     "test-app-module:Weekend"
114                                 ],
115                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=661A89AD3C2702233CD9E96E97E738C05C35EC5FDF32DC78D149B773726350067315B72448D004C938BCD0263F0C4BCCC8A5F9CDD145B9B740983D1523664328"
116                             }
117                         ]
118                     },
119                     {
120                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
121                             {
122                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16",
123                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16",
124                                 "classifiers": [
125                                     "test-app-module:Indoor",
126                                     "test-app-module:Rural",
127                                     "test-app-module:Weekend"
128                                 ],
129                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=D67357F682531C7B068486313B0FDAC3E719A166229520196FB9CE917E0236754226A5BCBF7BB7240E516D7ED3FEA852855EC3F121DD4BAFEC5646F2A37F57EE"
130                             }
131                         ]
132                     }
133                 ],
134                 "self": {
135                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']&targetFilter=/classifiers"
136                 },
137                 "first": {
138                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']&targetFilter=/classifiers"
139                 },
140                 "prev": {
141                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']&targetFilter=/classifiers"
142                 },
143                 "next": {
144                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']&targetFilter=/classifiers"
145                 },
146                 "last": {
147                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[@item='test-app-module:Rural' and @item='test-app-module:Weekend']&targetFilter=/classifiers"
148                 },
149                 "totalCount": 2
150             }''')
151             bodyMatchers {
152                 jsonPath('$.items', byType {
153                     occurrence(2)
154                 })
155                 jsonPath('$.items[0].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
156                 jsonPath('$.items[1].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
157             }
158         }
159     },
160     Contract.make {
161         description "SUCCESS - 200: Get classifiers using getRelationshipsByType - CONTAINS"
162         request {
163             method GET()
164             url "/topology-inventory/v1/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&targetFilter=/classifiers&scopeFilter=/classifiers[contains(@item,'ural')]"
165         }
166         response {
167             status OK()
168             headers {
169                 contentType('application/json')
170             }
171             body('''{
172                 "items": [
173                     {
174                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
175                             {
176                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10,ODUFunction=10",
177                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=10",
178                                 "classifiers": [
179                                     "test-app-module:Rural",
180                                     "test-app-module:Weekend"
181                                 ],
182                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=661A89AD3C2702233CD9E96E97E738C05C35EC5FDF32DC78D149B773726350067315B72448D004C938BCD0263F0C4BCCC8A5F9CDD145B9B740983D1523664328"
183                             }
184                         ]
185                     },
186                     {
187                         "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION": [
188                             {
189                                 "bSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16",
190                                 "aSide": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16",
191                                 "classifiers": [
192                                     "module-x:Indoor",
193                                     "module-y:Rural",
194                                     "module-z:Weekend"
195                                 ],
196                                 "id": "urn:o-ran:smo:teiv:sha512:MANAGEDELEMENT_MANAGES_ODUFUNCTION=D67357F682531C7B068486313B0FDAC3E719A166229520196FB9CE917E0236754226A5BCBF7BB7240E516D7ED3FEA852855EC3F121DD4BAFEC5646F2A37F57EE"
197                             }
198                         ]
199                     }
200                 ],
201                 "self": {
202                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[contains(@item,'ural')]&targetFilter=/classifiers"
203                 },
204                 "first": {
205                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[contains(@item,'ural')]&targetFilter=/classifiers"
206                 },
207                 "prev": {
208                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[contains(@item,'ural')]&targetFilter=/classifiers"
209                 },
210                 "next": {
211                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[contains(@item,'ural')]&targetFilter=/classifiers"
212                 },
213                 "last": {
214                     "href": "/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&scopeFilter=/classifiers[contains(@item,'ural')]&targetFilter=/classifiers"
215                 },
216                 "totalCount": 2
217             }''')
218             bodyMatchers {
219                 jsonPath('$.items', byType {
220                     occurrence(2)
221                 })
222                 jsonPath('$.items[0].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
223                 jsonPath('$.items[1].o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION[0].id', byEquality())
224             }
225         }
226     },
227     Contract.make {
228         description "NOT FOUND - 404: Get classifiers using getRelationshipsByType - CONTAINS"
229         request {
230             method GET()
231             url "/topology-inventory/v1/domains/REL_OAM_RAN/relationship-types/MANAGEDELEMENT_MANAGES_ODUFUNCTION/relationships?offset=0&limit=500&targetFilter=/classifiers&scopeFilter=/classifiers[contains(@item,'NOT_EXISTING')]"
232         }
233         response {
234             status NOT_FOUND()
235             headers {
236                 contentType('application/problem+json')
237             }
238             body('''{
239                     "status": "NOT_FOUND",
240                     "message": "Invalid classifiers",
241                     "details": "The provided classifiers are invalid [NOT_EXISTING]"
242                 }''')
243             bodyMatchers {
244                 jsonPath('$.status', byEquality())
245                 jsonPath('$.message', byEquality())
246                 jsonPath('$.details', byEquality())
247             }
248         }
249     },
250 ]