2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 package rmrmsghandlers
26 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
28 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
33 func TestX2ResetResponseSuccess(t *testing.T) {
34 payload, err := tests.BuildPackedX2ResetResponse()
36 t.Errorf("#x2_reset_response_handler_test.TestX2resetResponse - failed to build and pack X2ResetResponse. Error %x", err)
38 log, err := logger.InitLogger(logger.DebugLevel)
40 t.Errorf("#sctp_errors_notification_handler_test.TestHandleInSession - failed to initialize logger, error: %s", err)
42 readerMock :=&mocks.RnibReaderMock{}
43 rnibReaderProvider := func() reader.RNibReader {
47 h := NewX2ResetResponseHandler(rnibReaderProvider)
48 xaction := []byte("RanName")
49 mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
50 notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
51 StartTime: time.Now(), TransactionId: string(xaction)}
52 var messageChannel chan<- *models.NotificationResponse
54 nb := &entities.NodebInfo{RanName:mBuf.Meid, ConnectionStatus:entities.ConnectionStatus_CONNECTED_SETUP_FAILED,}
56 readerMock.On("GetNodeb", mBuf.Meid).Return(nb, rnibErr)
58 h.Handle(log, ¬ificationRequest, messageChannel)
60 //TODO:Nothing to verify
63 func TestX2ResetResponseReaderFailure(t *testing.T) {
65 log, err := logger.InitLogger(logger.DebugLevel)
67 t.Errorf("#sctp_errors_notification_handler_test.TestX2ResetResponseReaderFailure - failed to initialize logger, error: %s", err)
69 readerMock :=&mocks.RnibReaderMock{}
70 rnibReaderProvider := func() reader.RNibReader {
74 h := NewX2ResetResponseHandler(rnibReaderProvider)
75 xaction := []byte("RanName")
76 mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
77 notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
78 StartTime: time.Now(), TransactionId: string(xaction)}
79 var messageChannel chan<- *models.NotificationResponse
81 var nb *entities.NodebInfo
82 rnibErr := common.NewResourceNotFoundError("nodeb not found")
83 readerMock.On("GetNodeb", mBuf.Meid).Return(nb, rnibErr)
85 h.Handle(log, ¬ificationRequest, messageChannel)
87 //TODO:Nothing to verify
90 func TestX2ResetResponseUnpackFailure(t *testing.T) {
91 payload := []byte("not valid payload")
92 log, err := logger.InitLogger(logger.DebugLevel)
94 t.Errorf("#sctp_errors_notification_handler_test.TestX2ResetResponseUnpackFailure - failed to initialize logger, error: %s", err)
96 readerMock :=&mocks.RnibReaderMock{}
97 rnibReaderProvider := func() reader.RNibReader {
101 h := NewX2ResetResponseHandler(rnibReaderProvider)
102 xaction := []byte("RanName")
103 mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
104 notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
105 StartTime: time.Now(), TransactionId: string(xaction)}
106 var messageChannel chan<- *models.NotificationResponse
108 nb := &entities.NodebInfo{RanName:mBuf.Meid, ConnectionStatus:entities.ConnectionStatus_CONNECTED_SETUP_FAILED,}
110 readerMock.On("GetNodeb", mBuf.Meid).Return(nb, rnibErr)
112 h.Handle(log, ¬ificationRequest, messageChannel)
114 //TODO:Nothing to verify