2 // Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
\r
4 // Licensed under the Apache License, Version 2.0 (the "License");
\r
5 // you may not use this file except in compliance with the License.
\r
6 // You may obtain a copy of the License at
\r
8 // http://www.apache.org/licenses/LICENSE-2.0
\r
10 // Unless required by applicable law or agreed to in writing, software
\r
11 // distributed under the License is distributed on an "AS IS" BASIS,
\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 // See the License for the specific language governing permissions and
\r
14 // limitations under the License.
\r
16 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
\r
17 // platform project (RICP).
\r
19 package rmrmsghandlers
\r
22 "e2mgr/configuration"
\r
30 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
\r
31 "github.com/stretchr/testify/mock"
\r
35 E2ResetXmlPath = "../../tests/resources/reset/reset-request.xml"
\r
38 func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {
\r
39 logger := tests.InitLog(t)
\r
40 config := &configuration.Configuration{
\r
41 RnibRetryIntervalMs: 10,
\r
42 MaxRnibConnectionAttempts: 3,
\r
43 RnibWriter: configuration.RnibWriterConfig{
\r
44 StateChangeMessageChannel: StateChangeMessageChannel,
\r
46 readerMock := &mocks.RnibReaderMock{}
\r
47 writerMock := &mocks.RnibWriterMock{}
\r
48 rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
\r
49 handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService, config)
\r
50 return handler, readerMock, writerMock
\r
53 func TestE2ResetRequestHandler(t *testing.T) {
\r
54 e2ResetXml := utils.ReadXmlFile(t, E2ResetXmlPath)
\r
55 handler, readerMock, writerMock := initE2ResetMocks(t)
\r
56 var nodebInfo = &entities.NodebInfo{
\r
57 RanName: gnbNodebRanName,
\r
58 AssociatedE2TInstanceAddress: e2tInstanceFullAddress,
\r
59 ConnectionStatus: entities.ConnectionStatus_DISCONNECTED,
\r
60 NodeType: entities.Node_GNB,
\r
61 Configuration: &entities.NodebInfo_Gnb{
\r
62 Gnb: &entities.Gnb{},
\r
65 readerMock.On("GetNodeb", gnbNodebRanName).Return(nodebInfo, nil)
\r
66 writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil)
\r
67 notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(""), e2ResetXml...)}
\r
68 handler.Handle(notificationRequest)
\r
69 readerMock.AssertExpectations(t)
\r
70 writerMock.AssertExpectations(t)
\r