[RICPLT-2157] Restructure handlers and converters.......
[ric-plt/e2mgr.git] / E2Manager / handlers / rmrmsghandlers / endc_configuration_update_handler_test.go
1 //
2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
4 //
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
8 //
9 //      http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 package rmrmsghandlers
18
19 import (
20         "e2mgr/logger"
21         "e2mgr/models"
22         "e2mgr/rmrCgo"
23         "e2mgr/sessions"
24         "e2mgr/tests"
25         "github.com/stretchr/testify/assert"
26         "testing"
27         "time"
28 )
29
30 func TestHandleSuccessEndcConfigUpdate(t *testing.T){
31 /*      log, err := logger.InitLogger(logger.InfoLevel)
32         if err!=nil{
33                 t.Errorf("#endc_configuration_update_handler_test.TestHandleSuccessEndcConfigUpdate - failed to initialize logger, error: %s", err)
34         }
35         h := EndcConfigurationUpdateHandler{}
36         E2Sessions := make(sessions.E2Sessions)
37
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)
42
43         go h.Handle(log, E2Sessions, &notificationRequest, messageChannel)
44
45         response := <-messageChannel
46
47         assert.NotEmpty(t, response)
48         assert.EqualValues(t, 10371, response.MgsType)
49         assert.True(t, len(response.Payload) > 0)*/
50 }
51
52 func TestHandleFailureEndcConfigUpdate(t *testing.T){
53         log, err := logger.InitLogger(logger.InfoLevel)
54         if err!=nil{
55                 t.Errorf("#endc_configuration_update_handler_test.TestHandleFailureEndcConfigUpdate - failed to initialize logger, error: %s", err)
56         }
57         h := EndcConfigurationUpdateHandler{}
58         E2Sessions := make(sessions.E2Sessions)
59
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)
63
64         go h.Handle(log, E2Sessions, &notificationRequest, messageChannel)
65
66         response := <-messageChannel
67
68         assert.NotEmpty(t, response)
69         assert.EqualValues(t, 10372, response.MgsType)
70         assert.True(t, len(response.Payload) > 0)
71 }