[RICPLT-2727] Routing Manager - UT fixing 04/2104/1
authorIrina <ib565x@intl.att.com>
Tue, 24 Dec 2019 13:05:00 +0000 (15:05 +0200)
committerIrina <ib565x@intl.att.com>
Tue, 24 Dec 2019 13:05:11 +0000 (15:05 +0200)
Change-Id: Ibb5793f84ad1e0ce08b4714b75862536f36d6676
Signed-off-by: Irina <ib565x@intl.att.com>
E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler.go
E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler_test.go
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go

index 283de35..7063f57 100644 (file)
@@ -25,7 +25,6 @@ import (
        "e2mgr/logger"
        "e2mgr/managers"
        "e2mgr/models"
        "e2mgr/logger"
        "e2mgr/managers"
        "e2mgr/models"
-       "e2mgr/services"
        "encoding/json"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
        "encoding/json"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -33,16 +32,14 @@ import (
 
 type E2TermInitNotificationHandler struct {
        logger                 *logger.Logger
 
 type E2TermInitNotificationHandler struct {
        logger                 *logger.Logger
-       rnibDataService        services.RNibDataService
        ranReconnectionManager *managers.RanReconnectionManager
        e2tInstancesManager    managers.IE2TInstancesManager
        routingManagerClient   clients.IRoutingManagerClient
 }
 
        ranReconnectionManager *managers.RanReconnectionManager
        e2tInstancesManager    managers.IE2TInstancesManager
        routingManagerClient   clients.IRoutingManagerClient
 }
 
-func NewE2TermInitNotificationHandler(logger *logger.Logger, ranReconnectionManager *managers.RanReconnectionManager, rnibDataService services.RNibDataService, e2tInstancesManager managers.IE2TInstancesManager, routingManagerClient clients.IRoutingManagerClient) E2TermInitNotificationHandler {
+func NewE2TermInitNotificationHandler(logger *logger.Logger, ranReconnectionManager *managers.RanReconnectionManager, e2tInstancesManager managers.IE2TInstancesManager, routingManagerClient clients.IRoutingManagerClient) E2TermInitNotificationHandler {
        return E2TermInitNotificationHandler{
                logger:                 logger,
        return E2TermInitNotificationHandler{
                logger:                 logger,
-               rnibDataService:        rnibDataService,
                ranReconnectionManager: ranReconnectionManager,
                e2tInstancesManager:    e2tInstancesManager,
                routingManagerClient:   routingManagerClient,
                ranReconnectionManager: ranReconnectionManager,
                e2tInstancesManager:    e2tInstancesManager,
                routingManagerClient:   routingManagerClient,
index f6779df..bbf3826 100644 (file)
@@ -17,6 +17,8 @@
 package rmrmsghandlers
 
 import (
 package rmrmsghandlers
 
 import (
+       "bytes"
+       "e2mgr/clients"
        "e2mgr/configuration"
        "e2mgr/e2pdus"
        "e2mgr/logger"
        "e2mgr/configuration"
        "e2mgr/e2pdus"
        "e2mgr/logger"
@@ -30,7 +32,10 @@ import (
        "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"
        "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"
+       "github.com/pkg/errors"
        "github.com/stretchr/testify/mock"
        "github.com/stretchr/testify/mock"
+       "io/ioutil"
+       "net/http"
        "testing"
 )
 
        "testing"
 )
 
@@ -57,15 +62,15 @@ func initRanLostConnectionTest(t *testing.T) (*logger.Logger, E2TermInitNotifica
        e2tInstancesManagerMock := &mocks.E2TInstancesManagerMock{}
 
        ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, e2tInstancesManagerMock)
        e2tInstancesManagerMock := &mocks.E2TInstancesManagerMock{}
 
        ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, e2tInstancesManagerMock)
-       handler := NewE2TermInitNotificationHandler(logger, ranReconnectionManager, rnibDataService, e2tInstancesManagerMock, routingManagerClientMock)
+       handler := NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManagerMock, routingManagerClientMock)
 
        return logger, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock
 }
 
 
        return logger, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock
 }
 
-func initRanLostConnectionTestWithRealE2tInstanceManager(t *testing.T) (*logger.Logger, E2TermInitNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock) {
+func initRanLostConnectionTestWithRealE2tInstanceManager(t *testing.T) (*logger.Logger, *configuration.Configuration, E2TermInitNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock, *mocks.HttpClientMock) {
 
        logger := initLog(t)
 
        logger := initLog(t)
-       config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
+       config := configuration.ParseConfiguration()
 
        rmrMessengerMock := &mocks.RmrMessengerMock{}
        rmrSender := initRmrSender(rmrMessengerMock, logger)
 
        rmrMessengerMock := &mocks.RmrMessengerMock{}
        rmrSender := initRmrSender(rmrMessengerMock, logger)
@@ -73,15 +78,16 @@ func initRanLostConnectionTestWithRealE2tInstanceManager(t *testing.T) (*logger.
        readerMock := &mocks.RnibReaderMock{}
 
        writerMock := &mocks.RnibWriterMock{}
        readerMock := &mocks.RnibReaderMock{}
 
        writerMock := &mocks.RnibWriterMock{}
-       routingManagerClientMock := &mocks.RoutingManagerClientMock{}
+       httpClientMock := &mocks.HttpClientMock{}
 
 
+       routingManagerClient := clients.NewRoutingManagerClient(logger, config, httpClientMock)
        rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
        ranSetupManager := managers.NewRanSetupManager(logger, rmrSender, rnibDataService)
 
        e2tInstancesManager := managers.NewE2TInstancesManager(rnibDataService, logger)
        ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, e2tInstancesManager)
        rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
        ranSetupManager := managers.NewRanSetupManager(logger, rmrSender, rnibDataService)
 
        e2tInstancesManager := managers.NewE2TInstancesManager(rnibDataService, logger)
        ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, e2tInstancesManager)
-       handler := NewE2TermInitNotificationHandler(logger, ranReconnectionManager, rnibDataService, e2tInstancesManager, routingManagerClientMock)
-       return logger, handler, readerMock, writerMock, rmrMessengerMock
+       handler := NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient)
+       return logger, config, handler, readerMock, writerMock, rmrMessengerMock, httpClientMock
 }
 
 func TestE2TermInitUnmarshalPayloadFailure(t *testing.T) {
 }
 
 func TestE2TermInitUnmarshalPayloadFailure(t *testing.T) {
@@ -110,7 +116,7 @@ func TestE2TermInitGetE2TInstanceFailure(t *testing.T) {
 }
 
 func TestE2TermInitGetE2TInstanceDbFailure(t *testing.T) {
 }
 
 func TestE2TermInitGetE2TInstanceDbFailure(t *testing.T) {
-       _, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTestWithRealE2tInstanceManager(t)
+       _, _, handler, readerMock, writerMock, rmrMessengerMock,_ := initRanLostConnectionTestWithRealE2tInstanceManager(t)
        var e2tInstance *entities.E2TInstance
        readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewInternalError(fmt.Errorf("internal error")))
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
        var e2tInstance *entities.E2TInstance
        readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewInternalError(fmt.Errorf("internal error")))
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
@@ -120,31 +126,45 @@ func TestE2TermInitGetE2TInstanceDbFailure(t *testing.T) {
 }
 
 func TestE2TermInitNewE2TInstance(t *testing.T) {
 }
 
 func TestE2TermInitNewE2TInstance(t *testing.T) {
-       _, handler, _, _, _, e2tInstancesManagerMock, routingManagerClient := initRanLostConnectionTest(t)
+       _, config, handler, readerMock, writerMock, _, httpClientMock := initRanLostConnectionTestWithRealE2tInstanceManager(t)
        var e2tInstance *entities.E2TInstance
        var e2tInstance *entities.E2TInstance
-       e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewResourceNotFoundError("not found"))
-       e2tInstance = entities.NewE2TInstance(e2tInstanceAddress)
-       e2tInstancesManagerMock.On("AddE2TInstance", e2tInstanceAddress).Return(nil)
-       routingManagerClient.On("AddE2TInstance", e2tInstanceAddress).Return(nil)
+
+       readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewResourceNotFoundError("not found"))
+       writerMock.On("SaveE2TInstance", mock.Anything).Return(nil)
+
+       respBody := ioutil.NopCloser(bytes.NewBufferString(""))
+       url := config.RoutingManager.BaseUrl + clients.AddE2TInstanceApiSuffix
+       httpClientMock.On("Post", url, mock.Anything, mock.Anything).Return(&http.Response{StatusCode: http.StatusCreated, Body: respBody}, nil)
+
+       e2tAddresses := []string{}
+       readerMock.On("GetE2TAddresses").Return(e2tAddresses, common.NewResourceNotFoundError(""))
+
+       e2tAddresses = append(e2tAddresses, e2tInstanceAddress)
+       writerMock.On("SaveE2TAddresses", e2tAddresses).Return(nil)
+
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
        handler.Handle(notificationRequest)
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
        handler.Handle(notificationRequest)
-       routingManagerClient.AssertCalled(t, "AddE2TInstance", e2tInstanceAddress)
-       e2tInstancesManagerMock.AssertCalled(t, "AddE2TInstance", e2tInstanceAddress)
+
+       httpClientMock.AssertCalled(t, "Post", url, mock.Anything, mock.Anything)
+       writerMock.AssertCalled(t, "SaveE2TInstance", mock.Anything)
+       writerMock.AssertCalled(t, "SaveE2TAddresses", e2tAddresses)
 }
 
 func TestE2TermInitNewE2TInstance_RoutingManagerError(t *testing.T) {
 }
 
 func TestE2TermInitNewE2TInstance_RoutingManagerError(t *testing.T) {
-       _, handler, _, _, _, e2tInstancesManagerMock, routingManagerClient := initRanLostConnectionTest(t)
+       _, config, handler, readerMock, writerMock, _, httpClientMock := initRanLostConnectionTestWithRealE2tInstanceManager(t)
        var e2tInstance *entities.E2TInstance
        var e2tInstance *entities.E2TInstance
-       e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewResourceNotFoundError("not found"))
-       e2tInstance = entities.NewE2TInstance(e2tInstanceAddress)
-       e2tInstancesManagerMock.On("AddE2TInstance", e2tInstanceAddress).Return(nil)
-       routingManagerClient.On("AddE2TInstance", e2tInstanceAddress).Return(fmt.Errorf("error"))
-       notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
 
 
+       readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, common.NewResourceNotFoundError("not found"))
+
+       url := config.RoutingManager.BaseUrl + clients.AddE2TInstanceApiSuffix
+       httpClientMock.On("Post", url, mock.Anything, mock.Anything).Return(&http.Response{}, errors.New("error"))
+
+       notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
        handler.Handle(notificationRequest)
 
        handler.Handle(notificationRequest)
 
-       routingManagerClient.AssertCalled(t, "AddE2TInstance", e2tInstanceAddress)
-       e2tInstancesManagerMock.AssertNotCalled(t, "AddE2TInstance", e2tInstanceAddress)
+       httpClientMock.AssertCalled(t, "Post", url, mock.Anything, mock.Anything)
+       writerMock.AssertNotCalled(t, "SaveE2TInstance", mock.Anything)
+       writerMock.AssertNotCalled(t, "SaveE2TAddresses", mock.Anything)
 }
 
 func TestE2TermInitExistingE2TInstanceNoAssociatedRans(t *testing.T) {
 }
 
 func TestE2TermInitExistingE2TInstanceNoAssociatedRans(t *testing.T) {
@@ -184,7 +204,7 @@ func TestE2TermInitHandlerSuccessOneRan(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessOneRanShuttingdown(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessOneRanShuttingdown(t *testing.T) {
-       _, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTestWithRealE2tInstanceManager(t)
+       _, _, handler, readerMock, writerMock, rmrMessengerMock,_ := initRanLostConnectionTestWithRealE2tInstanceManager(t)
        var rnibErr error
 
        var initialNodeb = &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
        var rnibErr error
 
        var initialNodeb = &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
@@ -211,7 +231,7 @@ func TestE2TermInitHandlerSuccessOneRanShuttingdown(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessOneRan_ToBeDeleted(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessOneRan_ToBeDeleted(t *testing.T) {
-       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, _  := initRanLostConnectionTest(t)
+       _, _, handler, readerMock, writerMock, rmrMessengerMock, httpClientMock:= initRanLostConnectionTestWithRealE2tInstanceManager(t)
        var rnibErr error
 
        var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
        var rnibErr error
 
        var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
@@ -230,21 +250,24 @@ func TestE2TermInitHandlerSuccessOneRan_ToBeDeleted(t *testing.T) {
        e2tInstance.State = entities.ToBeDeleted
        e2tInstance.AssociatedRanList = append(e2tInstance.AssociatedRanList, RanName)
 
        e2tInstance.State = entities.ToBeDeleted
        e2tInstance.AssociatedRanList = append(e2tInstance.AssociatedRanList, RanName)
 
-       e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
+       readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
 
        handler.Handle(notificationRequest)
 
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
 
        handler.Handle(notificationRequest)
 
+       httpClientMock.AssertNotCalled(t, "Post", mock.Anything, mock.Anything, mock.Anything)
        writerMock.AssertNotCalled(t, "UpdateNodebInfo")
        rmrMessengerMock.AssertNotCalled(t, "SendMsg")
 }
 
        writerMock.AssertNotCalled(t, "UpdateNodebInfo")
        rmrMessengerMock.AssertNotCalled(t, "SendMsg")
 }
 
-func TestE2TermInitHandlerSuccessOneRan_RoutingManagerFailure(t *testing.T) {
-       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, _  := initRanLostConnectionTest(t)
-       var rnibErr error
+func TestE2TermInitHandlerSuccessTwoRans_RoutingManagerFailure(t *testing.T) {
+       _, _, handler, readerMock, writerMock, rmrMessengerMock, httpClientMock:= initRanLostConnectionTestWithRealE2tInstanceManager(t)
 
 
-       var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
-       readerMock.On("GetNodeb", RanName).Return(initialNodeb, rnibErr)
+       var rnibErr error
+       var initialNodeb0 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
+       var initialNodeb1 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
+       readerMock.On("GetNodeb", RanName).Return(initialNodeb0, rnibErr)
+       readerMock.On("GetNodeb", "test2").Return(initialNodeb1, rnibErr)
 
        var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
        writerMock.On("UpdateNodebInfo", argNodeb).Return(rnibErr)
 
        var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
        writerMock.On("UpdateNodebInfo", argNodeb).Return(rnibErr)
@@ -257,18 +280,20 @@ func TestE2TermInitHandlerSuccessOneRan_RoutingManagerFailure(t *testing.T) {
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
        e2tInstance.State = entities.RoutingManagerFailure
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
        e2tInstance.State = entities.RoutingManagerFailure
-       e2tInstance.AssociatedRanList = append(e2tInstance.AssociatedRanList, RanName)
+       e2tInstance.AssociatedRanList = append(e2tInstance.AssociatedRanList, RanName, "test2")
 
 
-       e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
-       e2tInstancesManagerMock.On("ActivateE2TInstance", e2tInstance).Return(nil)
-       writerMock.On("UpdateNodebInfo", argNodeb).Return(rnibErr)
+       readerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
+       writerMock.On("SaveE2TInstance", mock.Anything).Return(nil)
 
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
 
        handler.Handle(notificationRequest)
 
 
        notificationRequest := &models.NotificationRequest{RanName: RanName, Payload: []byte(e2tInitPayload)}
 
        handler.Handle(notificationRequest)
 
-       writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1)
-       rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 1)
+       rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 2)
+       writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2)
+
+       httpClientMock.AssertNotCalled(t, "Post", mock.Anything, mock.Anything, mock.Anything)
+       writerMock.AssertCalled(t, "SaveE2TInstance", mock.Anything)
 }
 
 func TestE2TermInitHandlerSuccessOneRan_RoutingManagerFailure_Error(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessOneRan_RoutingManagerFailure_Error(t *testing.T) {
@@ -304,7 +329,7 @@ func TestE2TermInitHandlerSuccessOneRan_RoutingManagerFailure_Error(t *testing.T
 }
 
 func TestE2TermInitHandlerSuccessTwoRans(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessTwoRans(t *testing.T) {
-       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock,  := initRanLostConnectionTest(t)
+       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, httpClientMock := initRanLostConnectionTest(t)
        var rnibErr error
        var initialNodeb0 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
        var initialNodeb1 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
        var rnibErr error
        var initialNodeb0 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
        var initialNodeb1 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
@@ -329,6 +354,7 @@ func TestE2TermInitHandlerSuccessTwoRans(t *testing.T) {
 
        writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2)
        rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 2)
 
        writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2)
        rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 2)
+       httpClientMock.AssertNotCalled(t, "Post", mock.Anything, mock.Anything, mock.Anything)
 }
 
 func TestE2TermInitHandlerSuccessTwoRansSecondRanShutdown(t *testing.T) {
 }
 
 func TestE2TermInitHandlerSuccessTwoRansSecondRanShutdown(t *testing.T) {
@@ -382,11 +408,6 @@ func TestE2TermInitHandlerSuccessThreeRansFirstRmrFailure(t *testing.T) {
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
-       // Cannot use Mock because request MBuf contains pointers
-       //payload =models.NewE2RequestMessage(ids[1].InventoryName /*tid*/, "", 0,ids[1].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
-       //xaction = []byte(ids[1].InventoryName)
-       //msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
-
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, fmt.Errorf("RMR Error"))
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, fmt.Errorf("RMR Error"))
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
@@ -429,11 +450,6 @@ func TestE2TermInitHandlerSuccessThreeRansSecondNotFoundFailure(t *testing.T) {
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
-       // Cannot use Mock because request MBuf contains pointers
-       //payload =models.NewE2RequestMessage(ids[1].InventoryName /*tid*/, "", 0,ids[1].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
-       //xaction = []byte(ids[1].InventoryName)
-       //msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
-
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, nil)
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, nil)
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
@@ -477,11 +493,6 @@ func TestE2TermInitHandlerSuccessThreeRansSecondRnibInternalErrorFailure(t *test
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
        xaction := []byte(ids[0].InventoryName)
        msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
 
-       // Cannot use Mock because request MBuf contains pointers
-       //payload =models.NewE2RequestMessage(ids[1].InventoryName /*tid*/, "", 0,ids[1].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
-       //xaction = []byte(ids[1].InventoryName)
-       //msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
-
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, nil)
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
        rmrMessengerMock.On("SendMsg", mock.Anything, true).Return(msg0, nil)
 
        e2tInstance := entities.NewE2TInstance(e2tInstanceAddress)
index b161c93..b7002ad 100644 (file)
@@ -87,7 +87,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config
        endcConfigurationUpdateHandler := rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender)
        x2ResetResponseHandler := rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, x2ResetResponseExtractor)
        x2ResetRequestNotificationHandler := rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)
        endcConfigurationUpdateHandler := rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender)
        x2ResetResponseHandler := rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, x2ResetResponseExtractor)
        x2ResetRequestNotificationHandler := rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)
-       e2TermInitNotificationHandler := rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, rnibDataService, e2tInstancesManager, routingManagerClient)
+       e2TermInitNotificationHandler := rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient)
        e2TKeepAliveResponseHandler := rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)
 
        provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler)
        e2TKeepAliveResponseHandler := rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)
 
        provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler)
index fb5dadb..d01d7c4 100644 (file)
@@ -92,7 +92,7 @@ func TestGetNotificationHandlerSuccess(t *testing.T) {
                {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(logger, rnibDataService, converters.NewEnbLoadInformationExtractor(logger))},
                {rmrCgo.RIC_ENB_CONF_UPDATE, rmrmsghandlers.NewX2EnbConfigurationUpdateHandler(logger, rmrSender)},
                {rmrCgo.RIC_ENDC_CONF_UPDATE, rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender)},
                {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(logger, rnibDataService, converters.NewEnbLoadInformationExtractor(logger))},
                {rmrCgo.RIC_ENB_CONF_UPDATE, rmrmsghandlers.NewX2EnbConfigurationUpdateHandler(logger, rmrSender)},
                {rmrCgo.RIC_ENDC_CONF_UPDATE, rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender)},
-               {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, rnibDataService, e2tInstancesManager, routingManagerClient)},
+               {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient)},
                {rmrCgo.E2_TERM_KEEP_ALIVE_RESP, rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)},
                {rmrCgo.RIC_X2_RESET_RESP, rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, converters.NewX2ResetResponseExtractor(logger))},
                {rmrCgo.RIC_X2_RESET, rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)},
                {rmrCgo.E2_TERM_KEEP_ALIVE_RESP, rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)},
                {rmrCgo.RIC_X2_RESET_RESP, rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, converters.NewX2ResetResponseExtractor(logger))},
                {rmrCgo.RIC_X2_RESET, rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)},