RMR version update and H release step 1/2
[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         "regexp"
29         "strings"
30         "testing"
31 )
32
33 /*
34 Test permutations of x2 setup response to protobuf enb
35  */
36
37 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
38         InfoLevel := int8(4)
39         logger, _ := logger.InitLogger(InfoLevel)
40
41         var testCases = []struct {
42                 key       *entities.GlobalNbId
43                 gnb       string
44                 packedPdu string
45                 failure   error
46         }{
47                 {
48                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
49                         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}}}}}]",
50                         /*
51                 E2AP-PDU:
52                          successfulOutcome_t
53                           procedureCode_t = 0x24
54                           criticality_t = 0
55                           ENDCX2SetupResponse
56                            protocolIEs_t:
57                             ProtocolIE_Container_elm
58                              id_t = 0xf6
59                              criticality_t = 0
60                              RespondingNodeType-EndcX2Setup:
61                               respond_en_gNB_t:
62                                ProtocolIE_Container_elm
63                                 id_t = 0xfc
64                                 criticality_t = 0
65                                 GlobalGNB-ID
66                                  pLMN_Identity_t = 02 f8 29
67                                  gNB_ID_t:
68                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
69                                ProtocolIE_Container_elm
70                                 id_t = 0xfd
71                                 criticality_t = 0
72                                 ServedNRcellsENDCX2ManagementList:
73                                  ServedNRcellsENDCX2ManagementList_elm
74                                   servedNRCellInfo_t
75                                    nrpCI_t = 0x5
76                                    nrCellID_t
77                                     pLMN_Identity_t = 1e 3f 27
78                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
79                                    fiveGS_TAC_t = 3d 44 d3
80                                    configured_TAC_t = 4e 4f
81                                    broadcastPLMNs_t:
82                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
83                                    nrModeInfo_t:
84                                     tdd_t
85                                      nRFreqInfo_t
86                                       nRARFCN_t = 0x1
87                                       freqBandListNr_t:
88                                        freqBandListNr_t_elm
89                                         freqBandIndicatorNr_t = 0x16
90                                         supportedSULBandList_t:
91                                          supportedSULBandList_t_elm
92                                           freqBandIndicatorNr_t = 0xb
93                                       sULInformation_t
94                                        sUL_ARFCN_t = 0x2
95                                        sUL_TxBW_t
96                                         nRSCS_t = 0x2
97                                         nRNRB_t = 0xf
98                                      nR_TxBW_t
99                                       nRSCS_t = 0x1
100                                       nRNRB_t = 0x12
101                                    measurementTimingConfiguration_t = 3e 4e 5e
102                                  ServedNRcellsENDCX2ManagementList_elm
103                                   servedNRCellInfo_t
104                                    nrpCI_t = 0x5
105                                    nrCellID_t
106                                     pLMN_Identity_t = 1e 3f 27
107                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
108                                    fiveGS_TAC_t = 3d 44 d3
109                                    configured_TAC_t = 4e 4f
110                                    broadcastPLMNs_t:
111                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
112                                    nrModeInfo_t:
113                                     tdd_t
114                                      nRFreqInfo_t
115                                       nRARFCN_t = 0x1
116                                       freqBandListNr_t:
117                                        freqBandListNr_t_elm
118                                         freqBandIndicatorNr_t = 0x16
119                                         supportedSULBandList_t:
120                                          supportedSULBandList_t_elm
121                                           freqBandIndicatorNr_t = 0xb
122                                       sULInformation_t
123                                        sUL_ARFCN_t = 0x2
124                                        sUL_TxBW_t
125                                         nRSCS_t = 0x3
126                                         nRNRB_t = 0x10
127                                      nR_TxBW_t
128                                       nRSCS_t = 0
129                                       nRNRB_t = 0x11
130                                    measurementTimingConfiguration_t = 3e 4e 5e
131                                   nRNeighbourInfo_t:
132                                    NRNeighbour_Information_elm
133                                     nrpCI_t = 0x2c
134                                     nrCellID_t
135                                      pLMN_Identity_t = 1e 3f 27
136                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
137                                     measurementTimingConfiguration_t = 1e 3f 27
138                                     nRNeighbourModeInfo_t:
139                                      tdd_t
140                                       nRFreqInfo_t
141                                        nRARFCN_t = 0x1
142                                        freqBandListNr_t:
143                                         freqBandListNr_t_elm
144                                          freqBandIndicatorNr_t = 0x16
145                                          supportedSULBandList_t:
146                                           supportedSULBandList_t_elm
147                                            freqBandIndicatorNr_t = 0xb
148                                        sULInformation_t
149                                         sUL_ARFCN_t = 0x2
150                                         sUL_TxBW_t
151                                          nRSCS_t = 0
152                                          nRNRB_t = 0
153
154                         */
155                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
156                 {
157                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
158                         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}}}}}]",
159                         /*
160                         E2AP-PDU:
161                          successfulOutcome_t
162                           procedureCode_t = 0x24
163                           criticality_t = 0
164                           ENDCX2SetupResponse
165                            protocolIEs_t:
166                             ProtocolIE_Container_elm
167                              id_t = 0xf6
168                              criticality_t = 0
169                              RespondingNodeType-EndcX2Setup:
170                               respond_en_gNB_t:
171                                ProtocolIE_Container_elm
172                                 id_t = 0xfc
173                                 criticality_t = 0
174                                 GlobalGNB-ID
175                                  pLMN_Identity_t = 02 f8 29
176                                  gNB_ID_t:
177                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
178                                ProtocolIE_Container_elm
179                                 id_t = 0xfd
180                                 criticality_t = 0
181                                 ServedNRcellsENDCX2ManagementList:
182                                  ServedNRcellsENDCX2ManagementList_elm
183                                   servedNRCellInfo_t
184                                    nrpCI_t = 0x5
185                                    nrCellID_t
186                                     pLMN_Identity_t = 1e 3f 27
187                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
188                                    fiveGS_TAC_t = 3d 44 d3
189                                    configured_TAC_t = 4e 4f
190                                    broadcastPLMNs_t:
191                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
192                                    nrModeInfo_t:
193                                     tdd_t
194                                      nRFreqInfo_t
195                                       nRARFCN_t = 0x1
196                                       freqBandListNr_t:
197                                        freqBandListNr_t_elm
198                                         freqBandIndicatorNr_t = 0x16
199                                         supportedSULBandList_t:
200                                          supportedSULBandList_t_elm
201                                           freqBandIndicatorNr_t = 0xb
202                                       sULInformation_t
203                                        sUL_ARFCN_t = 0x2
204                                        sUL_TxBW_t
205                                         nRSCS_t = 0x1
206                                         nRNRB_t = 0xf
207                                      nR_TxBW_t
208                                       nRSCS_t = 0
209                                       nRNRB_t = 0x10
210                                    measurementTimingConfiguration_t = 3e 4e 5e
211                                   nRNeighbourInfo_t:
212                                    NRNeighbour_Information_elm
213                                     nrpCI_t = 0x2c
214                                     nrCellID_t
215                                      pLMN_Identity_t = 1e 3f 27
216                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
217                                     measurementTimingConfiguration_t = 1e 3f 27
218                                     nRNeighbourModeInfo_t:
219                                      tdd_t
220                                       nRFreqInfo_t
221                                        nRARFCN_t = 0x5
222                                        freqBandListNr_t:
223                                         freqBandListNr_t_elm
224                                          freqBandIndicatorNr_t = 0x16
225                                          supportedSULBandList_t:
226                                           supportedSULBandList_t_elm
227                                            freqBandIndicatorNr_t = 0xb
228                                        sULInformation_t
229                                         sUL_ARFCN_t = 0x6
230                                         sUL_TxBW_t
231                                          nRSCS_t = 0x3
232                                          nRNRB_t = 0x1
233
234                         */
235                         packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
236
237                 {
238                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
239                         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}}}}}]",
240                         /*
241                         E2AP-PDU:
242                          successfulOutcome_t
243                           procedureCode_t = 0x24
244                           criticality_t = 0
245                           ENDCX2SetupResponse
246                            protocolIEs_t:
247                             ProtocolIE_Container_elm
248                              id_t = 0xf6
249                              criticality_t = 0
250                              RespondingNodeType-EndcX2Setup:
251                               respond_en_gNB_t:
252                                ProtocolIE_Container_elm
253                                 id_t = 0xfc
254                                 criticality_t = 0
255                                 GlobalGNB-ID
256                                  pLMN_Identity_t = 02 f8 29
257                                  gNB_ID_t:
258                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
259                                ProtocolIE_Container_elm
260                                 id_t = 0xfd
261                                 criticality_t = 0
262                                 ServedNRcellsENDCX2ManagementList:
263                                  ServedNRcellsENDCX2ManagementList_elm
264                                   servedNRCellInfo_t
265                                    nrpCI_t = 0x5
266                                    nrCellID_t
267                                     pLMN_Identity_t = 1e 3f 27
268                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
269                                    fiveGS_TAC_t = 3d 44 d3
270                                    configured_TAC_t = 4e 4f
271                                    broadcastPLMNs_t:
272                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
273                                    nrModeInfo_t:
274                                     tdd_t
275                                      nRFreqInfo_t
276                                       nRARFCN_t = 0x1
277                                       freqBandListNr_t:
278                                        freqBandListNr_t_elm
279                                         freqBandIndicatorNr_t = 0x16
280                                         supportedSULBandList_t:
281                                          supportedSULBandList_t_elm
282                                           freqBandIndicatorNr_t = 0xb
283                                       sULInformation_t
284                                        sUL_ARFCN_t = 0x2
285                                        sUL_TxBW_t
286                                         nRSCS_t = 0x2
287                                         nRNRB_t = 0xf
288                                      nR_TxBW_t
289                                       nRSCS_t = 0x1
290                                       nRNRB_t = 0x12
291                                    measurementTimingConfiguration_t = 3e 4e 5e
292                                  ServedNRcellsENDCX2ManagementList_elm
293                                   servedNRCellInfo_t
294                                    nrpCI_t = 0x8
295                                    nrCellID_t
296                                     pLMN_Identity_t = 2e 3f 45
297                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
298                                    fiveGS_TAC_t = 4f aa 3c
299                                    configured_TAC_t = 1a 2f
300                                    broadcastPLMNs_t:
301                                     BroadcastPLMNs_Item_elm = 50 32 1e
302                                    nrModeInfo_t:
303                                     tdd_t
304                                      nRFreqInfo_t
305                                       nRARFCN_t = 0x4
306                                       freqBandListNr_t:
307                                        freqBandListNr_t_elm
308                                         freqBandIndicatorNr_t = 0x7
309                                         supportedSULBandList_t:
310                                          supportedSULBandList_t_elm
311                                           freqBandIndicatorNr_t = 0x3
312                                       sULInformation_t
313                                        sUL_ARFCN_t = 0x8
314                                        sUL_TxBW_t
315                                         nRSCS_t = 0x3
316                                         nRNRB_t = 0x10
317                                      nR_TxBW_t
318                                       nRSCS_t = 0
319                                       nRNRB_t = 0x11
320                                    measurementTimingConfiguration_t = 50 32 1e
321                                   nRNeighbourInfo_t:
322                                    NRNeighbour_Information_elm
323                                     nrpCI_t = 0x2c
324                                     nrCellID_t
325                                      pLMN_Identity_t = 1e 3f 27
326                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
327                                     measurementTimingConfiguration_t = 1e 3f 27
328                                     nRNeighbourModeInfo_t:
329                                      tdd_t
330                                       nRFreqInfo_t
331                                        nRARFCN_t = 0x1
332                                        freqBandListNr_t:
333                                         freqBandListNr_t_elm
334                                          freqBandIndicatorNr_t = 0x16
335                                          supportedSULBandList_t:
336                                           supportedSULBandList_t_elm
337                                            freqBandIndicatorNr_t = 0xb
338                                        sULInformation_t
339                                         sUL_ARFCN_t = 0x2
340                                         sUL_TxBW_t
341                                          nRSCS_t = 0
342                                          nRNRB_t = 0
343                         */
344                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
345
346                 {
347                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
348                         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}}}}}]",
349                         /*
350                         E2AP-PDU:
351                          successfulOutcome_t
352                           procedureCode_t = 0x24
353                           criticality_t = 0
354                           ENDCX2SetupResponse
355                            protocolIEs_t:
356                             ProtocolIE_Container_elm
357                              id_t = 0xf6
358                              criticality_t = 0
359                              RespondingNodeType-EndcX2Setup:
360                               respond_en_gNB_t:
361                                ProtocolIE_Container_elm
362                                 id_t = 0xfc
363                                 criticality_t = 0
364                                 GlobalGNB-ID
365                                  pLMN_Identity_t = 02 f8 29
366                                  gNB_ID_t:
367                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
368                                ProtocolIE_Container_elm
369                                 id_t = 0xfd
370                                 criticality_t = 0
371                                 ServedNRcellsENDCX2ManagementList:
372                                  ServedNRcellsENDCX2ManagementList_elm
373                                   servedNRCellInfo_t
374                                    nrpCI_t = 0x5
375                                    nrCellID_t
376                                     pLMN_Identity_t = 1e 3f 27
377                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
378                                    broadcastPLMNs_t:
379                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
380                                    nrModeInfo_t:
381                                     fdd_t
382                                      ul_NRFreqInfo_t
383                                       nRARFCN_t = 0x5
384                                       freqBandListNr_t:
385                                        freqBandListNr_t_elm
386                                         freqBandIndicatorNr_t = 0x2c
387                                         supportedSULBandList_t:
388                                          supportedSULBandList_t_elm
389                                           freqBandIndicatorNr_t = 0x21
390                                      dl_NRFreqInfo_t
391                                       nRARFCN_t = 0x1
392                                       freqBandListNr_t:
393                                        freqBandListNr_t_elm
394                                         freqBandIndicatorNr_t = 0x16
395                                         supportedSULBandList_t:
396                                          supportedSULBandList_t_elm
397                                           freqBandIndicatorNr_t = 0xb
398                                      ul_NR_TxBW_t
399                                       nRSCS_t = 0x3
400                                       nRNRB_t = 0
401                                      dl_NR_TxBW_t
402                                       nRSCS_t = 0
403                                       nRNRB_t = 0x13
404                                    measurementTimingConfiguration_t = 01 02 03
405                                   nRNeighbourInfo_t:
406                                    NRNeighbour_Information_elm
407                                     nrpCI_t = 0x2c
408                                     nrCellID_t
409                                      pLMN_Identity_t = 1e 3f 27
410                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
411                                     measurementTimingConfiguration_t = 01 02 03
412                                     nRNeighbourModeInfo_t:
413                                      fdd_t
414                                       ul_NRFreqInfo_t
415                                        nRARFCN_t = 0x5
416                                        freqBandListNr_t:
417                                         freqBandListNr_t_elm
418                                          freqBandIndicatorNr_t = 0x16
419                                          supportedSULBandList_t:
420                                           supportedSULBandList_t_elm
421                                            freqBandIndicatorNr_t = 0xb
422                                       dl_NRFreqInfo_t
423                                        nRARFCN_t = 0x1
424                                        freqBandListNr_t:
425                                         freqBandListNr_t_elm
426                                          freqBandIndicatorNr_t = 0x16
427                                          supportedSULBandList_t:
428                                           supportedSULBandList_t_elm
429                                            freqBandIndicatorNr_t = 0xb
430
431
432                         */
433                         packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
434
435
436                 {
437                         key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
438                         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}}}}}]",
439                         /*
440                         E2AP-PDU:
441                          successfulOutcome_t
442                           procedureCode_t = 0x24
443                           criticality_t = 0
444                           ENDCX2SetupResponse
445                            protocolIEs_t:
446                             ProtocolIE_Container_elm
447                              id_t = 0xf6
448                              criticality_t = 0
449                              RespondingNodeType-EndcX2Setup:
450                               respond_en_gNB_t:
451                                ProtocolIE_Container_elm
452                                 id_t = 0xfc
453                                 criticality_t = 0
454                                 GlobalGNB-ID
455                                  pLMN_Identity_t = 04 a5 c1
456                                  gNB_ID_t:
457                                   gNB_ID_t = 4f c5 2b ff (32 bits)
458                                ProtocolIE_Container_elm
459                                 id_t = 0xfd
460                                 criticality_t = 0
461                                 ServedNRcellsENDCX2ManagementList:
462                                  ServedNRcellsENDCX2ManagementList_elm
463                                   servedNRCellInfo_t
464                                    nrpCI_t = 0x9
465                                    nrCellID_t
466                                     pLMN_Identity_t = ae af a7
467                                     nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
468                                    fiveGS_TAC_t = 7d 47 73
469                                    configured_TAC_t = 47 7f
470                                    broadcastPLMNs_t:
471                                     BroadcastPLMNs_Item_elm = 7e 7e 7e
472                                    nrModeInfo_t:
473                                     tdd_t
474                                      nRFreqInfo_t
475                                       nRARFCN_t = 0x8
476                                       freqBandListNr_t:
477                                        freqBandListNr_t_elm
478                                         freqBandIndicatorNr_t = 0x16
479                                         supportedSULBandList_t:
480                                          supportedSULBandList_t_elm
481                                           freqBandIndicatorNr_t = 0xb
482                                       sULInformation_t
483                                        sUL_ARFCN_t = 0x9
484                                        sUL_TxBW_t
485                                         nRSCS_t = 0
486                                         nRNRB_t = 0x10
487                                      nR_TxBW_t
488                                       nRSCS_t = 0x2
489                                       nRNRB_t = 0x1
490                                    measurementTimingConfiguration_t = 7e 7e 7e
491                                   nRNeighbourInfo_t:
492                                    NRNeighbour_Information_elm
493                                     nrpCI_t = 0x2c
494                                     nrCellID_t
495                                      pLMN_Identity_t = 5a 5f f1
496                                      nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
497                                     measurementTimingConfiguration_t = 5a 5f f1
498                                     nRNeighbourModeInfo_t:
499                                      tdd_t
500                                       nRFreqInfo_t
501                                        nRARFCN_t = 0x5
502                                        freqBandListNr_t:
503                                         freqBandListNr_t_elm
504                                          freqBandIndicatorNr_t = 0x4
505                                          supportedSULBandList_t:
506                                           supportedSULBandList_t_elm
507                                            freqBandIndicatorNr_t = 0x3
508                                        sULInformation_t
509                                         sUL_ARFCN_t = 0x6
510                                         sUL_TxBW_t
511                                          nRSCS_t = 0x1
512                                          nRNRB_t = 0x1
513                                    NRNeighbour_Information_elm
514                                     nrpCI_t = 0x9
515                                     nrCellID_t
516                                      pLMN_Identity_t = 5d 5c aa
517                                      nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
518                                     measurementTimingConfiguration_t = 5d 5c aa
519                                     nRNeighbourModeInfo_t:
520                                      tdd_t
521                                       nRFreqInfo_t
522                                        nRARFCN_t = 0x7
523                                        freqBandListNr_t:
524                                         freqBandListNr_t_elm
525                                          freqBandIndicatorNr_t = 0x3
526                                          supportedSULBandList_t:
527                                           supportedSULBandList_t_elm
528                                            freqBandIndicatorNr_t = 0x1
529                                        sULInformation_t
530                                         sUL_ARFCN_t = 0x8
531                                         sUL_TxBW_t
532                                          nRSCS_t = 0x3
533                                          nRNRB_t = 0x3
534                         */
535                         packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
536
537                 {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
538                         /*
539                         E2AP-PDU:
540                          successfulOutcome_t
541                           procedureCode_t = 0x24
542                           criticality_t = 0
543                           ENDCX2SetupResponse
544                            protocolIEs_t:
545                             ProtocolIE_Container_elm
546                              id_t = 0xf6
547                              criticality_t = 0
548                              RespondingNodeType-EndcX2Setup:
549                               respond_en_gNB_t:
550                                ProtocolIE_Container_elm
551                                 id_t = 0xfc
552                                 criticality_t = 0
553                                 GlobalGNB-ID
554                                  pLMN_Identity_t = 02 f8 29
555                                  gNB_ID_t:
556                                   gNB_ID_t = 4a 95 2a aa (32 bits)
557                         */
558                         packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
559
560                         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*/),},
561         }
562
563         converter := NewEndcSetupResponseConverter(logger)
564
565         for _, tc := range testCases {
566                 t.Run(tc.packedPdu, func(t *testing.T) {
567
568                         var payload []byte
569
570                         _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
571
572                         if err != nil {
573                                 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
574                         }
575
576                         key, gnb, err := converter.UnpackEndcSetupResponseAndExtract(payload)
577
578                         if err != nil {
579                                 if tc.failure == nil {
580                                         t.Errorf("want: success, got: error: %v\n", err)
581                                 } else {
582                                         if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
583                                                 t.Errorf("want: %s, got: %s", tc.failure, err)
584                                         }
585                                 }
586                         }
587
588                         if key == nil {
589                                 if tc.failure == nil {
590                                         t.Errorf("want: key=%v, got: empty key", tc.key)
591                                 }
592                         } else {
593                                 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
594                                         t.Errorf("want: key=%v, got: %v", tc.key, key)
595                                 }
596                         }
597
598                         if gnb == nil {
599                                 if tc.failure == nil {
600                                         t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
601                                 }
602                         } else {
603                                 nb := &entities.NodebInfo{}
604                                 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
605                                 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
606                                 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
607
608                                 space := regexp.MustCompile(`\s+`)
609                                 s1 := space.ReplaceAllString(gnbStr, " ")
610                                 s2 := space.ReplaceAllString(tc.gnb," ")
611
612                                 if !strings.EqualFold(s1, s2) {
613                                         t.Errorf("want: [%s], got: [%s]", tc.gnb, gnbStr)
614                                 }
615
616                         }
617                 })
618         }
619 }