// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
package httpmsghandlerprovider
import (
+ "e2mgr/clients"
"e2mgr/configuration"
"e2mgr/e2managererrors"
"e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/mocks"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
"e2mgr/services"
"e2mgr/services/rmrsender"
"e2mgr/tests"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"github.com/stretchr/testify/assert"
"reflect"
"testing"
func getRmrSender(rmrMessengerMock *mocks.RmrMessengerMock, log *logger.Logger) *rmrsender.RmrSender {
rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
rmrMessengerMock.On("Init", tests.GetPort(), tests.MaxMsgSize, tests.Flags, log).Return(&rmrMessenger)
- return rmrsender.NewRmrSender(log, &rmrMessenger)
+ return rmrsender.NewRmrSender(log, rmrMessenger)
}
func setupTest(t *testing.T) *IncomingRequestHandlerProvider {
rmrMessengerMock := &mocks.RmrMessengerMock{}
log := initLog(t)
- config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
- readerProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return &mocks.RnibWriterMock{}
- }
- rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3, RnibWriter: configuration.RnibWriterConfig{StateChangeMessageChannel: "RAN_CONNECTION_STATUS_CHANGE", RanManipulationMessageChannel: "RAN_MANIPULATION"}}
+ config.RoutingManager.BaseUrl = "http://10.10.2.15:12020/routingmanager"
+ readerMock := &mocks.RnibReaderMock{}
+ writerMock := &mocks.RnibWriterMock{}
+ rnibDataService := services.NewRnibDataService(log, config, readerMock, writerMock)
rmrSender := getRmrSender(rmrMessengerMock, log)
ranSetupManager := managers.NewRanSetupManager(log, rmrSender, rnibDataService)
- return NewIncomingRequestHandlerProvider(log, rmrSender, configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
+ e2tInstancesManager := managers.NewE2TInstancesManager(rnibDataService, log)
+ httpClientMock := &mocks.HttpClientMock{}
+ rmClient := clients.NewRoutingManagerClient(log, config, httpClientMock)
+ ranListManager := managers.NewRanListManager(log)
+ ranAlarmService := services.NewRanAlarmService(log, config)
+ ranConnectStatusChangeManager := managers.NewRanConnectStatusChangeManager(log, rnibDataService,ranListManager, ranAlarmService)
+ e2tAssociationManager := managers.NewE2TAssociationManager(log, rnibDataService, e2tInstancesManager, rmClient, ranConnectStatusChangeManager)
+ return NewIncomingRequestHandlerProvider(log, rmrSender, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, e2tInstancesManager, e2tAssociationManager, rmClient, ranConnectStatusChangeManager)
}
func TestNewIncomingRequestHandlerProvider(t *testing.T) {
assert.True(t, ok)
}
-func TestX2SetupRequestHandler(t *testing.T) {
- provider := setupTest(t)
- handler, err := provider.GetHandler(X2SetupRequest)
-
- assert.NotNil(t, provider)
- assert.Nil(t, err)
-
- _, ok := handler.(*httpmsghandlers.SetupRequestHandler)
-
- assert.True(t, ok)
-}
-
-func TestEndcSetupRequestHandler(t *testing.T) {
+func TestSetGeneralConfigurationHandler(t *testing.T) {
provider := setupTest(t)
- handler, err := provider.GetHandler(EndcSetupRequest)
+ handler, err := provider.GetHandler(SetGeneralConfigurationRequest)
assert.NotNil(t, provider)
assert.Nil(t, err)
- _, ok := handler.(*httpmsghandlers.SetupRequestHandler)
+ _, ok := handler.(*httpmsghandlers.SetGeneralConfigurationHandler)
assert.True(t, ok)
}