+func TestConnFailureTwiceGetNodebIdList(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ invName := "abcd"
+ var nodeb *entities.NodebInfo = nil
+ var nodeIds []*entities.NbIdentity = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetNodeb", invName).Return(nodeb, mockErr)
+ readerMock.On("GetListNodebIds").Return(nodeIds, mockErr)
+
+ res, err := rnibDataService.GetListNodebIds()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 3)
+ assert.True(t, strings.Contains(err.Error(), "connection error", ))
+ assert.Equal(t, nodeIds, res)
+
+ res2, err := rnibDataService.GetNodeb(invName)
+ readerMock.AssertNumberOfCalls(t, "GetNodeb", 3)
+ assert.True(t, strings.Contains(err.Error(), "connection error", ))
+ assert.Equal(t, nodeb, res2)
+}
+
+func TestConnFailureWithAnotherConfig(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTestWithMaxAttempts(t, 5)
+
+ var nodeIds []*entities.NbIdentity = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetListNodebIds").Return(nodeIds, mockErr)
+
+ res, err := rnibDataService.GetListNodebIds()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 5)
+ assert.True(t, strings.Contains(err.Error(), "connection error", ))
+ assert.Equal(t, nodeIds, res)
+}
+
+func TestPingRnibConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var nodeIds []*entities.NbIdentity = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetListNodebIds").Return(nodeIds, mockErr)
+
+ res := rnibDataService.PingRnib()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 3)
+ assert.False(t, res)
+}
+
+func TestPingRnibOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var nodeIds []*entities.NbIdentity = nil
+ readerMock.On("GetListNodebIds").Return(nodeIds, nil)
+
+ res := rnibDataService.PingRnib()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 1)
+ assert.True(t, res)
+}
+
+func TestPingRnibOkOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var nodeIds []*entities.NbIdentity = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetListNodebIds").Return(nodeIds, mockErr)
+
+ res := rnibDataService.PingRnib()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 1)
+ assert.True(t, res)
+}
+
+func TestSuccessfulUpdateNodebInfoOnConnectionStatusInversion(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+ event := "event"
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", nodebInfo, "RAN_CONNECTION_STATUS_CHANGE", event).Return(nil)
+
+ rnibDataService.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, event)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoOnConnectionStatusInversion", 1)
+}
+
+func TestConnFailureUpdateNodebInfoOnConnectionStatusInversion(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+ event := "event"
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", nodebInfo, "RAN_CONNECTION_STATUS_CHANGE", event).Return(mockErr)
+
+ rnibDataService.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, event)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoOnConnectionStatusInversion", 3)
+}
+