RIC:1060: Change in PTL
[ric-plt/nodeb-rnib.git] / reader / rNibReader_test.go
index dea8970..3007b33 100644 (file)
@@ -27,6 +27,7 @@ import (
        "github.com/golang/protobuf/proto"
        "github.com/pkg/errors"
        "github.com/stretchr/testify/assert"
+       "strconv"
        "testing"
        "time"
 )
@@ -432,7 +433,13 @@ func TestGetListEnbIds(t *testing.T) {
        idsData := make([]string, listSize)
        idsEntities := make([]*entities.NbIdentity, listSize)
        for i := 0; i < listSize; i++ {
-               nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
+               nbIdentity := &entities.NbIdentity{
+                       InventoryName: name,
+                       GlobalNbId: &entities.GlobalNbId{
+                               PlmnId: strconv.FormatInt(int64(plmnId+i), 16),
+                               NbId:   strconv.FormatInt(int64(nbId+i), 16),
+                       },
+               }
                data, err := proto.Marshal(nbIdentity)
                if err != nil {
                        t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
@@ -490,7 +497,13 @@ func TestGetListGnbIds(t *testing.T) {
        idsData := make([]string, listSize)
        idsEntities := make([]*entities.NbIdentity, listSize)
        for i := 0; i < listSize; i++ {
-               nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
+               nbIdentity := &entities.NbIdentity{
+                       InventoryName: name,
+                       GlobalNbId: &entities.GlobalNbId{
+                               PlmnId: strconv.FormatInt(int64(plmnId+i), 16),
+                               NbId:   strconv.FormatInt(int64(nbId+i), 16),
+                       },
+               }
                data, err := proto.Marshal(nbIdentity)
                if err != nil {
                        t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
@@ -1230,6 +1243,34 @@ func TestGetGeneralConfigurationUnmarshalError(t *testing.T) {
        assert.Equal(t, rNibErr.Error(), "unexpected end of JSON input")
 }
 
+func TestGetRanFunctionDefinition(t *testing.T) {
+    name := "name"
+    oid := "1.3.6.1.4.1.1.2.2.2"
+    w, sdlInstanceMock := initSdlSyncStorageMock()
+    nb := entities.NodebInfo{}
+    nb.ConnectionStatus = 1
+    nb.Ip = "localhost"
+    nb.Port = 5656
+    enb := entities.Enb{}
+    cell := entities.ServedCellInfo{Tac: "tac"}
+    enb.ServedCells = []*entities.ServedCellInfo{&cell}
+    nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
+    var e error
+    data, err := proto.Marshal(&nb)
+    if err != nil {
+        t.Errorf("#rNibReader_test.GetRanFunctionDefinition - Failed to marshal ENB instance. Error: %v", err)
+    }
+    redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
+    if rNibErr != nil {
+        t.Errorf("#rNibReader_test.TestRanFunctionDefinition - failed to validate key parameter")
+    }
+    ret := map[string]interface{}{redisKey: string(data)}
+    sdlInstanceMock.On("Get", common.GetRNibNamespace(), []string{redisKey}).Return(ret, e)
+    ranFuncs, er := w.GetRanFunctionDefinition(name, oid)
+    assert.IsType(t, &common.ResourceNotFoundError{}, er)
+    assert.Nil(t, ranFuncs)
+}
+
 //integration tests
 //
 //func TestGetEnbInteg(t *testing.T){