+func TestGetListNodesIdsGnbSdlgoFailure(t *testing.T) {
+
+ readerPool = nil
+ sdlInstanceMock := initSdlInstanceMock(namespace, 1)
+ w := GetRNibReader()
+
+ name := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
+ var nilError error
+ data, err := proto.Marshal(nbIdentity)
+ if err != nil {
+ t.Errorf("#rNibReader_test.TestGetListNodesIdsGnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
+ }
+ sdlInstanceMock.On("GetMembers", EnbType).Return([]string{string(data)}, nilError)
+
+ errMsg := "expected Sdlgo error"
+ errMsgExpected := "2 INTERNAL_ERROR - expected Sdlgo error"
+ expectedError := errors.New(errMsg)
+ var nilData []string
+ sdlInstanceMock.On("GetMembers", GnbType).Return(nilData, expectedError)
+
+ ids, er := w.GetListNodebIds()
+ assert.NotNil(t, er)
+ assert.Nil(t, ids)
+ assert.Equal(t, 2, er.GetCode())
+ assert.EqualValues(t, errMsgExpected, er.Error())
+}
+
+func TestGetListNodesIdsEnbSdlgoFailure(t *testing.T) {
+
+ readerPool = nil
+ sdlInstanceMock := initSdlInstanceMock(namespace, 1)
+ w := GetRNibReader()
+
+ name := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
+ var nilError error
+ data, err := proto.Marshal(nbIdentity)
+ if err != nil {
+ t.Errorf("#rNibReader_test.TestGetListNodesIdsEnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
+ }
+ sdlInstanceMock.On("GetMembers", GnbType).Return([]string{string(data)}, nilError)
+
+ errMsg := "expected Sdlgo error"
+ errMsgExpected := "2 INTERNAL_ERROR - expected Sdlgo error"
+ expectedError := errors.New(errMsg)
+ var nilData []string
+ sdlInstanceMock.On("GetMembers", EnbType).Return(nilData, expectedError)
+
+ ids, er := w.GetListNodebIds()
+ assert.NotNil(t, er)
+ assert.Nil(t, ids)
+ assert.Equal(t, 2, er.GetCode())
+ assert.EqualValues(t, errMsgExpected, er.Error())
+}
+
+func TestGetListNodesIdsEnbSdlgoSuccess(t *testing.T) {
+
+ readerPool = nil
+ sdlInstanceMock := initSdlInstanceMock(namespace, 1)
+ w := GetRNibReader()
+
+ name := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
+ var nilError error
+ data, err := proto.Marshal(nbIdentity)
+ if err != nil {
+ t.Errorf("#rNibReader_test.TestGetListNodesIdsEnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
+ }
+ sdlInstanceMock.On("GetMembers", GnbType).Return([]string{string(data)}, nilError)
+ sdlInstanceMock.On("GetMembers", EnbType).Return([]string{string(data)}, nilError)
+
+ ids, er := w.GetListNodebIds()
+ assert.Nil(t, er)
+ assert.NotNil(t, ids)
+ assert.Len(t, ids, 2)
+}
+