aa206375fdc86b4c20dfe5cc32ad5cf10b753020
[ric-plt/submgr.git] / e2ap / pkg / e2ap / e2ap_tests / msg_e2ap_subscriptiondelete.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 package e2ap_tests
21
22 import (
23         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
24         "testing"
25 )
26
27 //-----------------------------------------------------------------------------
28 //
29 //-----------------------------------------------------------------------------
30
31 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteRequest(t *testing.T) {
32
33         testCtxt.SetDesc("SubsDeleteReq")
34
35         e2SubsReq := testCtxt.packerif.NewPackerSubscriptionDeleteRequest()
36
37         testCtxt.testPrint("########## ##########")
38         testCtxt.testPrint("init")
39
40         areqenc := e2ap.E2APSubscriptionDeleteRequest{}
41         areqenc.RequestId.Id = 1
42         areqenc.RequestId.Seq = 22
43         areqenc.FunctionId = 33
44
45         seterr := e2SubsReq.Set(&areqenc)
46         if seterr != nil {
47                 testCtxt.testError(t, "set err: %s", seterr.Error())
48                 return
49         }
50         testCtxt.testPrint("print:\n%s", e2SubsReq.String())
51         testCtxt.testPrint("pack")
52         err, packedMsg := e2SubsReq.Pack(nil)
53         if err != nil {
54                 testCtxt.testError(t, "Pack failed: %s", err.Error())
55                 return
56         }
57         testCtxt.testPrint("unpack")
58         err = e2SubsReq.UnPack(packedMsg)
59         if err != nil {
60                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
61                 return
62         }
63         testCtxt.testPrint("print:\n%s", e2SubsReq.String())
64         geterr, areqdec := e2SubsReq.Get()
65         if geterr != nil {
66                 testCtxt.testError(t, "get nil: %s", geterr.Error())
67                 return
68         }
69         testCtxt.testValueEquality(t, "msg", &areqenc, areqdec)
70 }
71
72 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteResponse(t *testing.T) {
73
74         testCtxt.SetDesc("SubsDeleteResp")
75
76         e2SubsResp := testCtxt.packerif.NewPackerSubscriptionDeleteResponse()
77
78         testCtxt.testPrint("########## ##########")
79         testCtxt.testPrint("init")
80
81         arespenc := e2ap.E2APSubscriptionDeleteResponse{}
82         arespenc.RequestId.Id = 1
83         arespenc.RequestId.Seq = 22
84         arespenc.FunctionId = 33
85
86         seterr := e2SubsResp.Set(&arespenc)
87         if seterr != nil {
88                 testCtxt.testError(t, "set err: %s", seterr.Error())
89                 return
90         }
91         testCtxt.testPrint("print:\n%s", e2SubsResp.String())
92         testCtxt.testPrint("pack")
93         err, packedMsg := e2SubsResp.Pack(nil)
94         if err != nil {
95                 testCtxt.testError(t, "Pack failed: %s", err.Error())
96                 return
97         }
98         testCtxt.testPrint("unpack")
99         err = e2SubsResp.UnPack(packedMsg)
100         if err != nil {
101                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
102                 return
103         }
104         testCtxt.testPrint("print:\n%s", e2SubsResp.String())
105         geterr, arespdec := e2SubsResp.Get()
106         if geterr != nil {
107                 testCtxt.testError(t, "get nil: %s", geterr.Error())
108                 return
109         }
110         testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
111 }
112
113 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailure(t *testing.T) {
114
115         testCtxt.SetDesc("SubsDeleteFail")
116
117         e2SubsFail := testCtxt.packerif.NewPackerSubscriptionDeleteFailure()
118
119         testCtxt.testPrint("########## ##########")
120         testCtxt.testPrint("init")
121
122         afailenc := e2ap.E2APSubscriptionDeleteFailure{}
123         afailenc.RequestId.Id = 1
124         afailenc.RequestId.Seq = 22
125         afailenc.FunctionId = 33
126         afailenc.Cause.Content = 1
127         afailenc.Cause.CauseVal = 1
128         // NOT SUPPORTED CURRENTLY
129         //      afailenc.CriticalityDiagnostics.Present = false
130         //      afailenc.CriticalityDiagnostics.ProcCodePresent = true
131         //      afailenc.CriticalityDiagnostics.ProcCode = 1
132         //      afailenc.CriticalityDiagnostics.TrigMsgPresent = true
133         //      afailenc.CriticalityDiagnostics.TrigMsg = 2
134         //      afailenc.CriticalityDiagnostics.ProcCritPresent = true
135         //      afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
136         //      for index := uint32(0); index < 256; index++ {
137         //              ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
138         //              ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
139         //              ieitem.IeID = index
140         //              ieitem.TypeOfError = 1
141         //              afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
142         //      }
143
144         seterr := e2SubsFail.Set(&afailenc)
145         if seterr != nil {
146                 testCtxt.testError(t, "set err: %s", seterr.Error())
147                 return
148         }
149         testCtxt.testPrint("print:\n%s", e2SubsFail.String())
150         testCtxt.testPrint("pack")
151         err, packedMsg := e2SubsFail.Pack(nil)
152         if err != nil {
153                 testCtxt.testError(t, "Pack failed: %s", err.Error())
154                 return
155         }
156         testCtxt.testPrint("unpack")
157         err = e2SubsFail.UnPack(packedMsg)
158         if err != nil {
159                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
160                 return
161         }
162         testCtxt.testPrint("print:\n%s", e2SubsFail.String())
163         geterr, afaildec := e2SubsFail.Get()
164         if geterr != nil {
165                 testCtxt.testError(t, "get nil: %s", geterr.Error())
166                 return
167         }
168         testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
169 }
170
171 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteRequestBuffers(t *testing.T) {
172
173         testfunc := func(buffer string) {
174                 packedData := testCtxt.toPackedData(t, buffer)
175                 if packedData == nil {
176                         return
177                 }
178                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteRequest()
179                 err := e2SubResp.UnPack(packedData)
180                 if err != nil {
181                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
182                         return
183                 }
184                 err, _ = e2SubResp.Get()
185                 if err != nil {
186                         testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
187                         return
188                 }
189                 testCtxt.testPrint("OK [%s]", buffer)
190         }
191
192         testCtxt.SetDesc("SubDelReqBuffer")
193
194         testfunc("00ca4012000002ea7e000500000106e7ea6300020001")
195         testfunc("00ca4012000002ea7e000500000106e8ea6300020001")
196         testfunc("00ca4012000002ea7e000500000106e9ea6300020001")
197         testfunc("00ca4012000002ea7e000500000106eaea6300020001")
198         testfunc("00ca4012000002ea7e000500000106ebea6300020001")
199         testfunc("00ca4012000002ea7e000500000106ecea6300020001")
200         testfunc("00ca4012000002ea7e000500000106edea6300020001")
201         testfunc("00ca4012000002ea7e000500000106eeea6300020001")
202         testfunc("00ca4012000002ea7e000500000106efea6300020001")
203         testfunc("00ca4012000002ea7e000500000106f0ea6300020001")
204         testfunc("00ca4012000002ea7e000500000106f4ea6300020001")
205         testfunc("00ca4012000002ea7e000500000106f5ea6300020001")
206         testfunc("00ca4012000002ea7e000500000106f6ea6300020001")
207 }
208
209 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteResponseBuffers(t *testing.T) {
210
211         testfunc := func(buffer string) {
212                 packedData := testCtxt.toPackedData(t, buffer)
213                 if packedData == nil {
214                         return
215                 }
216                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteResponse()
217                 err := e2SubResp.UnPack(packedData)
218                 if err != nil {
219                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
220                         return
221                 }
222                 err, _ = e2SubResp.Get()
223                 if err != nil {
224                         testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
225                         return
226                 }
227                 testCtxt.testPrint("OK [%s]", buffer)
228         }
229
230         testCtxt.SetDesc("SubDelRespBuffer")
231         testfunc("20ca4012000002ea7e000500000106e7ea6300020001")
232         testfunc("20ca4012000002ea7e000500000106e8ea6300020001")
233         testfunc("20ca4012000002ea7e000500000106e9ea6300020001")
234         testfunc("20ca4012000002ea7e000500000106eaea6300020001")
235         testfunc("20ca4012000002ea7e000500000106ebea6300020001")
236         testfunc("20ca4012000002ea7e000500000106ecea6300020001")
237         testfunc("20ca4012000002ea7e000500000106edea6300020001")
238         testfunc("20ca4012000002ea7e000500000106eeea6300020001")
239         testfunc("20ca4012000002ea7e000500000106efea6300020001")
240         testfunc("20ca4012000002ea7e000500000106f0ea6300020001")
241         testfunc("20ca4012000002ea7e000500000106f1ea6300020001")
242         testfunc("20ca4012000002ea7e000500000106f4ea6300020001")
243
244 }
245
246 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailureBuffers(t *testing.T) {
247
248         testfunc := func(buffer string) {
249                 packedData := testCtxt.toPackedData(t, buffer)
250                 if packedData == nil {
251                         return
252                 }
253                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteFailure()
254                 err := e2SubResp.UnPack(packedData)
255                 if err != nil {
256                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
257                         return
258                 }
259                 err, _ = e2SubResp.Get()
260                 if err != nil {
261                         testCtxt.testError(t, "Get() Failed: %s [%s]", err.Error(), buffer)
262                         return
263                 }
264                 testCtxt.testPrint("OK [%s]", buffer)
265         }
266
267         testCtxt.SetDesc("SubDelFailBuffer")
268         testfunc("40ca4017000003ea7e000500000106f6ea6300020001ea74000124")
269 }