X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fran_lost_connection_handler_test.go;h=a1043a7f58957f7c10d528c3cb1ea4670091559d;hb=refs%2Fchanges%2F35%2F2635%2F1;hp=c0cd787168c12e59fbd077d5e65e45360c916875;hpb=2ed06429ecae26f8591f2f7b6a8b64fe15c9b3d8;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go index c0cd787..a1043a7 100644 --- a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go @@ -42,25 +42,25 @@ func TestLostConnectionHandlerSuccess(t *testing.T) { logger, _ := logger.InitLogger(logger.InfoLevel) notificationRequest := models.NotificationRequest{RanName: ranName} - ranReconnectionManagerMock := &mocks.RanDisconnectionManagerMock{} - ranReconnectionManagerMock.On("DisconnectRan", ranName).Return(nil) - handler := NewRanLostConnectionHandler(logger, ranReconnectionManagerMock) + ranDisconnectionManagerMock := &mocks.RanDisconnectionManagerMock{} + ranDisconnectionManagerMock.On("DisconnectRan", ranName).Return(nil) + handler := NewRanLostConnectionHandler(logger, ranDisconnectionManagerMock) handler.Handle(¬ificationRequest) - ranReconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName) + ranDisconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName) } func TestLostConnectionHandlerFailure(t *testing.T) { logger, _ := logger.InitLogger(logger.InfoLevel) notificationRequest := models.NotificationRequest{RanName: ranName} - ranReconnectionManagerMock := &mocks.RanDisconnectionManagerMock{} - ranReconnectionManagerMock.On("DisconnectRan", ranName).Return(errors.New("error")) - handler := NewRanLostConnectionHandler(logger, ranReconnectionManagerMock) + ranDisconnectionManagerMock := &mocks.RanDisconnectionManagerMock{} + ranDisconnectionManagerMock.On("DisconnectRan", ranName).Return(errors.New("error")) + handler := NewRanLostConnectionHandler(logger, ranDisconnectionManagerMock) handler.Handle(¬ificationRequest) - ranReconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName) + ranDisconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName) } -func setupLostConnectionHandlerTestWithRealReconnectionManager(t *testing.T, isSuccessfulHttpPost bool) (RanLostConnectionHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock) { +func setupLostConnectionHandlerTestWithRealDisconnectionManager(t *testing.T, isSuccessfulHttpPost bool) (RanLostConnectionHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock) { logger, _ := logger.InitLogger(logger.InfoLevel) config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3} @@ -71,10 +71,10 @@ func setupLostConnectionHandlerTestWithRealReconnectionManager(t *testing.T, isS httpClientMock := &mocks.HttpClientMock{} routingManagerClient := clients.NewRoutingManagerClient(logger, config, httpClientMock) e2tAssociationManager := managers.NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManager, routingManagerClient) - ranReconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) - handler := NewRanLostConnectionHandler(logger, ranReconnectionManager) + ranDisconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) + handler := NewRanLostConnectionHandler(logger, ranDisconnectionManager) - origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, ConnectionAttempts: 20, AssociatedE2TInstanceAddress: e2tAddress} + origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, AssociatedE2TInstanceAddress: e2tAddress} var rnibErr error readerMock.On("GetNodeb", ranName).Return(origNodebInfo, rnibErr) updatedNodebInfo1 := *origNodebInfo @@ -108,8 +108,8 @@ func mockHttpClient(httpClientMock *mocks.HttpClientMock, isSuccessful bool) { httpClientMock.On("Post", clients.DissociateRanE2TInstanceApiSuffix, "application/json", body).Return(&http.Response{StatusCode: respStatusCode, Body: respBody}, nil) } -func TestLostConnectionHandlerFailureWithRealReconnectionManager(t *testing.T) { - handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealReconnectionManager(t, false) +func TestLostConnectionHandlerFailureWithRealDisconnectionManager(t *testing.T) { + handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealDisconnectionManager(t, false) notificationRequest := models.NotificationRequest{RanName: ranName} handler.Handle(¬ificationRequest) @@ -120,8 +120,8 @@ func TestLostConnectionHandlerFailureWithRealReconnectionManager(t *testing.T) { writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2) } -func TestLostConnectionHandlerSuccessWithRealReconnectionManager(t *testing.T) { - handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealReconnectionManager(t, true) +func TestLostConnectionHandlerSuccessWithRealDisconnectionManager(t *testing.T) { + handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealDisconnectionManager(t, true) notificationRequest := models.NotificationRequest{RanName: ranName} handler.Handle(¬ificationRequest)