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.
25 "github.com/stretchr/testify/assert"
30 func TestHandleSuccessEnbConfigUpdate(t *testing.T){
31 log, err := logger.InitLogger(logger.InfoLevel)
33 t.Errorf("#endc_configuration_update_handler_test.TestHandleSuccessEndcConfigUpdate - failed to initialize logger, error: %s", err)
35 h := X2EnbConfigurationUpdateHandler{}
36 E2Sessions := make(sessions.E2Sessions)
38 payload := tests.GetPackedPayload(t)
39 mBuf := rmrCgo.NewMBuf(10370, len(payload),"RanName", &payload, &tests.DummyXAction)
40 notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
41 messageChannel := make(chan *models.NotificationResponse)
43 go h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)
45 response := <-messageChannel
47 assert.NotEmpty(t, response)
48 assert.EqualValues(t, 10081, response.MgsType)
49 assert.True(t, len(response.Payload) > 0)
52 func TestHandleFailureEnbConfigUpdate(t *testing.T){
53 log, err := logger.InitLogger(logger.InfoLevel)
55 t.Errorf("#endc_configuration_update_handler_test.TestHandleFailureEndcConfigUpdate - failed to initialize logger, error: %s", err)
57 h := X2EnbConfigurationUpdateHandler{}
58 E2Sessions := make(sessions.E2Sessions)
60 mBuf := rmrCgo.NewMBuf(tests.MessageType, 4,"RanName", &tests.DummyPayload, &tests.DummyXAction)
61 notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
62 messageChannel := make(chan *models.NotificationResponse)
64 go h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)
66 response := <-messageChannel
68 assert.NotEmpty(t, response)
69 assert.EqualValues(t, 10082, response.MgsType)
70 assert.True(t, len(response.Payload) > 0)