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