+ request, _, err := handler.parseSetupRequest(append(prefBytes, xmlGnb...))
+ assert.Equal(t, "02F829", request.GetPlmnId())
+ assert.Equal(t, "001100000011000000110000", request.GetNbId())
+ assert.Nil(t, err)
+}
+
+func TestParseEnGnbSetupRequest_Success(t *testing.T) {
+ enGnbXml := readXmlFile(t, EnGnbSetupRequestXmlPath)
+ handler, _, _, _, _, _ := initMocks(t)
+ prefBytes := []byte(prefix)
+ request, _, err := handler.parseSetupRequest(append(prefBytes, enGnbXml...))
+ assert.Equal(t, "131014", request.GetPlmnId())
+ assert.Equal(t, "11000101110001101100011111111000", request.GetNbId())
+ assert.Nil(t, err)
+}
+
+func TestParseNgEnbSetupRequest_Success(t *testing.T) {
+ ngEnbXml := readXmlFile(t, NgEnbSetupRequestXmlPath)
+ handler, _, _, _, _, _ := initMocks(t)
+ prefBytes := []byte(prefix)
+ request, _, err := handler.parseSetupRequest(append(prefBytes, ngEnbXml...))
+ assert.Equal(t, "131014", request.GetPlmnId())
+ assert.Equal(t, "101010101010101010", request.GetNbId())
+ assert.Nil(t, err)
+}
+
+func TestParseEnbSetupRequest_Success(t *testing.T) {
+ enbXml := readXmlFile(t, EnbSetupRequestXmlPath)
+ handler, _, _, _, _, _ := initMocks(t)
+ prefBytes := []byte(prefix)
+ request, _, err := handler.parseSetupRequest(append(prefBytes, enbXml...))
+ assert.Equal(t, "6359AB", request.GetPlmnId())
+ assert.Equal(t, "101010101010101010", request.GetNbId())
+ assert.Nil(t, err)
+}
+
+func TestParseSetupRequest_PipFailure(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
+ handler, _, _, _, _, _ := initMocks(t)
+ prefBytes := []byte("10.0.2.15:9999")
+ request, _, err := handler.parseSetupRequest(append(prefBytes, xmlGnb...))
+ assert.Nil(t, request)
+ assert.NotNil(t, err)
+ assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error parsing E2 Setup Request failed extract Payload: no | separator found")
+}
+
+func TestParseSetupRequest_UnmarshalFailure(t *testing.T) {
+ handler, _, _, _, _, _ := initMocks(t)
+ prefBytes := []byte(prefix)
+ request, _, err := handler.parseSetupRequest(append(prefBytes, 1, 2, 3))
+ assert.Nil(t, request)
+ assert.NotNil(t, err)
+ assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: 31302e302e322e31353a393939397c010203")
+}
+
+func TestE2SetupRequestNotificationHandler_HandleNewGnbSuccess(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ var e2tInstance = &entities.E2TInstance{}
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ var gnb *entities.NodebInfo
+ readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ nodebInfo := getExpectedNodebWithFunctionsForNewRan(notificationRequest.Payload)
+ writerMock.On("SaveNodeb", mock.Anything, nodebInfo).Return(nil)
+ routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
+ e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
+ var errEmpty error
+ rmrMessage := &rmrCgo.MBuf{}
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(rmrMessage, errEmpty)