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"
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}
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)
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)
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)
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)
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)
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)
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)
var e error
instanceMock.On("Close").Return(e)
Close()
- assert.Panics(t, func(){Close()})
+ assert.Panics(t, func() { Close() })
}
func TestCloseFailure(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) {
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 {
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)
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())
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 {
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)
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())
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 {
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)
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)
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)
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")
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 {
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)
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)
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)
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)
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)
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)
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)
// } else if cell != nil{
// fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
// }
-//}
\ No newline at end of file
+//}