"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
+ "unsafe"
)
const (
nodebInfo := &entities.NodebInfo{
ConnectionStatus: entities.ConnectionStatus_CONNECTING,
- ConnectionAttempts: 1,
RanName: RanName,
Ip: "10.0.2.2",
Port: 1231,
}
testContext.readerMock.On("GetNodeb", RanName).Return(nodebInfo, rnibErr)
- testContext.writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(tc.saveNodebMockError)
+ testContext.writerMock.On("SaveNodeb", mock.Anything).Return(tc.saveNodebMockError)
testContext.rmrMessengerMock.On("SendMsg", tc.statusChangeMbuf, true).Return(&rmrCgo.MBuf{}, tc.sendMsgError)
handler.Handle(¬ificationRequest)
var xAction []byte
resourceStatusPayload := models.NewResourceStatusPayload(nodeType, enums.RIC_TO_RAN)
resourceStatusJson, _ := json.Marshal(resourceStatusPayload)
- return rmrCgo.NewMBuf(rmrCgo.RAN_CONNECTED, len(resourceStatusJson), RanName, &resourceStatusJson, &xAction)
+ var msgSrc unsafe.Pointer
+ return rmrCgo.NewMBuf(rmrCgo.RAN_CONNECTED, len(resourceStatusJson), RanName, &resourceStatusJson, &xAction, msgSrc)
}
func executeHandleSetupFailureResponse(t *testing.T, tc setupFailureResponseTestCase) (*setupResponseTestContext, *entities.NodebInfo) {
nodebInfo := &entities.NodebInfo{
ConnectionStatus: entities.ConnectionStatus_CONNECTING,
- ConnectionAttempts: 1,
RanName: RanName,
Ip: "10.0.2.2",
Port: 1231,
}
testContext.readerMock.On("GetNodeb", RanName).Return(nodebInfo, rnibErr)
- testContext.writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(tc.saveNodebMockError)
+ testContext.writerMock.On("SaveNodeb", mock.Anything).Return(tc.saveNodebMockError)
handler.Handle(¬ificationRequest)
return testContext, nodebInfo
testContext, nodebInfo := executeHandleSetupSuccessResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
assert.EqualValues(t, entities.ConnectionStatus_CONNECTED, nodebInfo.ConnectionStatus)
- assert.EqualValues(t, 0, nodebInfo.ConnectionAttempts)
assert.EqualValues(t, entities.Node_ENB, nodebInfo.NodeType)
assert.IsType(t, &entities.NodebInfo_Enb{}, nodebInfo.Configuration)
testContext, nodebInfo := executeHandleSetupFailureResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
assert.EqualValues(t, entities.ConnectionStatus_CONNECTED_SETUP_FAILED, nodebInfo.ConnectionStatus)
- assert.EqualValues(t, 0, nodebInfo.ConnectionAttempts)
assert.EqualValues(t, entities.Failure_X2_SETUP_FAILURE, nodebInfo.FailureType)
assert.NotNil(t, nodebInfo.SetupFailure)
testContext.rmrMessengerMock.AssertNotCalled(t, "SendMsg")
testContext, nodebInfo := executeHandleSetupSuccessResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
assert.EqualValues(t, entities.ConnectionStatus_CONNECTED, nodebInfo.ConnectionStatus)
- assert.EqualValues(t, 0, nodebInfo.ConnectionAttempts)
assert.EqualValues(t, entities.Node_GNB, nodebInfo.NodeType)
assert.IsType(t, &entities.NodebInfo_Gnb{}, nodebInfo.Configuration)
testContext, nodebInfo := executeHandleSetupFailureResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
assert.EqualValues(t, entities.ConnectionStatus_CONNECTED_SETUP_FAILED, nodebInfo.ConnectionStatus)
- assert.EqualValues(t, 0, nodebInfo.ConnectionAttempts)
assert.EqualValues(t, entities.Failure_ENDC_X2_SETUP_FAILURE, nodebInfo.FailureType)
assert.NotNil(t, nodebInfo.SetupFailure)
testContext.rmrMessengerMock.AssertNotCalled(t, "SendMsg")
testContext := NewSetupResponseTestContext(nil)
handler := NewSetupResponseNotificationHandler(testContext.logger, testContext.rnibDataService, managers.NewX2SetupResponseManager(converters.NewX2SetupResponseConverter(logger)), testContext.ranStatusChangeManager, rmrCgo.RIC_X2_SETUP_RESP)
var rnibErr error
- testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, ConnectionAttempts: 1}, rnibErr)
+ testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING}, rnibErr)
handler.Handle(¬ificationRequest)
testContext.readerMock.AssertCalled(t, "GetNodeb", ranName)
testContext.writerMock.AssertNotCalled(t, "SaveNodeb")
testContext, nodebInfo := executeHandleSetupSuccessResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
testContext.rmrMessengerMock.AssertNotCalled(t, "SendMsg")
}
testContext, nodebInfo := executeHandleSetupSuccessResponse(t, tc)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
- testContext.writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ testContext.writerMock.AssertCalled(t, "SaveNodeb", nodebInfo)
assert.EqualValues(t, entities.ConnectionStatus_CONNECTED, nodebInfo.ConnectionStatus)
- assert.EqualValues(t, 0, nodebInfo.ConnectionAttempts)
assert.EqualValues(t, entities.Node_ENB, nodebInfo.NodeType)
assert.IsType(t, &entities.NodebInfo_Enb{}, nodebInfo.Configuration)