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
28 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
\r
29 "github.com/stretchr/testify/mock"
\r
34 E2ResetXmlPath = "../../tests/resources/reset/reset-request.xml"
\r
37 func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {
\r
38 logger := tests.InitLog(t)
\r
39 config := &configuration.Configuration{
\r
40 RnibRetryIntervalMs: 10,
\r
41 MaxRnibConnectionAttempts: 3,
\r
42 RnibWriter: configuration.RnibWriterConfig{
\r
43 StateChangeMessageChannel: StateChangeMessageChannel,
\r
45 readerMock := &mocks.RnibReaderMock{}
\r
46 writerMock := &mocks.RnibWriterMock{}
\r
47 rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
\r
48 handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService)
\r
49 return handler, readerMock, writerMock
\r
52 func TestE2ResetRequestHandler(t *testing.T) {
\r
53 e2ResetXml := utils.ReadXmlFile(t, E2ResetXmlPath)
\r
54 handler, readerMock, writerMock := initE2ResetMocks(t)
\r
55 var nodebInfo = &entities.NodebInfo{
\r
56 RanName: gnbNodebRanName,
\r
57 AssociatedE2TInstanceAddress: e2tInstanceFullAddress,
\r
58 ConnectionStatus: entities.ConnectionStatus_DISCONNECTED,
\r
59 NodeType: entities.Node_GNB,
\r
60 Configuration: &entities.NodebInfo_Gnb{
\r
61 Gnb: &entities.Gnb{},
\r
64 readerMock.On("GetNodeb", gnbNodebRanName).Return(nodebInfo, nil)
\r
65 writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil)
\r
66 notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(""), e2ResetXml...)}
\r
67 handler.Handle(notificationRequest)
\r
68 readerMock.AssertExpectations(t)
\r
69 writerMock.AssertExpectations(t)
\r