X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fsetup_response_notification_handler_test.go;h=d4503b8c13e7675fb1f0235000831668f253321c;hb=refs%2Fchanges%2F43%2F943%2F1;hp=e94a36a68e13a407ac6f20465aa9172d8e2b2c15;hpb=ffd085dd7f0654b84b163a7bfedd3fa89e7b8a71;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go index e94a36a..d4503b8 100644 --- a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go @@ -1,11 +1,30 @@ +// +// Copyright 2019 AT&T Intellectual Property +// Copyright 2019 Nokia +// +// 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. +// + package rmrmsghandlers import ( + "e2mgr/configuration" "e2mgr/logger" "e2mgr/managers" "e2mgr/mocks" "e2mgr/models" "e2mgr/rNibWriter" + "e2mgr/services" "fmt" "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common" "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" @@ -28,26 +47,28 @@ type setupResponseTestContext struct { logger *logger.Logger readerMock *mocks.RnibReaderMock writerMock *mocks.RnibWriterMock - rnibReaderProvider func() reader.RNibReader - rnibWriterProvider func() rNibWriter.RNibWriter + rnibDataService services.RNibDataService setupResponseManager managers.ISetupResponseManager } func NewSetupResponseTestContext(manager managers.ISetupResponseManager) *setupResponseTestContext { logger, _ := logger.InitLogger(logger.InfoLevel) + config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3} readerMock := &mocks.RnibReaderMock{} writerMock := &mocks.RnibWriterMock{} + rnibReaderProvider := func() reader.RNibReader { + return readerMock + } + rnibWriterProvider := func() rNibWriter.RNibWriter { + return writerMock + } + rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider) return &setupResponseTestContext{ - logger: logger, - readerMock: readerMock, - writerMock: writerMock, - rnibReaderProvider: func() reader.RNibReader { - return readerMock - }, - rnibWriterProvider: func() rNibWriter.RNibWriter { - return writerMock - }, + logger: logger, + readerMock: readerMock, + writerMock: writerMock, + rnibDataService: rnibDataService, setupResponseManager: manager, } } @@ -55,7 +76,7 @@ func NewSetupResponseTestContext(manager managers.ISetupResponseManager) *setupR func TestSetupResponseGetNodebFailure(t *testing.T) { notificationRequest := models.NotificationRequest{RanName: RanName} testContext := NewSetupResponseTestContext(nil) - handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response") + handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response") testContext.readerMock.On("GetNodeb", RanName).Return(&entities.NodebInfo{}, common.NewInternalError(errors.New("Error"))) handler.Handle(testContext.logger, ¬ificationRequest, nil) testContext.readerMock.AssertCalled(t, "GetNodeb", RanName) @@ -66,7 +87,7 @@ func TestSetupResponseInvalidConnectionStatus(t *testing.T) { ranName := "test" notificationRequest := models.NotificationRequest{RanName: ranName} testContext := NewSetupResponseTestContext(nil) - handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response") + handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response") var rnibErr error testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_SHUT_DOWN}, rnibErr) handler.Handle(testContext.logger, ¬ificationRequest, nil) @@ -84,7 +105,7 @@ func executeHandleSuccessSetupResponse(t *testing.T, packedPdu string, setupResp notificationRequest := models.NotificationRequest{RanName: RanName, Payload: payload} testContext := NewSetupResponseTestContext(setupResponseManager) - handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, testContext.setupResponseManager, notificationType) + handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, testContext.setupResponseManager, notificationType) var rnibErr error @@ -156,7 +177,7 @@ func TestSetupResponseInvalidPayload(t *testing.T) { ranName := "test" notificationRequest := models.NotificationRequest{RanName: ranName, Payload: []byte("123")} testContext := NewSetupResponseTestContext(nil) - handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response") + handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response") var rnibErr error testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, ConnectionAttempts: 1}, rnibErr) handler.Handle(testContext.logger, ¬ificationRequest, nil)