0ce5786857133542469364be946d07d47bea0431
[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.decorators
22
23 import org.springframework.cloud.contract.spec.Contract
24
25 [
26     Contract.make {
27         description "SUCCESS - 200: Get decorators using getTopologyByEntityTypeName - EQUALS"
28         request {
29             method GET()
30             url "/topology-inventory/v1alpha11/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
31         }
32         response {
33             status OK()
34             headers {
35                 contentType('application/json')
36             }
37             body('''{
38                 "items": [
39                     {
40                         "o-ran-smo-teiv-ran:ODUFunction": [
41                             {
42                                 "decorators": {
43                                     "test-app-module:textdata": "Stockholm",
44                                     "test-app-module:intdata": 456
45                                 },
46                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=13,ODUFunction=13"
47                             }
48                         ]
49                     },
50                     {
51                         "o-ran-smo-teiv-ran:ODUFunction": [
52                             {
53                                 "decorators": {
54                                     "test-app-module:textdata": "Stockholm",
55                                     "test-app-module:intdata": 123
56                                 },
57                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=14,ODUFunction=14"
58                             }
59                         ]
60                     },
61                     {
62                         "o-ran-smo-teiv-ran:ODUFunction": [
63                             {
64                                 "decorators": {
65                                     "test-app-module:textdata": "Stockholm",
66                                     "test-app-module:intdata": 123
67                                 },
68                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16"
69                             }
70                         ]
71                     }
72                 ],
73                 "self": {
74                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
75                 },
76                 "first": {
77                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
78                 },
79                 "prev": {
80                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
81                 },
82                 "next": {
83                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
84                 },
85                 "last": {
86                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[@test-app-module:textdata = 'Stockholm']"
87                 },
88                 "totalCount": 3
89             }''')
90             bodyMatchers {
91                 jsonPath('$.items', byType {
92                     occurrence(3)
93                 })
94                 jsonPath('$.items[0].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
95                 jsonPath('$.items[1].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
96                 jsonPath('$.items[2].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
97             }
98         }
99     },
100     Contract.make {
101         description "SUCCESS - 200: Get decorators using getTopologyByEntityTypeName - CONTAINS"
102         request {
103             method GET()
104             url "/topology-inventory/v1alpha11/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
105         }
106         response {
107             status OK()
108             headers {
109                 contentType('application/json')
110             }
111             body('''{
112                 "items": [
113                     {
114                         "o-ran-smo-teiv-ran:ODUFunction": [
115                             {
116                                 "decorators": {
117                                     "test-app-module:textdata": "Stockholm",
118                                     "test-app-module:intdata": 456
119                                 },
120                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=13,ODUFunction=13"
121                             }
122                         ]
123                     },
124                     {
125                         "o-ran-smo-teiv-ran:ODUFunction": [
126                             {
127                                 "decorators": {
128                                     "test-app-module:textdata": "Stockholm",
129                                     "test-app-module:intdata": 123
130                                 },
131                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=14,ODUFunction=14"
132                             }
133                         ]
134                     },
135                     {
136                         "o-ran-smo-teiv-ran:ODUFunction": [
137                             {
138                                 "decorators": {
139                                     "test-app-module:textdata": "Stockholm",
140                                     "test-app-module:intdata": 123
141                                 },
142                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16"
143                             }
144                         ]
145                     }
146                 ],
147                 "self": {
148                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
149                 },
150                 "first": {
151                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
152                 },
153                 "prev": {
154                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
155                 },
156                 "next": {
157                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
158                 },
159                 "last": {
160                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')]"
161                 },
162                 "totalCount": 3
163             }''')
164             bodyMatchers {
165                 jsonPath('$.items', byType {
166                     occurrence(3)
167                 })
168                 jsonPath('$.items[0].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
169                 jsonPath('$.items[1].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
170                 jsonPath('$.items[2].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
171             }
172         }
173     },
174     Contract.make {
175         description "SUCCESS - 200: Get decorators using getTopologyByEntityTypeName - CONTAINS and EQUALS"
176         request {
177             method GET()
178             url "/topology-inventory/v1alpha11/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
179         }
180         response {
181             status OK()
182             headers {
183                 contentType('application/json')
184             }
185             body('''{
186                 "items": [
187                     {
188                         "o-ran-smo-teiv-ran:ODUFunction": [
189                             {
190                                 "decorators": {
191                                     "test-app-module:textdata": "Stockholm",
192                                     "test-app-module:intdata": 123
193                                 },
194                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=14,ODUFunction=14"
195                             }
196                         ]
197                     },
198                     {
199                         "o-ran-smo-teiv-ran:ODUFunction": [
200                             {
201                                 "decorators": {
202                                     "test-app-module:textdata": "Stockholm",
203                                     "test-app-module:intdata": 123
204                                 },
205                                 "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=16,ODUFunction=16"
206                             }
207                         ]
208                     }
209                 ],
210                 "self": {
211                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
212                 },
213                 "first": {
214                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
215                 },
216                 "prev": {
217                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
218                 },
219                 "next": {
220                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
221                 },
222                 "last": {
223                     "href": "/domains/RAN/entity-types/ODUFunction/entities?offset=0&limit=500&targetFilter=/decorators&scopeFilter=/decorators[contains(@test-app-module:textdata, 'Stock')] ; /decorators[@test-app-module:intdata = 123]"
224                 },
225                 "totalCount": 2
226             }''')
227             bodyMatchers {
228                 jsonPath('$.items', byType {
229                     occurrence(2)
230                 })
231                 jsonPath('$.items[0].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
232                 jsonPath('$.items[1].o-ran-smo-teiv-ran:ODUFunction[0].id', byEquality())
233             }
234         }
235     },
236     Contract.make {
237         description "SUCCESS - 200: Get decorators using association name - contains"
238         request {
239             method GET()
240             url "/topology-inventory/v1alpha11/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
241         }
242         response {
243             status OK()
244             headers {
245                 contentType('application/json')
246             }
247             body('''{
248                 "items": [
249                     {
250                             "o-ran-smo-teiv-ran:NRCellDU": [
251                                 {
252                                     "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=9,ODUFunction=9,NRCellDU=1"
253                                 }
254                             ]
255                     },
256                     {
257                             "o-ran-smo-teiv-ran:NRCellDU": [
258                                 {
259                                     "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=9,ODUFunction=9,NRCellDU=2"
260                                 }
261                             ]
262                     },
263                     {
264                             "o-ran-smo-teiv-ran:NRCellDU": [
265                                 {
266                                     "id": "urn:3gpp:dn:SubNetwork=Europe,SubNetwork=Hungary,MeContext=1,ManagedElement=9,ODUFunction=9,NRCellDU=3"
267                                 }
268                             ]
269                     }
270                 ],
271                 "self": {
272                     "href": "/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
273                 },
274                 "first": {
275                     "href": "/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
276                 },
277                 "prev": {
278                     "href": "/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
279                 },
280                 "next": {
281                     "href": "/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
282                 },
283                 "last": {
284                     "href": "/domains/RAN/entity-types/NRCellDU/entities?offset=0&limit=100&scopeFilter=/provided-by-oduFunction/decorators[contains(@test-app-module:textdata, 'ORAN')]"
285                 },
286                 "totalCount": 3
287             }''')
288             bodyMatchers {
289                 jsonPath('$.items', byType {
290                     occurrence(3)
291                 })
292                 jsonPath('$.items[0].o-ran-smo-teiv-ran:NRCellDU[0].id', byEquality())
293                 jsonPath('$.items[1].o-ran-smo-teiv-ran:NRCellDU[0].id', byEquality())
294                 jsonPath('$.items[2].o-ran-smo-teiv-ran:NRCellDU[0].id', byEquality())
295             }
296         }
297     }
298 ]