+ return log
+}
+
+func TestX2ResetHandleSuccessfulRequestedCause(t *testing.T) {
+ controller, readerMock, _, rmrMessengerMock, _ := setupControllerTest(t)
+
+ ranName := "test1"
+ payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x40}
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
+
+ writer := httptest.NewRecorder()
+
+ var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
+ readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
+
+ data4Req := map[string]interface{}{"cause": "protocol:transfer-syntax-error"}
+ b := new(bytes.Buffer)
+ _ = json.NewEncoder(b).Encode(data4Req)
+ req, _ := http.NewRequest("PUT", "https://localhost:3800/nodeb-reset", b)
+ req = mux.SetURLVars(req, map[string]string{"ranName": ranName})
+
+ controller.X2Reset(writer, req)
+ assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
+
+}
+
+func TestX2ResetHandleSuccessfulRequestedDefault(t *testing.T) {
+ controller, readerMock, _, rmrMessengerMock, _ := setupControllerTest(t)
+
+ ranName := "test1"
+ // o&m intervention
+ payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x64}
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("SendMsg", msg, true).Return(msg, nil)
+
+ writer := httptest.NewRecorder()
+
+ var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
+ readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
+
+ // no body
+ b := new(bytes.Buffer)
+ data4Req := map[string]interface{}{}
+ _ = json.NewEncoder(b).Encode(data4Req)
+ req, _ := http.NewRequest("PUT", "https://localhost:3800/nodeb-reset", b)
+ req = mux.SetURLVars(req, map[string]string{"ranName": ranName})
+
+ controller.X2Reset(writer, req)
+ assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
+}
+
+func TestX2ResetHandleFailureInvalidBody(t *testing.T) {
+ controller, _, _, _, _ := setupControllerTest(t)
+
+ ranName := "test1"
+
+ writer := httptest.NewRecorder()