f68e4c0eb7816a02d5ec1734f0453d1c22f8714d
[ric-plt/e2mgr.git] / E2Manager / converters / endc_setup_response_converter_test.go
1 /*
2  *   Copyright (c) 2019 AT&T Intellectual Property.
3  *
4  *   Licensed under the Apache License, Version 2.0 (the "License");
5  *   you may not use this file except in compliance with the License.
6  *   You may obtain a copy of the License at
7  *
8  *       http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *   Unless required by applicable law or agreed to in writing, software
11  *   distributed under the License is distributed on an "AS IS" BASIS,
12  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *   See the License for the specific language governing permissions and
14  *   limitations under the License.
15  */
16
17 /*
18  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19  * platform project (RICP).
20  */
21
22 package converters
23
24 import (
25         "e2mgr/logger"
26         "fmt"
27         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
28         "strings"
29         "testing"
30 )
31
32 /*
33 Test permutations of x2 setup response to protobuf enb
34  */
35
36 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
37         logger, _ := logger.InitLogger(logger.InfoLevel)
38
39         var testCases = []struct {
40                 key       *entities.GlobalNbId
41                 gnb       string
42                 packedPdu string
43                 failure   error
44         }{
45                 {
46                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
47                         gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB133 > > > >  served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB132 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB11 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
48                         /*
49                 E2AP-PDU:
50                          successfulOutcome_t
51                           procedureCode_t = 0x24
52                           criticality_t = 0
53                           ENDCX2SetupResponse
54                            protocolIEs_t:
55                             ProtocolIE_Container_elm
56                              id_t = 0xf6
57                              criticality_t = 0
58                              RespondingNodeType-EndcX2Setup:
59                               respond_en_gNB_t:
60                                ProtocolIE_Container_elm
61                                 id_t = 0xfc
62                                 criticality_t = 0
63                                 GlobalGNB-ID
64                                  pLMN_Identity_t = 02 f8 29
65                                  gNB_ID_t:
66                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
67                                ProtocolIE_Container_elm
68                                 id_t = 0xfd
69                                 criticality_t = 0
70                                 ServedNRcellsENDCX2ManagementList:
71                                  ServedNRcellsENDCX2ManagementList_elm
72                                   servedNRCellInfo_t
73                                    nrpCI_t = 0x5
74                                    nrCellID_t
75                                     pLMN_Identity_t = 1e 3f 27
76                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
77                                    fiveGS_TAC_t = 3d 44 d3
78                                    configured_TAC_t = 4e 4f
79                                    broadcastPLMNs_t:
80                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
81                                    nrModeInfo_t:
82                                     tdd_t
83                                      nRFreqInfo_t
84                                       nRARFCN_t = 0x1
85                                       freqBandListNr_t:
86                                        freqBandListNr_t_elm
87                                         freqBandIndicatorNr_t = 0x16
88                                         supportedSULBandList_t:
89                                          supportedSULBandList_t_elm
90                                           freqBandIndicatorNr_t = 0xb
91                                       sULInformation_t
92                                        sUL_ARFCN_t = 0x2
93                                        sUL_TxBW_t
94                                         nRSCS_t = 0x2
95                                         nRNRB_t = 0xf
96                                      nR_TxBW_t
97                                       nRSCS_t = 0x1
98                                       nRNRB_t = 0x12
99                                    measurementTimingConfiguration_t = 3e 4e 5e
100                                  ServedNRcellsENDCX2ManagementList_elm
101                                   servedNRCellInfo_t
102                                    nrpCI_t = 0x5
103                                    nrCellID_t
104                                     pLMN_Identity_t = 1e 3f 27
105                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
106                                    fiveGS_TAC_t = 3d 44 d3
107                                    configured_TAC_t = 4e 4f
108                                    broadcastPLMNs_t:
109                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
110                                    nrModeInfo_t:
111                                     tdd_t
112                                      nRFreqInfo_t
113                                       nRARFCN_t = 0x1
114                                       freqBandListNr_t:
115                                        freqBandListNr_t_elm
116                                         freqBandIndicatorNr_t = 0x16
117                                         supportedSULBandList_t:
118                                          supportedSULBandList_t_elm
119                                           freqBandIndicatorNr_t = 0xb
120                                       sULInformation_t
121                                        sUL_ARFCN_t = 0x2
122                                        sUL_TxBW_t
123                                         nRSCS_t = 0x3
124                                         nRNRB_t = 0x10
125                                      nR_TxBW_t
126                                       nRSCS_t = 0
127                                       nRNRB_t = 0x11
128                                    measurementTimingConfiguration_t = 3e 4e 5e
129                                   nRNeighbourInfo_t:
130                                    NRNeighbour_Information_elm
131                                     nrpCI_t = 0x2c
132                                     nrCellID_t
133                                      pLMN_Identity_t = 1e 3f 27
134                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
135                                     measurementTimingConfiguration_t = 1e 3f 27
136                                     nRNeighbourModeInfo_t:
137                                      tdd_t
138                                       nRFreqInfo_t
139                                        nRARFCN_t = 0x1
140                                        freqBandListNr_t:
141                                         freqBandListNr_t_elm
142                                          freqBandIndicatorNr_t = 0x16
143                                          supportedSULBandList_t:
144                                           supportedSULBandList_t_elm
145                                            freqBandIndicatorNr_t = 0xb
146                                        sULInformation_t
147                                         sUL_ARFCN_t = 0x2
148                                         sUL_TxBW_t
149                                          nRSCS_t = 0
150                                          nRNRB_t = 0
151
152                         */
153                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
154                 {
155                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
156                         gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
157                         /*
158                         E2AP-PDU:
159                          successfulOutcome_t
160                           procedureCode_t = 0x24
161                           criticality_t = 0
162                           ENDCX2SetupResponse
163                            protocolIEs_t:
164                             ProtocolIE_Container_elm
165                              id_t = 0xf6
166                              criticality_t = 0
167                              RespondingNodeType-EndcX2Setup:
168                               respond_en_gNB_t:
169                                ProtocolIE_Container_elm
170                                 id_t = 0xfc
171                                 criticality_t = 0
172                                 GlobalGNB-ID
173                                  pLMN_Identity_t = 02 f8 29
174                                  gNB_ID_t:
175                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
176                                ProtocolIE_Container_elm
177                                 id_t = 0xfd
178                                 criticality_t = 0
179                                 ServedNRcellsENDCX2ManagementList:
180                                  ServedNRcellsENDCX2ManagementList_elm
181                                   servedNRCellInfo_t
182                                    nrpCI_t = 0x5
183                                    nrCellID_t
184                                     pLMN_Identity_t = 1e 3f 27
185                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
186                                    fiveGS_TAC_t = 3d 44 d3
187                                    configured_TAC_t = 4e 4f
188                                    broadcastPLMNs_t:
189                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
190                                    nrModeInfo_t:
191                                     tdd_t
192                                      nRFreqInfo_t
193                                       nRARFCN_t = 0x1
194                                       freqBandListNr_t:
195                                        freqBandListNr_t_elm
196                                         freqBandIndicatorNr_t = 0x16
197                                         supportedSULBandList_t:
198                                          supportedSULBandList_t_elm
199                                           freqBandIndicatorNr_t = 0xb
200                                       sULInformation_t
201                                        sUL_ARFCN_t = 0x2
202                                        sUL_TxBW_t
203                                         nRSCS_t = 0x1
204                                         nRNRB_t = 0xf
205                                      nR_TxBW_t
206                                       nRSCS_t = 0
207                                       nRNRB_t = 0x10
208                                    measurementTimingConfiguration_t = 3e 4e 5e
209                                   nRNeighbourInfo_t:
210                                    NRNeighbour_Information_elm
211                                     nrpCI_t = 0x2c
212                                     nrCellID_t
213                                      pLMN_Identity_t = 1e 3f 27
214                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
215                                     measurementTimingConfiguration_t = 1e 3f 27
216                                     nRNeighbourModeInfo_t:
217                                      tdd_t
218                                       nRFreqInfo_t
219                                        nRARFCN_t = 0x5
220                                        freqBandListNr_t:
221                                         freqBandListNr_t_elm
222                                          freqBandIndicatorNr_t = 0x16
223                                          supportedSULBandList_t:
224                                           supportedSULBandList_t_elm
225                                            freqBandIndicatorNr_t = 0xb
226                                        sULInformation_t
227                                         sUL_ARFCN_t = 0x6
228                                         sUL_TxBW_t
229                                          nRSCS_t = 0x3
230                                          nRNRB_t = 0x1
231
232                         */
233                         packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
234
235                 {
236                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
237                         gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB133 > > > >  served_nr_cell_information:<nr_pci:8 cell_id:\"2e3f45:1f2e3d4ff0\" stac5g:\"4faa3c\" configured_stac:\"1a2f\" served_plmns:\"50321e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:4 sulInformation:<sul_ar_fcn:8 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:7 supported_sul_bands:3 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB132 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB11 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
238                         /*
239                         E2AP-PDU:
240                          successfulOutcome_t
241                           procedureCode_t = 0x24
242                           criticality_t = 0
243                           ENDCX2SetupResponse
244                            protocolIEs_t:
245                             ProtocolIE_Container_elm
246                              id_t = 0xf6
247                              criticality_t = 0
248                              RespondingNodeType-EndcX2Setup:
249                               respond_en_gNB_t:
250                                ProtocolIE_Container_elm
251                                 id_t = 0xfc
252                                 criticality_t = 0
253                                 GlobalGNB-ID
254                                  pLMN_Identity_t = 02 f8 29
255                                  gNB_ID_t:
256                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
257                                ProtocolIE_Container_elm
258                                 id_t = 0xfd
259                                 criticality_t = 0
260                                 ServedNRcellsENDCX2ManagementList:
261                                  ServedNRcellsENDCX2ManagementList_elm
262                                   servedNRCellInfo_t
263                                    nrpCI_t = 0x5
264                                    nrCellID_t
265                                     pLMN_Identity_t = 1e 3f 27
266                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
267                                    fiveGS_TAC_t = 3d 44 d3
268                                    configured_TAC_t = 4e 4f
269                                    broadcastPLMNs_t:
270                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
271                                    nrModeInfo_t:
272                                     tdd_t
273                                      nRFreqInfo_t
274                                       nRARFCN_t = 0x1
275                                       freqBandListNr_t:
276                                        freqBandListNr_t_elm
277                                         freqBandIndicatorNr_t = 0x16
278                                         supportedSULBandList_t:
279                                          supportedSULBandList_t_elm
280                                           freqBandIndicatorNr_t = 0xb
281                                       sULInformation_t
282                                        sUL_ARFCN_t = 0x2
283                                        sUL_TxBW_t
284                                         nRSCS_t = 0x2
285                                         nRNRB_t = 0xf
286                                      nR_TxBW_t
287                                       nRSCS_t = 0x1
288                                       nRNRB_t = 0x12
289                                    measurementTimingConfiguration_t = 3e 4e 5e
290                                  ServedNRcellsENDCX2ManagementList_elm
291                                   servedNRCellInfo_t
292                                    nrpCI_t = 0x8
293                                    nrCellID_t
294                                     pLMN_Identity_t = 2e 3f 45
295                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
296                                    fiveGS_TAC_t = 4f aa 3c
297                                    configured_TAC_t = 1a 2f
298                                    broadcastPLMNs_t:
299                                     BroadcastPLMNs_Item_elm = 50 32 1e
300                                    nrModeInfo_t:
301                                     tdd_t
302                                      nRFreqInfo_t
303                                       nRARFCN_t = 0x4
304                                       freqBandListNr_t:
305                                        freqBandListNr_t_elm
306                                         freqBandIndicatorNr_t = 0x7
307                                         supportedSULBandList_t:
308                                          supportedSULBandList_t_elm
309                                           freqBandIndicatorNr_t = 0x3
310                                       sULInformation_t
311                                        sUL_ARFCN_t = 0x8
312                                        sUL_TxBW_t
313                                         nRSCS_t = 0x3
314                                         nRNRB_t = 0x10
315                                      nR_TxBW_t
316                                       nRSCS_t = 0
317                                       nRNRB_t = 0x11
318                                    measurementTimingConfiguration_t = 50 32 1e
319                                   nRNeighbourInfo_t:
320                                    NRNeighbour_Information_elm
321                                     nrpCI_t = 0x2c
322                                     nrCellID_t
323                                      pLMN_Identity_t = 1e 3f 27
324                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
325                                     measurementTimingConfiguration_t = 1e 3f 27
326                                     nRNeighbourModeInfo_t:
327                                      tdd_t
328                                       nRFreqInfo_t
329                                        nRARFCN_t = 0x1
330                                        freqBandListNr_t:
331                                         freqBandListNr_t_elm
332                                          freqBandIndicatorNr_t = 0x16
333                                          supportedSULBandList_t:
334                                           supportedSULBandList_t_elm
335                                            freqBandIndicatorNr_t = 0xb
336                                        sULInformation_t
337                                         sUL_ARFCN_t = 0x2
338                                         sUL_TxBW_t
339                                          nRSCS_t = 0
340                                          nRNRB_t = 0
341                         */
342                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
343
344                 {
345                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
346                         gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" served_plmns:\"3e4e5e\" nr_mode:FDD choice_nr_mode:<fdd:<ul_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:44 supported_sul_bands:33 > > dl_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > ul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB11 > dl_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB135 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:FDD choice_nr_mode:<fdd:<ular_fcn_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > dlar_fcn_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
347                         /*
348                         E2AP-PDU:
349                          successfulOutcome_t
350                           procedureCode_t = 0x24
351                           criticality_t = 0
352                           ENDCX2SetupResponse
353                            protocolIEs_t:
354                             ProtocolIE_Container_elm
355                              id_t = 0xf6
356                              criticality_t = 0
357                              RespondingNodeType-EndcX2Setup:
358                               respond_en_gNB_t:
359                                ProtocolIE_Container_elm
360                                 id_t = 0xfc
361                                 criticality_t = 0
362                                 GlobalGNB-ID
363                                  pLMN_Identity_t = 02 f8 29
364                                  gNB_ID_t:
365                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
366                                ProtocolIE_Container_elm
367                                 id_t = 0xfd
368                                 criticality_t = 0
369                                 ServedNRcellsENDCX2ManagementList:
370                                  ServedNRcellsENDCX2ManagementList_elm
371                                   servedNRCellInfo_t
372                                    nrpCI_t = 0x5
373                                    nrCellID_t
374                                     pLMN_Identity_t = 1e 3f 27
375                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
376                                    broadcastPLMNs_t:
377                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
378                                    nrModeInfo_t:
379                                     fdd_t
380                                      ul_NRFreqInfo_t
381                                       nRARFCN_t = 0x5
382                                       freqBandListNr_t:
383                                        freqBandListNr_t_elm
384                                         freqBandIndicatorNr_t = 0x2c
385                                         supportedSULBandList_t:
386                                          supportedSULBandList_t_elm
387                                           freqBandIndicatorNr_t = 0x21
388                                      dl_NRFreqInfo_t
389                                       nRARFCN_t = 0x1
390                                       freqBandListNr_t:
391                                        freqBandListNr_t_elm
392                                         freqBandIndicatorNr_t = 0x16
393                                         supportedSULBandList_t:
394                                          supportedSULBandList_t_elm
395                                           freqBandIndicatorNr_t = 0xb
396                                      ul_NR_TxBW_t
397                                       nRSCS_t = 0x3
398                                       nRNRB_t = 0
399                                      dl_NR_TxBW_t
400                                       nRSCS_t = 0
401                                       nRNRB_t = 0x13
402                                    measurementTimingConfiguration_t = 01 02 03
403                                   nRNeighbourInfo_t:
404                                    NRNeighbour_Information_elm
405                                     nrpCI_t = 0x2c
406                                     nrCellID_t
407                                      pLMN_Identity_t = 1e 3f 27
408                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
409                                     measurementTimingConfiguration_t = 01 02 03
410                                     nRNeighbourModeInfo_t:
411                                      fdd_t
412                                       ul_NRFreqInfo_t
413                                        nRARFCN_t = 0x5
414                                        freqBandListNr_t:
415                                         freqBandListNr_t_elm
416                                          freqBandIndicatorNr_t = 0x16
417                                          supportedSULBandList_t:
418                                           supportedSULBandList_t_elm
419                                            freqBandIndicatorNr_t = 0xb
420                                       dl_NRFreqInfo_t
421                                        nRARFCN_t = 0x1
422                                        freqBandListNr_t:
423                                         freqBandListNr_t_elm
424                                          freqBandIndicatorNr_t = 0x16
425                                          supportedSULBandList_t:
426                                           supportedSULBandList_t_elm
427                                            freqBandIndicatorNr_t = 0xb
428
429
430                         */
431                         packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
432
433
434                 {
435                         key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
436                         gnb: "CONNECTED [served_nr_cell_information:<nr_pci:9 cell_id:\"aeafa7:2a3e3b4cd0\" stac5g:\"7d4773\" configured_stac:\"477f\" served_plmns:\"7e7e7e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:8 sulInformation:<sul_ar_fcn:9 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB18 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"5a5ff1:2a3e3b4cd0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:4 supported_sul_bands:3 > > > > > nr_neighbour_infos:<nr_pci:9 nr_cgi:\"5d5caa:af3e354ac0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:7 sulInformation:<sul_ar_fcn:8 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB25 > > frequency_bands:<nr_frequency_band:3 supported_sul_bands:1 > > > > > ]",
437                         /*
438                         E2AP-PDU:
439                          successfulOutcome_t
440                           procedureCode_t = 0x24
441                           criticality_t = 0
442                           ENDCX2SetupResponse
443                            protocolIEs_t:
444                             ProtocolIE_Container_elm
445                              id_t = 0xf6
446                              criticality_t = 0
447                              RespondingNodeType-EndcX2Setup:
448                               respond_en_gNB_t:
449                                ProtocolIE_Container_elm
450                                 id_t = 0xfc
451                                 criticality_t = 0
452                                 GlobalGNB-ID
453                                  pLMN_Identity_t = 04 a5 c1
454                                  gNB_ID_t:
455                                   gNB_ID_t = 4f c5 2b ff (32 bits)
456                                ProtocolIE_Container_elm
457                                 id_t = 0xfd
458                                 criticality_t = 0
459                                 ServedNRcellsENDCX2ManagementList:
460                                  ServedNRcellsENDCX2ManagementList_elm
461                                   servedNRCellInfo_t
462                                    nrpCI_t = 0x9
463                                    nrCellID_t
464                                     pLMN_Identity_t = ae af a7
465                                     nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
466                                    fiveGS_TAC_t = 7d 47 73
467                                    configured_TAC_t = 47 7f
468                                    broadcastPLMNs_t:
469                                     BroadcastPLMNs_Item_elm = 7e 7e 7e
470                                    nrModeInfo_t:
471                                     tdd_t
472                                      nRFreqInfo_t
473                                       nRARFCN_t = 0x8
474                                       freqBandListNr_t:
475                                        freqBandListNr_t_elm
476                                         freqBandIndicatorNr_t = 0x16
477                                         supportedSULBandList_t:
478                                          supportedSULBandList_t_elm
479                                           freqBandIndicatorNr_t = 0xb
480                                       sULInformation_t
481                                        sUL_ARFCN_t = 0x9
482                                        sUL_TxBW_t
483                                         nRSCS_t = 0
484                                         nRNRB_t = 0x10
485                                      nR_TxBW_t
486                                       nRSCS_t = 0x2
487                                       nRNRB_t = 0x1
488                                    measurementTimingConfiguration_t = 7e 7e 7e
489                                   nRNeighbourInfo_t:
490                                    NRNeighbour_Information_elm
491                                     nrpCI_t = 0x2c
492                                     nrCellID_t
493                                      pLMN_Identity_t = 5a 5f f1
494                                      nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
495                                     measurementTimingConfiguration_t = 5a 5f f1
496                                     nRNeighbourModeInfo_t:
497                                      tdd_t
498                                       nRFreqInfo_t
499                                        nRARFCN_t = 0x5
500                                        freqBandListNr_t:
501                                         freqBandListNr_t_elm
502                                          freqBandIndicatorNr_t = 0x4
503                                          supportedSULBandList_t:
504                                           supportedSULBandList_t_elm
505                                            freqBandIndicatorNr_t = 0x3
506                                        sULInformation_t
507                                         sUL_ARFCN_t = 0x6
508                                         sUL_TxBW_t
509                                          nRSCS_t = 0x1
510                                          nRNRB_t = 0x1
511                                    NRNeighbour_Information_elm
512                                     nrpCI_t = 0x9
513                                     nrCellID_t
514                                      pLMN_Identity_t = 5d 5c aa
515                                      nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
516                                     measurementTimingConfiguration_t = 5d 5c aa
517                                     nRNeighbourModeInfo_t:
518                                      tdd_t
519                                       nRFreqInfo_t
520                                        nRARFCN_t = 0x7
521                                        freqBandListNr_t:
522                                         freqBandListNr_t_elm
523                                          freqBandIndicatorNr_t = 0x3
524                                          supportedSULBandList_t:
525                                           supportedSULBandList_t_elm
526                                            freqBandIndicatorNr_t = 0x1
527                                        sULInformation_t
528                                         sUL_ARFCN_t = 0x8
529                                         sUL_TxBW_t
530                                          nRSCS_t = 0x3
531                                          nRNRB_t = 0x3
532                         */
533                         packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
534
535                 {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
536                         /*
537                         E2AP-PDU:
538                          successfulOutcome_t
539                           procedureCode_t = 0x24
540                           criticality_t = 0
541                           ENDCX2SetupResponse
542                            protocolIEs_t:
543                             ProtocolIE_Container_elm
544                              id_t = 0xf6
545                              criticality_t = 0
546                              RespondingNodeType-EndcX2Setup:
547                               respond_en_gNB_t:
548                                ProtocolIE_Container_elm
549                                 id_t = 0xfc
550                                 criticality_t = 0
551                                 GlobalGNB-ID
552                                  pLMN_Identity_t = 02 f8 29
553                                  gNB_ID_t:
554                                   gNB_ID_t = 4a 95 2a aa (32 bits)
555                         */
556                         packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
557
558                         failure: fmt.Errorf("getList for path [successfulOutcome_t ENDCX2SetupResponse protocolIEs_t ProtocolIE_Container_elm RespondingNodeType-EndcX2Setup respond_en_gNB_t ProtocolIE_Container_elm ServedNRcellsENDCX2ManagementList ServedNRcellsENDCX2ManagementList_elm servedNRCellInfo_t nrpCI_t] failed, rc = 1" /*NO_ITEMS*/),},
559         }
560
561         converter := NewEndcSetupResponseConverter(logger)
562
563         for _, tc := range testCases {
564                 t.Run(tc.packedPdu, func(t *testing.T) {
565
566                         var payload []byte
567
568                         _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
569
570                         if err != nil {
571                                 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
572                         }
573
574                         key, gnb, err := converter.UnpackEndcSetupResponseAndExtract(payload)
575
576                         if err != nil {
577                                 if tc.failure == nil {
578                                         t.Errorf("want: success, got: error: %v\n", err)
579                                 } else {
580                                         if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
581                                                 t.Errorf("want: %s, got: %s", tc.failure, err)
582                                         }
583                                 }
584                         }
585
586                         if key == nil {
587                                 if tc.failure == nil {
588                                         t.Errorf("want: key=%v, got: empty key", tc.key)
589                                 }
590                         } else {
591                                 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
592                                         t.Errorf("want: key=%v, got: %v", tc.key, key)
593                                 }
594                         }
595
596                         if gnb == nil {
597                                 if tc.failure == nil {
598                                         t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
599                                 }
600                         } else {
601                                 nb := &entities.NodebInfo{}
602                                 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
603                                 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
604                                 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
605                                 if !strings.EqualFold(gnbStr, tc.gnb) {
606                                         t.Errorf("want: enb=%s, got: %s", tc.gnb, gnbStr)
607                                 }
608
609                         }
610                 })
611         }
612 }