X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fe2_reset_request_handler_test.go;fp=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fe2_reset_request_handler_test.go;h=8b15865e7d64e0b70338db0558391e33e99ac9ca;hb=04ff63f1708020673dd9be975476e0f76f179a81;hp=0000000000000000000000000000000000000000;hpb=b663d02aefda8fb49dd8c824eca19c9762346f95;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go new file mode 100644 index 0000000..8b15865 --- /dev/null +++ b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go @@ -0,0 +1,70 @@ +// +// Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This source code is part of the near-RT RIC (RAN Intelligent Controller) +// platform project (RICP). + +package rmrmsghandlers + +import ( + "e2mgr/configuration" + "e2mgr/mocks" + "e2mgr/models" + "e2mgr/services" + "e2mgr/tests" + "e2mgr/utils" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" + "github.com/stretchr/testify/mock" + "testing" +) + +const ( + E2ResetXmlPath = "../../tests/resources/reset/reset-request.xml" +) + +func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) { + logger := tests.InitLog(t) + config := &configuration.Configuration{ + RnibRetryIntervalMs: 10, + MaxRnibConnectionAttempts: 3, + RnibWriter: configuration.RnibWriterConfig{ + StateChangeMessageChannel: StateChangeMessageChannel, + }} + readerMock := &mocks.RnibReaderMock{} + writerMock := &mocks.RnibWriterMock{} + rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock) + handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService) + return handler, readerMock, writerMock +} + +func TestE2ResetRequestHandler(t *testing.T) { + e2ResetXml := utils.ReadXmlFile(t, E2ResetXmlPath) + handler, readerMock, writerMock := initE2ResetMocks(t) + var nodebInfo = &entities.NodebInfo{ + RanName: gnbNodebRanName, + AssociatedE2TInstanceAddress: e2tInstanceFullAddress, + ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, + NodeType: entities.Node_GNB, + Configuration: &entities.NodebInfo_Gnb{ + Gnb: &entities.Gnb{}, + }, + } + readerMock.On("GetNodeb", gnbNodebRanName).Return(nodebInfo, nil) + writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil) + notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(""), e2ResetXml...)} + handler.Handle(notificationRequest) + readerMock.AssertExpectations(t) + writerMock.AssertExpectations(t) +}