2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
21 package httpmsghandlers
29 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 "github.com/stretchr/testify/assert"
34 func setupGetNodebIdListRequestHandlerTest(t *testing.T) (*GetNodebIdListRequestHandler, *mocks.RnibReaderMock, managers.RanListManager) {
36 config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
37 readerMock := &mocks.RnibReaderMock{}
39 rnibDataService := services.NewRnibDataService(log, config, readerMock, nil)
40 ranListManager := managers.NewRanListManager(log, rnibDataService)
42 handler := NewGetNodebIdListRequestHandler(log, rnibDataService, ranListManager)
43 return handler, readerMock, ranListManager
46 func TestHandleGetNodebIdListSuccess(t *testing.T) {
47 handler, readerMock, ranListManager := setupGetNodebIdListRequestHandlerTest(t)
49 readerMock.On("GetListNodebIds").Return([]*entities.NbIdentity{}, rnibError)
51 err := ranListManager.InitNbIdentityMap()
53 t.Errorf("Error cannot init identity")
56 response, err := handler.Handle(nil)
58 assert.NotNil(t, response)
59 assert.IsType(t, &models.GetNodebIdListResponse{}, response)