[RICPLT-1783] Add ValidateAndBuildRanLoadInformationKey | Fix dependencies | Reformat... 90/590/1
authoris005q <idan.shalom@intl.att.com>
Tue, 30 Jul 2019 14:09:03 +0000 (17:09 +0300)
committeris005q <idan.shalom@intl.att.com>
Tue, 30 Jul 2019 14:09:48 +0000 (17:09 +0300)
Change-Id: Ibaf0d82759909884d5f9d73582449f1c4b9aed52
Signed-off-by: is005q <idan.shalom@intl.att.com>
common/go.mod
common/go.sum
common/utils.go
common/utils_test.go
reader/go.mod
reader/rNibReader.go
reader/rNibReader_test.go
reader/sdlInstanceMock.go

index ac77bf2..fd1b918 100644 (file)
@@ -2,4 +2,7 @@ module gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common
 
 go 1.12
 
-require github.com/stretchr/testify v1.3.0
+require (
+       github.com/pkg/errors v0.8.1
+       github.com/stretchr/testify v1.3.0
+)
index 93b73c6..9f0c72d 100644 (file)
@@ -1,6 +1,10 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
index f7a84ad..7b7b4e2 100644 (file)
@@ -20,9 +20,10 @@ import (
        "errors"
        "fmt"
 )
+
 /*
 ValidateAndBuildCellIdKey builds key according to the specified format returns the resulting string
- */
+*/
 func ValidateAndBuildCellIdKey(cellId string) (string, IRNibError) {
        if cellId == "" {
                e := errors.New("#utils.ValidateAndBuildCellIdKey - an empty cell id received")
@@ -30,9 +31,10 @@ func ValidateAndBuildCellIdKey(cellId string) (string, IRNibError) {
        }
        return fmt.Sprintf("CELL:%s", cellId), nil
 }
+
 /*
 ValidateAndBuildNrCellIdKey builds key according to the specified format returns the resulting string
- */
+*/
 func ValidateAndBuildNrCellIdKey(cellId string) (string, IRNibError) {
        if cellId == "" {
                e := errors.New("#utils.ValidateAndBuildNrCellIdKey - an empty cell id received")
@@ -40,9 +42,10 @@ func ValidateAndBuildNrCellIdKey(cellId string) (string, IRNibError) {
        }
        return fmt.Sprintf("NRCELL:%s", cellId), nil
 }
+
 /*
 ValidateAndBuildNodeBNameKey builds key according to the specified format returns the resulting string
- */
+*/
 func ValidateAndBuildNodeBNameKey(inventoryName string) (string, IRNibError) {
        if inventoryName == "" {
                e := errors.New("#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received")
@@ -50,9 +53,10 @@ func ValidateAndBuildNodeBNameKey(inventoryName string) (string, IRNibError) {
        }
        return fmt.Sprintf("RAN:%s", inventoryName), nil
 }
+
 /*
 ValidateAndBuildNodeBIdKey builds key according to the specified format returns the resulting string
- */
+*/
 func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (string, IRNibError) {
        if nodeType == "" {
                e := errors.New("#utils.ValidateAndBuildNodeBIdKey - an empty node type received")
@@ -68,13 +72,24 @@ func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (st
        }
        return fmt.Sprintf("%s:%s:%s", nodeType, plmnId, nbId), nil
 }
+
 /*
 ValidateAndBuildCellNamePciKey builds key according to the specified format returns the resulting string
- */
+*/
 func ValidateAndBuildCellNamePciKey(inventoryName string, pci uint32) (string, IRNibError) {
        if inventoryName == "" {
                e := errors.New("#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received")
                return "", NewValidationError(e)
        }
        return fmt.Sprintf("PCI:%s:%02x", inventoryName, pci), nil
-}
\ No newline at end of file
+}
+
+func ValidateAndBuildRanLoadInformationKey(inventoryName string) (string, IRNibError) {
+
+       if inventoryName == "" {
+               e := errors.New("#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received")
+               return "", NewValidationError(e)
+       }
+
+       return fmt.Sprintf("LOAD:%s", inventoryName), nil
+}
index 640362c..2364467 100644 (file)
@@ -124,4 +124,25 @@ func TestValidateAndBuildCellNamePciKeySuccess(t *testing.T){
        assert.Contains(t, key, delimiter)
        assert.Contains(t, key, prefix)
        assert.Contains(t, key, "270f")
+}
+
+
+func TestValidateAndBuildRanLoadInformationKeySuccess(t *testing.T) {
+       name := "name"
+       prefix := "LOAD"
+       delimiter := ":"
+       key, err := ValidateAndBuildRanLoadInformationKey(name)
+       if err != nil{
+               t.Errorf("#utils_test.TestValidateAndBuildNodeBNameKey - failed to validate key parameter")
+       }
+       assert.Contains(t, key, name)
+       assert.Contains(t, key, delimiter)
+       assert.Contains(t, key, prefix)
+}
+
+func TestValidateAndBuildRanLoadInformationKeyFailure(t *testing.T) {
+       name := ""
+       _, err := ValidateAndBuildRanLoadInformationKey(name)
+       assert.NotNil(t, err)
+       assert.Equal(t, VALIDATION_ERROR, err.GetCode())
 }
\ No newline at end of file
index 270cb98..a3dcb17 100644 (file)
@@ -3,9 +3,9 @@ module gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader
 go 1.12
 
 require (
-       gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.2.0
        gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.10
        gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.10
+       gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.2.0
        github.com/golang/protobuf v1.3.1
        github.com/pkg/errors v0.8.1
        github.com/stretchr/testify v1.3.0
index 70bbdb2..ed87ff7 100644 (file)
@@ -17,8 +17,8 @@
 package reader
 
 import (
-       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
        "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
        "github.com/golang/protobuf/proto"
        "github.com/pkg/errors"
@@ -33,7 +33,7 @@ type rNibReaderInstance struct {
 
 /*
 RNibReader interface allows retrieving data from redis BD by various keys
- */
+*/
 type RNibReader interface {
        // GetNodeb retrieves responding nodeb entity from redis DB by nodeb inventory name
        GetNodeb(inventoryName string) (*entities.NodebInfo, common.IRNibError)
@@ -42,28 +42,29 @@ type RNibReader interface {
        // GetCellList retrieves the list of cell entities belonging to responding nodeb entity from redis DB by nodeb inventory name
        GetCellList(inventoryName string) (*entities.Cells, common.IRNibError)
        // GetListGnbIds retrieves the list of gNodeb identity entities
-       GetListGnbIds()(*[]*entities.NbIdentity, common.IRNibError)
+       GetListGnbIds() (*[]*entities.NbIdentity, common.IRNibError)
        // GetListEnbIds retrieves the list of eNodeb identity entities
-       GetListEnbIds()(*[]*entities.NbIdentity, common.IRNibError)
+       GetListEnbIds() (*[]*entities.NbIdentity, common.IRNibError)
        // Close closes reader's pool
-       GetCountGnbList()(int, common.IRNibError)
+       GetCountGnbList() (int, common.IRNibError)
        // GetCell retrieves the cell entity belonging to responding nodeb from redis DB by nodeb inventory name and cell pci
        GetCell(inventoryName string, pci uint32) (*entities.Cell, common.IRNibError)
        // GetCellById retrieves the cell entity from redis DB by cell type and cell Id
        GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, common.IRNibError)
 }
+
 /*
  Init initializes the infrastructure required for the RNibReader instance
 */
 func Init(namespace string, poolSize int) {
        initPool(poolSize,
-       func() interface{} {
-               var sdlI common.ISdlInstance = sdlgo.NewSdlInstance(namespace, sdlgo.NewDatabase())
-               return &rNibReaderInstance{sdl: &sdlI, namespace: namespace}
-       },
+               func() interface{} {
+                       var sdlI common.ISdlInstance = sdlgo.NewSdlInstance(namespace, sdlgo.NewDatabase())
+                       return &rNibReaderInstance{sdl: &sdlI, namespace: namespace}
+               },
                func(obj interface{}) {
-               (*obj.(*rNibReaderInstance).sdl).Close()
-       })
+                       (*obj.(*rNibReaderInstance).sdl).Close()
+               })
 }
 
 func initPool(poolSize int, newObj func() interface{}, destroyObj func(interface{})) {
@@ -72,25 +73,25 @@ func initPool(poolSize int, newObj func() interface{}, destroyObj func(interface
 
 /*
 GetRNibReader returns RNibReader instance from the pool
- */
+*/
 func GetRNibReader() RNibReader {
        return readerPool.Get().(RNibReader)
 }
 
 func (w *rNibReaderInstance) GetNodeb(inventoryName string) (*entities.NodebInfo, common.IRNibError) {
        name, rNibErr := common.ValidateAndBuildNodeBNameKey(inventoryName)
-       if rNibErr != nil{
+       if rNibErr != nil {
                return nil, rNibErr
        }
        defer readerPool.Put(w)
        data, err := (*w.sdl).Get([]string{name})
-       if err != nil{
+       if err != nil {
                return nil, common.NewInternalError(err)
        }
        nb := entities.NodebInfo{}
-       if data != nil && data[name] != nil{
-               err = proto.Unmarshal( []byte(data[name].(string)), &nb)
-               if err != nil{
+       if data != nil && data[name] != nil {
+               err = proto.Unmarshal([]byte(data[name].(string)), &nb)
+               if err != nil {
                        return nil, common.NewInternalError(err)
                }
                return &nb, nil
@@ -100,18 +101,18 @@ func (w *rNibReaderInstance) GetNodeb(inventoryName string) (*entities.NodebInfo
 
 func (w *rNibReaderInstance) GetNodebByGlobalNbId(nodeType entities.Node_Type, globalNbId *entities.GlobalNbId) (*entities.NodebInfo, common.IRNibError) {
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(nodeType.String(), globalNbId.GetPlmnId(), globalNbId.GetNbId())
-       if rNibErr != nil{
+       if rNibErr != nil {
                return nil, rNibErr
        }
        defer readerPool.Put(w)
        data, err := (*w.sdl).Get([]string{key})
-       if err != nil{
+       if err != nil {
                return nil, common.NewInternalError(err)
        }
        nb := entities.NodebInfo{}
-       if data != nil && data[key] != nil{
-               err = proto.Unmarshal( []byte(data[key].(string)), &nb)
-               if err != nil{
+       if data != nil && data[key] != nil {
+               err = proto.Unmarshal([]byte(data[key].(string)), &nb)
+               if err != nil {
                        return nil, common.NewInternalError(err)
                }
                return &nb, nil
@@ -119,60 +120,60 @@ func (w *rNibReaderInstance) GetNodebByGlobalNbId(nodeType entities.Node_Type, g
        return nil, common.NewResourceNotFoundError(errors.Errorf("#rNibReader.GetNodebByGlobalNbId - responding node not found, global nodeb Id: %s", key))
 }
 
-func (w *rNibReaderInstance) GetCellList(inventoryName string) (*entities.Cells, common.IRNibError){
+func (w *rNibReaderInstance) GetCellList(inventoryName string) (*entities.Cells, common.IRNibError) {
        cells := &entities.Cells{}
        nb, err := w.GetNodeb(inventoryName)
-       if err != nil{
+       if err != nil {
                return nil, err
        }
-       if nb.GetEnb() != nil && len(nb.GetEnb().GetServedCells()) > 0{
+       if nb.GetEnb() != nil && len(nb.GetEnb().GetServedCells()) > 0 {
                cells.Type = entities.Cell_LTE_CELL
-               cells.List = &entities.Cells_ServedCellInfos{ServedCellInfos:&entities.ServedCellInfoList{ServedCells:nb.GetEnb().GetServedCells()}}
+               cells.List = &entities.Cells_ServedCellInfos{ServedCellInfos: &entities.ServedCellInfoList{ServedCells: nb.GetEnb().GetServedCells()}}
                return cells, nil
-       } else if nb.GetGnb() != nil && len(nb.GetGnb().GetServedNrCells()) > 0{
+       } else if nb.GetGnb() != nil && len(nb.GetGnb().GetServedNrCells()) > 0 {
                cells.Type = entities.Cell_NR_CELL
-               cells.List = &entities.Cells_ServedNrCells{ServedNrCells:&entities.ServedNRCellList{ServedCells:nb.GetGnb().GetServedNrCells()}}
+               cells.List = &entities.Cells_ServedNrCells{ServedNrCells: &entities.ServedNRCellList{ServedCells: nb.GetGnb().GetServedNrCells()}}
                return cells, nil
        }
        return nil, common.NewResourceNotFoundError(errors.Errorf("#rNibReader.GetCellList - served cells not found. Responding node RAN name: %s.", inventoryName))
 }
 
-func (w *rNibReaderInstance) GetListGnbIds()(*[]*entities.NbIdentity, common.IRNibError){
+func (w *rNibReaderInstance) GetListGnbIds() (*[]*entities.NbIdentity, common.IRNibError) {
        defer readerPool.Put(w)
        data, err := (*w.sdl).GetMembers("GNB")
-       if err != nil{
+       if err != nil {
                return nil, common.NewInternalError(err)
        }
        return unmarshalIdentityList(data)
 }
 
-func (w *rNibReaderInstance) GetListEnbIds()(*[]*entities.NbIdentity, common.IRNibError){
+func (w *rNibReaderInstance) GetListEnbIds() (*[]*entities.NbIdentity, common.IRNibError) {
        defer readerPool.Put(w)
        data, err := (*w.sdl).GetMembers("ENB")
-       if err != nil{
+       if err != nil {
                return nil, common.NewInternalError(err)
        }
        return unmarshalIdentityList(data)
 }
 
-func (w *rNibReaderInstance) GetCountGnbList()(int, common.IRNibError){
+func (w *rNibReaderInstance) GetCountGnbList() (int, common.IRNibError) {
        defer readerPool.Put(w)
        data, err := (*w.sdl).GetMembers("GNB")
-       if err != nil{
+       if err != nil {
                return 0, common.NewInternalError(err)
        }
        return len(data), nil
 }
 
-func (w *rNibReaderInstance) GetCell(inventoryName string, pci uint32) (*entities.Cell, common.IRNibError){
+func (w *rNibReaderInstance) GetCell(inventoryName string, pci uint32) (*entities.Cell, common.IRNibError) {
        key, rNibErr := common.ValidateAndBuildCellNamePciKey(inventoryName, pci)
-       if rNibErr != nil{
+       if rNibErr != nil {
                return nil, rNibErr
        }
        return (*w).getCellByKey(key)
 }
 
-func (w *rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, common.IRNibError){
+func (w *rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, common.IRNibError) {
        var key string
        var rNibErr common.IRNibError
        if cellType == entities.Cell_LTE_CELL {
@@ -182,22 +183,22 @@ func (w *rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId str
        } else {
                return nil, common.NewValidationError(errors.Errorf("#rNibReader.GetCellById - invalid cell type: %v", cellType))
        }
-       if rNibErr != nil{
+       if rNibErr != nil {
                return nil, rNibErr
        }
        return (*w).getCellByKey(key)
 }
 
-func (w *rNibReaderInstance) getCellByKey(key string) (*entities.Cell, common.IRNibError){
+func (w *rNibReaderInstance) getCellByKey(key string) (*entities.Cell, common.IRNibError) {
        defer readerPool.Put(w)
        data, err := (*w.sdl).Get([]string{key})
-       if err != nil{
+       if err != nil {
                return nil, common.NewInternalError(err)
        }
        cell := entities.Cell{}
-       if data != nil && data[key] != nil{
-               err = proto.Unmarshal( []byte(data[key].(string)), &cell)
-               if err != nil{
+       if data != nil && data[key] != nil {
+               err = proto.Unmarshal([]byte(data[key].(string)), &cell)
+               if err != nil {
                        return nil, common.NewInternalError(err)
                }
                return &cell, nil
@@ -205,12 +206,12 @@ func (w *rNibReaderInstance) getCellByKey(key string) (*entities.Cell, common.IR
        return nil, common.NewResourceNotFoundError(errors.Errorf("#rNibReader.getCellByKey - cell not found, key: %s", key))
 }
 
-func unmarshalIdentityList(data []string ) (*[]*entities.NbIdentity, common.IRNibError){
+func unmarshalIdentityList(data []string) (*[]*entities.NbIdentity, common.IRNibError) {
        var members []*entities.NbIdentity
-       for _, d := range data{
+       for _, d := range data {
                member := entities.NbIdentity{}
                err := proto.Unmarshal([]byte(d), &member)
-               if err != nil{
+               if err != nil {
                        return nil, common.NewInternalError(err)
                }
                members = append(members, &member)
@@ -218,6 +219,6 @@ func unmarshalIdentityList(data []string ) (*[]*entities.NbIdentity, common.IRNi
        return &members, nil
 }
 
-func Close(){
+func Close() {
        readerPool.Close()
-}
\ No newline at end of file
+}
index 105c0ba..f2005c4 100644 (file)
@@ -18,8 +18,8 @@ package reader
 
 import (
        "errors"
-       "gerrit.ranco-dev-tools.eastus.cloudapp.azure.com/ric-plt/nodeb-rnib.git/common"
-       "gerrit.ranco-dev-tools.eastus.cloudapp.azure.com/ric-plt/nodeb-rnib.git/entities"
+       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
        "github.com/golang/protobuf/proto"
        "github.com/stretchr/testify/assert"
        "testing"
@@ -56,8 +56,8 @@ func TestInitPool(t *testing.T) {
        assert.Equal(t, 0, created, "number of created objects in the readerPool should be 0")
 }
 
-func initSdlInstanceMock(namespace string, poolSize int) * MockSdlInstance {
-       sdlInstanceMock := new( MockSdlInstance)
+func initSdlInstanceMock(namespace string, poolSize int) *MockSdlInstance {
+       sdlInstanceMock := new(MockSdlInstance)
        initPool(poolSize, func() interface{} {
                sdlI := common.ISdlInstance(sdlInstanceMock)
                return &rNibReaderInstance{sdl: &sdlI, namespace: namespace}
@@ -78,15 +78,15 @@ func TestGetNodeB(t *testing.T) {
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := entities.ServedCellInfo{Tac:"tac"}
+       cell := entities.ServedCellInfo{Tac: "tac"}
        enb.ServedCells = []*entities.ServedCellInfo{&cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibReader_test.TestGetNb - Failed to marshal ENB instance. Error: %v", err)
        }
-       ret := map[string]interface{}{"RAN:" + name:string(data)}
+       ret := map[string]interface{}{"RAN:" + name: string(data)}
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        getNb, er := w.GetNodeb(name)
        assert.Nil(t, er)
@@ -118,8 +118,8 @@ func TestGetNodeBUnmarshalFailure(t *testing.T) {
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
        var e error
-       ret := make( map[string]interface{}, 1)
-       ret["RAN:" + name] = "data"
+       ret := make(map[string]interface{}, 1)
+       ret["RAN:"+name] = "data"
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        getNb, er := w.GetNodeb(name)
        assert.NotNil(t, er)
@@ -155,15 +155,15 @@ func TestGetNodeBCellsListEnb(t *testing.T) {
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := entities.ServedCellInfo{Tac:"tac"}
+       cell := entities.ServedCellInfo{Tac: "tac"}
        enb.ServedCells = []*entities.ServedCellInfo{&cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal ENB instance. Error: %v", err)
        }
-       ret := map[string]interface{}{"RAN:" + name:string(data)}
+       ret := map[string]interface{}{"RAN:" + name: string(data)}
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        cells, er := w.GetCellList(name)
        assert.Nil(t, er)
@@ -184,15 +184,15 @@ func TestGetNodeBCellsListGnb(t *testing.T) {
        nb.Port = 5656
        nb.NodeType = entities.Node_GNB
        gnb := entities.Gnb{}
-       cell := entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{NrPci:10}}
+       cell := entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{NrPci: 10}}
        gnb.ServedNrCells = []*entities.ServedNRCell{&cell}
-       nb.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
+       nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal GNB instance. Error: %v", err)
        }
-       ret := map[string]interface{}{"RAN:" + name:string(data)}
+       ret := map[string]interface{}{"RAN:" + name: string(data)}
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        cells, er := w.GetCellList(name)
        assert.Nil(t, er)
@@ -208,8 +208,8 @@ func TestGetNodeBCellsListNodeUnmarshalFailure(t *testing.T) {
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
        var e error
-       ret := make( map[string]interface{}, 1)
-       ret["RAN:" + name] = "data"
+       ret := make(map[string]interface{}, 1)
+       ret["RAN:"+name] = "data"
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        cells, er := w.GetCellList(name)
        assert.NotNil(t, er)
@@ -243,13 +243,13 @@ func TestGetNodeBCellsListNotFoundFailureEnb(t *testing.T) {
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibReader_test.TestGetNbCellsListNotFoundFailure - Failed to marshal ENB instance. Error: %v", err)
        }
-       ret := map[string]interface{}{"RAN:" + name:string(data)}
+       ret := map[string]interface{}{"RAN:" + name: string(data)}
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        _, er := w.GetCellList(name)
        assert.NotNil(t, er)
@@ -266,13 +266,13 @@ func TestGetNodeBCellsListNotFoundFailureGnb(t *testing.T) {
        nb.Ip = "localhost"
        nb.Port = 5656
        gnb := entities.Gnb{}
-       nb.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
+       nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibReader_test.TestGetNbCellsListNotFoundFailure - Failed to marshal ENB instance. Error: %v", err)
        }
-       ret := map[string]interface{}{"RAN:" + name:string(data)}
+       ret := map[string]interface{}{"RAN:" + name: string(data)}
        sdlInstanceMock.On("Get", []string{"RAN:" + name}).Return(ret, e)
        _, er := w.GetCellList(name)
        assert.NotNil(t, er)
@@ -290,7 +290,7 @@ func TestCloseOnClosedPoolFailure(t *testing.T) {
        var e error
        instanceMock.On("Close").Return(e)
        Close()
-       assert.Panics(t, func(){Close()})
+       assert.Panics(t, func() { Close() })
 }
 
 func TestCloseFailure(t *testing.T) {
@@ -335,7 +335,7 @@ func TestGetListGnbIdsSdlgoFailure(t *testing.T) {
        assert.NotNil(t, er)
        assert.Nil(t, ids)
        assert.Equal(t, 2, er.GetCode())
-       assert.EqualValues(t, errMsgExpected,er.Error())
+       assert.EqualValues(t, errMsgExpected, er.Error())
 }
 
 func TestGetListEnbIdsUnmarshalFailure(t *testing.T) {
@@ -358,7 +358,7 @@ func TestGetListEnbIdsOneId(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
        var e error
        data, err := proto.Marshal(nbIdentity)
        if err != nil {
@@ -394,8 +394,8 @@ func TestGetListEnbIds(t *testing.T) {
        w := GetRNibReader()
        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)}}
+       for i := 0; i < listSize; i++ {
+               nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
                data, err := proto.Marshal(nbIdentity)
                if err != nil {
                        t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
@@ -408,7 +408,7 @@ func TestGetListEnbIds(t *testing.T) {
        ids, er := w.GetListEnbIds()
        assert.Nil(t, er)
        assert.Len(t, *ids, listSize)
-       for i, id :=range *ids{
+       for i, id := range *ids {
                assert.Equal(t, id.GetInventoryName(), name)
                assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
                assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
@@ -422,7 +422,7 @@ func TestGetListGnbIdsOneId(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
        var e error
        data, err := proto.Marshal(nbIdentity)
        if err != nil {
@@ -458,8 +458,8 @@ func TestGetListGnbIds(t *testing.T) {
        w := GetRNibReader()
        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)}}
+       for i := 0; i < listSize; i++ {
+               nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
                data, err := proto.Marshal(nbIdentity)
                if err != nil {
                        t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
@@ -472,7 +472,7 @@ func TestGetListGnbIds(t *testing.T) {
        ids, er := w.GetListGnbIds()
        assert.Nil(t, er)
        assert.Len(t, *ids, listSize)
-       for i, id :=range *ids{
+       for i, id := range *ids {
                assert.Equal(t, id.GetInventoryName(), name)
                assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
                assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
@@ -502,7 +502,7 @@ func TestGetCountGnbListOneId(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
        var e error
        data, err := proto.Marshal(nbIdentity)
        if err != nil {
@@ -525,8 +525,8 @@ func TestGetCountGnbList(t *testing.T) {
        var e error
        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)}}
+       for i := 0; i < listSize; i++ {
+               nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
                data, err := proto.Marshal(nbIdentity)
                if err != nil {
                        t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
@@ -563,7 +563,7 @@ func TestGetCell(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       cellEntity := entities.Cell{Type:entities.Cell_LTE_CELL, Cell:&entities.Cell_ServedCellInfo{ServedCellInfo:&entities.ServedCellInfo{Pci:pci}}}
+       cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
        cellData, err := proto.Marshal(&cellEntity)
        if err != nil {
                t.Errorf("#rNibReader_test.TestGetCell - Failed to marshal Cell entity. Error: %v", err)
@@ -573,7 +573,7 @@ func TestGetCell(t *testing.T) {
        if rNibErr != nil {
                t.Errorf("#rNibReader_test.TestGetCell - failed to validate key parameter")
        }
-       ret := map[string]interface{}{key:string(cellData)}
+       ret := map[string]interface{}{key: string(cellData)}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
        cell, er := w.GetCell(name, pci)
        assert.Nil(t, er)
@@ -610,7 +610,7 @@ func TestGetCellUnmarshalFailure(t *testing.T) {
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
        var e error
-       ret := make( map[string]interface{}, 1)
+       ret := make(map[string]interface{}, 1)
        key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
        if rNibErr != nil {
                t.Errorf("#rNibReader_test.TestGetCellUnmarshalFailure - failed to validate key parameter")
@@ -650,14 +650,14 @@ func TestGetNodebById(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       nb := entities.NodebInfo{NodeType:entities.Node_ENB}
+       nb := entities.NodebInfo{NodeType: entities.Node_ENB}
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := entities.ServedCellInfo{Tac:"tac"}
+       cell := entities.ServedCellInfo{Tac: "tac"}
        enb.ServedCells = []*entities.ServedCellInfo{&cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
        var e error
        data, err := proto.Marshal(&nb)
        if err != nil {
@@ -667,12 +667,12 @@ func TestGetNodebById(t *testing.T) {
        plmnId := "02f829"
        nbId := "4a952a0a"
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
-       if rNibErr != nil{
+       if rNibErr != nil {
                t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
        }
-       ret := map[string]interface{}{key:string(data)}
+       ret := map[string]interface{}{key: string(data)}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
-       globalNbId := &entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}
+       globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
        getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
        assert.Nil(t, er)
        assert.Equal(t, getNb.Ip, nb.Ip)
@@ -690,12 +690,12 @@ func TestGetNodebByIdNotFoundFailureEnb(t *testing.T) {
        w := GetRNibReader()
        var e error
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
-       if rNibErr != nil{
+       if rNibErr != nil {
                t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
        }
        var ret map[string]interface{}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
-       globalNbId := &entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}
+       globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
        getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
        assert.NotNil(t, er)
        assert.Nil(t, getNb)
@@ -711,12 +711,12 @@ func TestGetNodebByIdNotFoundFailureGnb(t *testing.T) {
        w := GetRNibReader()
        var e error
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
-       if rNibErr != nil{
+       if rNibErr != nil {
                t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
        }
        var ret map[string]interface{}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
-       globalNbId := &entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}
+       globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
        getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
        assert.NotNil(t, er)
        assert.Nil(t, getNb)
@@ -731,14 +731,14 @@ func TestGetNodeByIdUnmarshalFailure(t *testing.T) {
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
-       if rNibErr != nil{
+       if rNibErr != nil {
                t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
        }
        var e error
-       ret := make( map[string]interface{}, 1)
+       ret := make(map[string]interface{}, 1)
        ret[key] = "data"
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
-       globalNbId := &entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}
+       globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
        getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
        assert.NotNil(t, er)
        assert.Nil(t, getNb)
@@ -755,13 +755,13 @@ func TestGetNodeByIdSdlgoFailure(t *testing.T) {
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
        key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
-       if rNibErr != nil{
+       if rNibErr != nil {
                t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
        }
        e := errors.New(errMsg)
        var ret map[string]interface{}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
-       globalNbId := &entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}
+       globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
        getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
        assert.NotNil(t, er)
        assert.Nil(t, getNb)
@@ -776,7 +776,7 @@ func TestGetCellById(t *testing.T) {
        readerPool = nil
        sdlInstanceMock := initSdlInstanceMock(namespace, 1)
        w := GetRNibReader()
-       cellEntity := entities.Cell{Type:entities.Cell_LTE_CELL, Cell:&entities.Cell_ServedCellInfo{ServedCellInfo:&entities.ServedCellInfo{Pci:pci}}}
+       cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
        cellData, err := proto.Marshal(&cellEntity)
        if err != nil {
                t.Errorf("#rNibReader_test.TestGetCellById - Failed to marshal Cell entity. Error: %v", err)
@@ -786,7 +786,7 @@ func TestGetCellById(t *testing.T) {
        if rNibErr != nil {
                t.Errorf("#rNibReader_test.TestGetCellById - failed to validate key parameter")
        }
-       ret := map[string]interface{}{key:string(cellData)}
+       ret := map[string]interface{}{key: string(cellData)}
        sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
        cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
        assert.Nil(t, er)
@@ -996,4 +996,4 @@ func TestGetCellByIdValidationFailureEnb(t *testing.T) {
 //     } else if cell != nil{
 //             fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
 //     }
-//}
\ No newline at end of file
+//}
index dd0a640..c03bf21 100644 (file)
@@ -106,7 +106,7 @@ func (m *MockSdlInstance) RemoveIf(key string, data interface{}) (bool, error) {
        return a.Bool(0), a.Error(1)
 }
 
-func (m *MockSdlInstance) AddMember(group string, member ...interface{}) error{
+func (m *MockSdlInstance) AddMember(group string, member ...interface{}) error {
        a := m.Called(group, member)
        return a.Error(0)
 }
@@ -123,11 +123,11 @@ func (m *MockSdlInstance) GetMembers(group string) ([]string, error) {
        a := m.Called(group)
        return a.Get(0).([]string), a.Error(1)
 }
-func (m *MockSdlInstance) IsMember(group string, member interface{}) (bool, error){
+func (m *MockSdlInstance) IsMember(group string, member interface{}) (bool, error) {
        a := m.Called(group, member)
        return a.Bool(0), a.Error(1)
 }
-func (m *MockSdlInstance) GroupSize(group string) (int64, error){
-       a := m.Called(group,)
+func (m *MockSdlInstance) GroupSize(group string) (int64, error) {
+       a := m.Called(group, )
        return int64(a.Int(0)), a.Error(1)
 }