RICPLT-2910
[ric-plt/submgr.git] / e2ap / pkg / e2ap / e2ap_tests / msg_e2ap_indication.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 func (testCtxt *E2ApTests) E2ApTestMsgIndication(t *testing.T) {
31
32         testCtxt.SetDesc("MsgIndication")
33         e2Ind := testCtxt.packerif.NewPackerIndication()
34
35         testCtxt.testPrint("########## Indication ##########")
36         testCtxt.testPrint("Indication: init")
37
38         aindenc := e2ap.E2APIndication{}
39         aindenc.RequestId.Id = 1
40         aindenc.RequestId.Seq = 22
41         aindenc.FunctionId = 33
42         aindenc.IndicationSn = 1
43         aindenc.IndicationType = e2ap.E2AP_IndicationTypeReport
44         aindenc.IndicationHeader.InterfaceId.GlobalEnbId.Present = true
45         aindenc.IndicationHeader.InterfaceId.GlobalEnbId.PlmnIdentity.StringPut("310150")
46         //Bits 20, 28(works), 18, 21 (asn1 problems)
47         aindenc.IndicationHeader.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
48         aindenc.IndicationHeader.InterfaceId.GlobalEnbId.NodeId.Id = 202251
49         aindenc.IndicationHeader.InterfaceDirection = 0
50         aindenc.IndicationMessage.InterfaceMessage.Buf = []uint8{1, 2, 3, 4, 5}
51         //aindenc.CallProcessId.CallProcessIDVal=100
52
53         seterr := e2Ind.Set(&aindenc)
54         if seterr != nil {
55                 testCtxt.testError(t, "set err: %s", seterr.Error())
56                 return
57         }
58
59         testCtxt.testPrint("Indication: print:\n%s", e2Ind.String())
60         testCtxt.testPrint("Indication: pack")
61         err, packedMsg := e2Ind.Pack(nil)
62         if err != nil {
63                 testCtxt.testError(t, "Indication Pack failed: %s", err.Error())
64                 return
65         }
66         testCtxt.testPrint("Indication: unpack")
67         err = e2Ind.UnPack(packedMsg)
68         if err != nil {
69                 testCtxt.testError(t, "Indication UnPack failed: %s", err.Error())
70                 return
71         }
72         testCtxt.testPrint("Indication: print:\n%s", e2Ind.String())
73         geterr, ainddec := e2Ind.Get()
74         if geterr != nil {
75                 testCtxt.testError(t, "Indication get nil: %s", geterr.Error())
76                 return
77         }
78         testCtxt.testValueEquality(t, "msg", &aindenc, ainddec)
79 }