- readerMock.On("GetNodeb", nodebRanName).Return(gnb, common.NewResourceNotFoundError("Not found"))
- notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xml...)}
- nodebInfo := getExpectedNodebForNewRan(notificationRequest.Payload)
- nbIdentity := &entities.NbIdentity{InventoryName: nodebRanName, GlobalNbId: nodebInfo.GlobalNbId}
- writerMock.On("SaveNodeb", nbIdentity, nodebInfo).Return(nil)
- updatedNodebInfo := *nodebInfo
+ readerMock.On("GetNodeb", gnbNodebRanName).Return(gnb, common.NewResourceNotFoundError("Not found"))
+ notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xml...)}
+ nodebInfo := getExpectedGnbNodebForNewRan(notificationRequest.Payload)
+ writerMock.On("SaveNodeb", nodebInfo).Return(nil)
+ nbIdentity := &entities.NbIdentity{InventoryName: gnbNodebRanName, GlobalNbId: nodebInfo.GlobalNbId}
+ writerMock.On("AddNbIdentity", entities.Node_GNB, nbIdentity).Return(common.NewInternalError(errors.New("error")))
+ handler.Handle(notificationRequest)
+ readerMock.AssertExpectations(t)
+ writerMock.AssertExpectations(t)
+ e2tInstancesManagerMock.AssertExpectations(t)
+}
+
+func testE2SetupRequestNotificationHandler_HandleNewRanSuccess(t *testing.T, xmlPath string, nodeType entities.Node_Type) {
+ xml := readXmlFile(t, xmlPath)
+ var ranName string
+ if nodeType == entities.Node_GNB {
+ ranName = gnbNodebRanName
+ } else {
+ ranName = enbNodebRanName
+ }
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
+ var gnb *entities.NodebInfo
+ readerMock.On("GetNodeb", ranName).Return(gnb, common.NewResourceNotFoundError("Not found"))
+ notificationRequest := &models.NotificationRequest{RanName: ranName, Payload: append([]byte(e2SetupMsgPrefix), xml...)}
+ var expectedNodebInfo *entities.NodebInfo
+ if nodeType == entities.Node_GNB {
+ expectedNodebInfo = getExpectedGnbNodebForNewRan(notificationRequest.Payload)
+ } else {
+ expectedNodebInfo = getExpectedEnbNodebForNewRan(notificationRequest.Payload)
+ }
+ writerMock.On("SaveNodeb", expectedNodebInfo).Return(nil)
+ nbIdentity := &entities.NbIdentity{InventoryName: ranName, GlobalNbId: expectedNodebInfo.GlobalNbId}
+ writerMock.On("AddNbIdentity", nodeType, nbIdentity).Return(nil)
+ updatedNodebInfo := *expectedNodebInfo