eae103e57320c1a9ca2cdc91fb4e70c2db444363
[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         testCtxt.testPrint("pack")
46         err, packedMsg := e2SubsReq.Pack(&areqenc)
47         if err != nil {
48                 testCtxt.testError(t, "Pack failed: %s", err.Error())
49                 return
50         }
51         testCtxt.testPrint("print:\n%s", e2SubsReq.String())
52         testCtxt.testPrint("unpack")
53         err, areqdec := e2SubsReq.UnPack(packedMsg)
54         if err != nil {
55                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
56                 return
57         }
58         testCtxt.testPrint("print:\n%s", e2SubsReq.String())
59         testCtxt.testValueEquality(t, "msg", &areqenc, areqdec)
60 }
61
62 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteResponse(t *testing.T) {
63
64         testCtxt.SetDesc("SubsDeleteResp")
65
66         e2SubsResp := testCtxt.packerif.NewPackerSubscriptionDeleteResponse()
67
68         testCtxt.testPrint("########## ##########")
69         testCtxt.testPrint("init")
70
71         arespenc := e2ap.E2APSubscriptionDeleteResponse{}
72         arespenc.RequestId.Id = 1
73         arespenc.RequestId.Seq = 22
74         arespenc.FunctionId = 33
75
76         testCtxt.testPrint("pack")
77         err, packedMsg := e2SubsResp.Pack(&arespenc)
78         if err != nil {
79                 testCtxt.testError(t, "Pack failed: %s", err.Error())
80                 return
81         }
82         testCtxt.testPrint("print:\n%s", e2SubsResp.String())
83         testCtxt.testPrint("unpack")
84         err, arespdec := e2SubsResp.UnPack(packedMsg)
85         if err != nil {
86                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
87                 return
88         }
89         testCtxt.testPrint("print:\n%s", e2SubsResp.String())
90         testCtxt.testValueEquality(t, "msg", &arespenc, arespdec)
91 }
92
93 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailure(t *testing.T) {
94
95         testCtxt.SetDesc("SubsDeleteFail")
96
97         e2SubsFail := testCtxt.packerif.NewPackerSubscriptionDeleteFailure()
98
99         testCtxt.testPrint("########## ##########")
100         testCtxt.testPrint("init")
101
102         afailenc := e2ap.E2APSubscriptionDeleteFailure{}
103         afailenc.RequestId.Id = 1
104         afailenc.RequestId.Seq = 22
105         afailenc.FunctionId = 33
106         afailenc.Cause.Content = 1
107         afailenc.Cause.Value = 1
108         // NOT SUPPORTED CURRENTLY
109         //      afailenc.CriticalityDiagnostics.Present = false
110         //      afailenc.CriticalityDiagnostics.ProcCodePresent = true
111         //      afailenc.CriticalityDiagnostics.ProcCode = 1
112         //      afailenc.CriticalityDiagnostics.TrigMsgPresent = true
113         //      afailenc.CriticalityDiagnostics.TrigMsg = 2
114         //      afailenc.CriticalityDiagnostics.ProcCritPresent = true
115         //      afailenc.CriticalityDiagnostics.ProcCrit = e2ap.E2AP_CriticalityReject
116         //      for index := uint32(0); index < 256; index++ {
117         //              ieitem := e2ap.CriticalityDiagnosticsIEListItem{}
118         //              ieitem.IeCriticality = e2ap.E2AP_CriticalityReject
119         //              ieitem.IeID = index
120         //              ieitem.TypeOfError = 1
121         //              afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items = append(afailenc.CriticalityDiagnostics.CriticalityDiagnosticsIEList.Items, ieitem)
122         //      }
123
124         testCtxt.testPrint("pack")
125         err, packedMsg := e2SubsFail.Pack(&afailenc)
126         if err != nil {
127                 testCtxt.testError(t, "Pack failed: %s", err.Error())
128                 return
129         }
130         testCtxt.testPrint("print:\n%s", e2SubsFail.String())
131         testCtxt.testPrint("unpack")
132         err, afaildec := e2SubsFail.UnPack(packedMsg)
133         if err != nil {
134                 testCtxt.testError(t, "UnPack failed: %s", err.Error())
135                 return
136         }
137         testCtxt.testPrint("print:\n%s", e2SubsFail.String())
138         testCtxt.testValueEquality(t, "msg", &afailenc, afaildec)
139 }
140
141 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteRequestBuffers(t *testing.T) {
142
143         testfunc := func(buffer string) {
144                 packedData := testCtxt.toPackedData(t, buffer)
145                 if packedData == nil {
146                         return
147                 }
148                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteRequest()
149                 err, _ := e2SubResp.UnPack(packedData)
150                 if err != nil {
151                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
152                         return
153                 }
154                 testCtxt.testPrint("OK [%s]", buffer)
155         }
156
157         testCtxt.SetDesc("SubDelReqBuffer")
158
159         testfunc("00ca4012000002ea7e000500000106e7ea6300020001")
160         testfunc("00ca4012000002ea7e000500000106e8ea6300020001")
161         testfunc("00ca4012000002ea7e000500000106e9ea6300020001")
162         testfunc("00ca4012000002ea7e000500000106eaea6300020001")
163         testfunc("00ca4012000002ea7e000500000106ebea6300020001")
164         testfunc("00ca4012000002ea7e000500000106ecea6300020001")
165         testfunc("00ca4012000002ea7e000500000106edea6300020001")
166         testfunc("00ca4012000002ea7e000500000106eeea6300020001")
167         testfunc("00ca4012000002ea7e000500000106efea6300020001")
168         testfunc("00ca4012000002ea7e000500000106f0ea6300020001")
169         testfunc("00ca4012000002ea7e000500000106f4ea6300020001")
170         testfunc("00ca4012000002ea7e000500000106f5ea6300020001")
171         testfunc("00ca4012000002ea7e000500000106f6ea6300020001")
172 }
173
174 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteResponseBuffers(t *testing.T) {
175
176         testfunc := func(buffer string) {
177                 packedData := testCtxt.toPackedData(t, buffer)
178                 if packedData == nil {
179                         return
180                 }
181                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteResponse()
182                 err, _ := e2SubResp.UnPack(packedData)
183                 if err != nil {
184                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
185                         return
186                 }
187                 testCtxt.testPrint("OK [%s]", buffer)
188         }
189
190         testCtxt.SetDesc("SubDelRespBuffer")
191         testfunc("20ca4012000002ea7e000500000106e7ea6300020001")
192
193 }
194
195 func (testCtxt *E2ApTests) E2ApTestMsgSubscriptionDeleteFailureBuffers(t *testing.T) {
196
197         testfunc := func(buffer string) {
198                 packedData := testCtxt.toPackedData(t, buffer)
199                 if packedData == nil {
200                         return
201                 }
202                 e2SubResp := testCtxt.packerif.NewPackerSubscriptionDeleteFailure()
203                 err, _ := e2SubResp.UnPack(packedData)
204                 if err != nil {
205                         testCtxt.testError(t, "UnPack() Failed: %s [%s]", err.Error(), buffer)
206                         return
207                 }
208                 testCtxt.testPrint("OK [%s]", buffer)
209         }
210
211         testCtxt.SetDesc("SubDelFailBuffer")
212         testfunc("40ca4017000003ea7e000500000106f6ea6300020001ea74000124")
213 }