Unittest stability improvements
[ric-plt/submgr.git] / pkg / control / ut_messaging_test.go
index 20f8709..dff639e 100644 (file)
 package control
 
 import (
+       "strings"
        "testing"
        "time"
 
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
        "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "github.com/stretchr/testify/assert"
 )
 
+func TestSuiteSetup(t *testing.T) {
+       // The effect of this call shall endure thgough the UT suite!
+       // If this causes any issues, the previout interface can be restored
+       // like this:git log
+       // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
+
+       SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
+
+       restDuplicateCtrl.Init()
+
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
+
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndE1apDeleteReqPackingError
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
+
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndE1apDeleteRespUnpackingError
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             | // The order of these events may vary
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             | // 1.st NOK
+//     |                 |              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             | // 2.nd NOK
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
+
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+}
+
 //-----------------------------------------------------------------------------
 // TestSubReqAndRouteNok
 //
@@ -2234,25 +2405,23 @@ func TestRESTSubReqAndRouteNok(t *testing.T) {
        CaseBegin("TestRESTSubReqAndRouteNok")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cRouteCreateFail, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
        // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
        waiter := rtmgrHttp.AllocNextSleep(50, false)
        newSubsId := mainCtrl.get_registry_next_subid(t)
 
        // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
-       xappConn1.ExpectRESTNotification(t, restSubId)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
        waiter.WaitResult(t)
 
        e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
@@ -2272,15 +2441,17 @@ func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
 
        //Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 2},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
                Counter{cRouteCreateUpdateFail, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        var params *teststube2ap.RESTSubsReqParams = nil
@@ -2293,11 +2464,11 @@ func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
        // xapp2 ROUTE creation shall fail with  400 from rtmgr -> submgr
        waiter := rtmgrHttp.AllocNextEvent(false)
        newSubsId := mainCtrl.get_registry_next_subid(t)
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
-       xappConn2.ExpectRESTNotification(t, restSubId2)
+       xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
        waiter.WaitResult(t)
        // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
        xappConn2.WaitRESTNotification(t, restSubId2)
@@ -2318,15 +2489,16 @@ func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cRouteDeleteFail, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        var params *teststube2ap.RESTSubsReqParams = nil
@@ -2351,15 +2523,16 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
        CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cRouteDeleteUpdateFail, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        var params *teststube2ap.RESTSubsReqParams = nil
@@ -2406,19 +2579,13 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
 //     | RESTSubReq2     |              |
 //     | (retrans)       |              |
 //     |---------------->|              |
-//     |                 |              |
-//     |                 | SubReq2      |
-//     |                 |------------->|
-//     |    RESTSubResp2 |              |
+//     | RESTSubResp(201)|              |
 //     |<----------------|              |
+//     |                 |              |
 //     |                 |     SubResp1 |
 //     |                 |<-------------|
 //     |      RESTNotif1 |              |
 //     |<----------------|              |
-//     |                 |     SubResp1 |
-//     |                 |<-------------|
-//     |      RESTNotif2 |              |
-//     |<----------------|              |
 //     |                 |              |
 //     |            [SUBS DELETE]       |
 //     |                 |              |
@@ -2429,284 +2596,820 @@ func TestRESTSubReqRetransmission(t *testing.T) {
        CaseBegin("TestRESTSubReqRetransmission")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
-               Counter{cSubReqToE2, 2},
-               Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
-               Counter{cSubDelReqToE2, 2},
-               Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
-       // Retry/duplicate will get the same way as the first request.  Submgr cannot detect duplicate RESTRequests
+       // Retry/duplicate will get the same way as the first request.
        // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
        // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
 
        // Subs Create
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
        // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
        // gets into execution before the rtmgrg responds for the first one.
        waiter := rtmgrHttp.AllocNextSleep(10, true)
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
-       restSubId2 := xappConn2.SendRESTSubsReq(t, params)
+       xappConn2.SendRESTSubsReq(t, params)
 
        waiter.WaitResult(t)
 
-       xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
+       xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
 
        // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
        // the order is not significant he6re.
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
        e2termConn1.SendSubsResp(t, crereq, cremsg)
-       crereq, cremsg = e2termConn1.RecvSubsReq(t)
-       e2termConn1.SendSubsResp(t, crereq, cremsg)
 
        e2SubsIdA := <-xappConn1.ListedRESTNotifications
        xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
-       e2SubsIdB := <-xappConn1.ListedRESTNotifications
-       xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
 
        // Del1
        xappConn1.SendRESTSubsDelReq(t, &restSubId1)
        delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
        e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 
-       // Del2
-       xappConn2.SendRESTSubsDelReq(t, &restSubId2)
-       delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
-       e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
-
-       mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
-
-       waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
+       mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
 
        mainCtrl.VerifyCounterValues(t)
 }
 
-func TestRESTSubDelReqRetransmission(t *testing.T) {
-       CaseBegin("TestRESTSubDelReqRetransmission")
+//-----------------------------------------------------------------------------
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS1]      |              |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS2]      |              |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmissionV2(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetransmissionV2")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 3},
+               Counter{cRestSubRespToXapp, 3},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 3},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
-       var params *teststube2ap.RESTSubsReqParams = nil
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
 
-       //Subs Create
        restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
 
        queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
 
-       //Subs Delete
-       xappConn1.SendRESTSubsDelReq(t, &restSubId)
-       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       //1.st resend
+       restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
 
-       seqBef := mainCtrl.get_msgcounter(t)
-       xappConn1.SendRESTSubsDelReq(t, &restSubId)
-       mainCtrl.wait_msgcounter_change(t, seqBef, 10)
+       assert.Equal(t, restSubId_resend, restSubId)
 
-       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+       <-time.After(100 * time.Millisecond)
+
+       //2.nd resend
+       restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+
+       assert.Equal(t, restSubId_resend2, restSubId)
+
+       <-time.After(100 * time.Millisecond)
+
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
 
        waitSubsCleanup(t, e2SubsId, 10)
 
+       //Wait that subs is cleaned
        mainCtrl.VerifyCounterValues(t)
 }
 
 //-----------------------------------------------------------------------------
-// TestRESTSubReqDelReq
-//
-//   stub                             stub
-// +-------+        +---------+    +---------+
-// | xapp  |        | submgr  |    | e2term  |
-// +-------+        +---------+    +---------+
-//     |                 |              |
-//     | RESTSubReq      |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |     RESTSubResp |              |
-//     |<----------------|              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     | RESTSubDelReq   |              |
-//     |---------------->|              |
-//     |  RESTSubDelResp |              |
-//     |     unsuccess   |              |
-//     |<----------------|              |
-//     |                 |      SubResp |
-//     |                 |<-------------|
-//     |      RESTNotif1 |              |
-//     |<----------------|              |
-//     |                 |              |
-//     |            [SUBS DELETE]       |
-//     |                 |              |
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS, with RESTsubsId]     |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS, without RESTsubsId]  |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
 //
 //-----------------------------------------------------------------------------
-func TestRESTSubReqDelReq(t *testing.T) {
-       CaseBegin("TestRESTSubReqDelReq")
+func TestRESTSubReqRetransmissionV3(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetransmissionV3")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 3},
+               Counter{cRestSubRespToXapp, 3},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 3},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
-       const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
 
-       // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
-       restSubId := xappConn1.SendRESTSubsReq(t, params)
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
 
-       // Del. This will fail as processing of the subscription
-       // is still ongoing in submgr. Deletion is not allowed before
-       // subscription creation has been completed.
-       xappConn1.SendRESTSubsDelReq(t, &restSubId)
-       crereq, cremsg := e2termConn1.RecvSubsReq(t)
-       xappConn1.ExpectRESTNotification(t, restSubId)
-       e2termConn1.SendSubsResp(t, crereq, cremsg)
-       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+       queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
 
-       // Retry del
-       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       <-time.After(100 * time.Millisecond)
 
-       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
-       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+       //1.st resend with subscription ID
+       params.SetSubscriptionID(&restSubId)
+       restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
+
+       assert.Equal(t, restSubId_resend, restSubId)
+
+       <-time.After(100 * time.Millisecond)
+
+       //2.nd resend without subscription ID (faking app restart)
+       params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+
+       assert.Equal(t, restSubId_resend2, restSubId)
+
+       <-time.After(100 * time.Millisecond)
+
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
 
-       // Wait that subs is cleaned
        waitSubsCleanup(t, e2SubsId, 10)
-       mainCtrl.VerifyCounterValues(t)
 
+       //Wait that subs is cleaned
+       mainCtrl.VerifyCounterValues(t)
 }
 
-func TestRESTSubDelReqCollision(t *testing.T) {
-       CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
-}
+//-----------------------------------------------------------------------------
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [with RestSUbsId + one additional e2 subDetail]
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     | [for initial e2 subDetail]     |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [with RESTsubsId initial request]            |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
 
-func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
-       CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
+func TestRESTSubReqRetransmissionV4(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetransmissionV4")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 3},
+               Counter{cRestSubRespToXapp, 3},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 4},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
-       //Req1
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
-       restSubId1 := xappConn1.SendRESTSubsReq(t, params)
-       xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
 
-       //Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
-       restSubId2 := xappConn2.SendRESTSubsReq(t, params)
-       xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
 
-       crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
-       crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+       <-time.After(100 * time.Millisecond)
 
-       //XappConn1 receives both of the  responses
-       xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
+       // Send modified  requst, this time with e2 subscriptions.
+       params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+       params2.SetSubscriptionID(&restSubId)
 
-       //Resp1
-       e2termConn1.SendSubsResp(t, crereq1, cremsg1)
-       //Resp2
+       xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+       xappConn1.ExpectAnyNotification(t)
+       // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+       restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
+       e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+       assert.Equal(t, e2SubsId, e2SubsId1)
+
+       crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+
+       xappConn1.DecrementRequestCount()
+       xappConn1.ExpectRESTNotification(t, restSubId_resend)
        e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+       e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+       assert.NotEqual(t, e2SubsId2, 0)
 
-       e2SubsIdA := <-xappConn1.ListedRESTNotifications
-       xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
-       e2SubsIdB := <-xappConn1.ListedRESTNotifications
-       xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+       <-time.After(100 * time.Millisecond)
 
-       //Del1
-       deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
-       //Del2
-       deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
+       xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+       params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       params.SetSubscriptionID(&restSubId)
+       xappConn1.ExpectAnyNotification(t)
+       // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
+       restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+       assert.Equal(t, restSubId_resend, restSubId_resend2)
 
-       //Wait that subs is cleaned
-       mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
-       waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
+       e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
+       assert.Equal(t, e2SubsId, e2SubsId1)
 
-       mainCtrl.VerifyCounterValues(t)
+       // Delete both e2 subscriptions
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+       sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+       waitSubsCleanup(t, e2SubsId, 10)
 
+       //Wait that subs is cleaned
+       mainCtrl.VerifyCounterValues(t)
 }
 
-func TestRESTSameSubsDiffRan(t *testing.T) {
-       CaseBegin("TestRESTSameSubsDiffRan")
+//-----------------------------------------------------------------------------
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [with RestSUbsId + one additional e2 subDetail]
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     | [for initial e2 subDetail]     |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [without RESTsubsId initial request]         |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmissionV5(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetransmissionV5")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 3},
+               Counter{cRestSubRespToXapp, 3},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 4},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
-       restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
-       xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
 
-       params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
-       params.SetMeid("RAN_NAME_2")
-       restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
-       xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
 
-       //Del1
-       deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
-       //Del2
-       deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
+       <-time.After(100 * time.Millisecond)
 
-       //Wait that subs is cleaned
-       mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
-       waitSubsCleanup(t, e2SubsId2, 10)
+       // Send modified  requst, this time with e2 subscriptions.
+       params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+       params2.SetSubscriptionID(&restSubId)
 
-       mainCtrl.VerifyCounterValues(t)
+       xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+       xappConn1.ExpectAnyNotification(t)
+       // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+       restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
 
-}
+       e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+       assert.Equal(t, e2SubsId, e2SubsId1)
+       // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
+       xappConn1.DecrementRequestCount()
 
-func TestRESTSubReqRetryInSubmgr(t *testing.T) {
-       CaseBegin("TestRESTSubReqRetryInSubmgr start")
+       crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
 
-       // Init counter check
-       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+       xappConn1.ExpectRESTNotification(t, restSubId_resend)
+       e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+       e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+       assert.NotEqual(t, e2SubsId2, 0)
+
+       <-time.After(100 * time.Millisecond)
+
+       xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+       params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       xappConn1.ExpectAnyNotification(t)
+       // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
+       // md5sum shall find the original request
+       restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+       assert.Equal(t, restSubId_resend, restSubId_resend2)
+
+       e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
+       assert.Equal(t, e2SubsId, e2SubsId1)
+
+       // Delete both e2 subscriptions
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+       sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+
+       //Wait that subs is cleaned
+       mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [with RestSUbsId + one additional e2 subDetail]
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     | [for initial e2 subDetail]     |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     | RESTSubReq      |              |             |
+//     | [with RESTsubsId initial request]            |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqRetransmissionV6(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetransmissionV6")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 3},
+               Counter{cRestSubRespToXapp, 3},
+               Counter{cSubReqToE2, 3},
+               Counter{cSubRespFromE2, 3},
+               Counter{cRestSubNotifToXapp, 4},
+               Counter{cRestSubDelReqFromXapp, 2},
+               Counter{cSubDelReqToE2, 3},
+               Counter{cSubDelRespFromE2, 3},
+               Counter{cRestSubDelRespToXapp, 2},
+       })
+
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       <-time.After(100 * time.Millisecond)
+
+       // Send modified  requst, this time with e2 subscriptions.
+       params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+       params2.SetSubscriptionID(&restSubId)
+
+       xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+       xappConn1.ExpectAnyNotification(t)
+       // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+       restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
+
+       e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+       assert.Equal(t, e2SubsId, e2SubsId1)
+
+       crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotification(t, restSubId_resend)
+       e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+       e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+       assert.NotEqual(t, e2SubsId2, 0)
+
+       <-time.After(100 * time.Millisecond)
+
+       // Delete both e2 subscriptions
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+       sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+
+       // Resend the original request, we shall find it's previous md5sum/restsubs
+       // but the restsubscription has been already removed. This shall trigger a
+       // fresh create.
+       restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
+
+       <-time.After(100 * time.Millisecond)
+
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+
+       //Wait that subs is cleaned
+       mainCtrl.VerifyCounterValues(t)
+}
+
+func TestRESTSubDelReqRetransmission(t *testing.T) {
+       CaseBegin("TestRESTSubDelReqRetransmission")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 2},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       var params *teststube2ap.RESTSubsReqParams = nil
+
+       //Subs Create
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+
+       //Subs Delete
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       seqBef := mainCtrl.get_msgcounter(t)
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       mainCtrl.wait_msgcounter_change(t, seqBef, 10)
+
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+
+       mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqDelReq
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |  RESTSubDelResp |              |
+//     |     unsuccess   |              |
+//     |<----------------|              |
+//     |                 |      SubResp |
+//     |                 |<-------------|
+//     |      RESTNotif1 |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |            [SUBS DELETE]       |
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqDelReq(t *testing.T) {
+       CaseBegin("TestRESTSubReqDelReq")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 2},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       const subReqCount int = 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       // Del. This will fail as processing of the subscription
+       // is still ongoing in submgr. Deletion is not allowed before
+       // subscription creation has been completed.
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       // Retry del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+
+}
+
+func TestRESTSubDelReqCollision(t *testing.T) {
+       CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
+}
+
+func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
+       CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
+               Counter{cSubReqToE2, 2},
+               Counter{cSubRespFromE2, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
+               Counter{cSubDelReqToE2, 2},
+               Counter{cSubDelRespFromE2, 2},
+               Counter{cRestSubDelRespToXapp, 2},
+       })
+
+       //Req1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId1 := xappConn1.SendRESTSubsReq(t, params)
+       xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+
+       //Req2
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
+       restSubId2 := xappConn2.SendRESTSubsReq(t, params)
+       xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+
+       crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+       crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+
+       //XappConn1 receives both of the  responses
+       xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
+
+       //Resp1
+       e2termConn1.SendSubsResp(t, crereq1, cremsg1)
+       //Resp2
+       e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+
+       e2SubsIdA := <-xappConn1.ListedRESTNotifications
+       xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+       e2SubsIdB := <-xappConn1.ListedRESTNotifications
+       xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+
+       //Del1
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
+       //Del2
+       deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
+
+       //Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
+       waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
+
+       mainCtrl.VerifyCounterValues(t)
+
+}
+
+func TestRESTSameSubsDiffRan(t *testing.T) {
+       CaseBegin("TestRESTSameSubsDiffRan")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
+               Counter{cSubReqToE2, 2},
+               Counter{cSubRespFromE2, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
+               Counter{cSubDelReqToE2, 2},
+               Counter{cSubDelRespFromE2, 2},
+               Counter{cRestSubDelRespToXapp, 2},
+       })
+
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
+       xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+
+       params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       params.SetMeid("RAN_NAME_2")
+       restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
+       xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+
+       //Del1
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
+       //Del2
+       deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
+
+       //Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
+       waitSubsCleanup(t, e2SubsId2, 10)
+
+       mainCtrl.VerifyCounterValues(t)
+
+}
+
+func TestRESTSubReqRetryInSubmgr(t *testing.T) {
+       CaseBegin("TestRESTSubReqRetryInSubmgr start")
+
+       // Init counter check
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubReReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
 
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
@@ -2771,12 +3474,14 @@ func TestRESTSubReqRetryInSubmgr(t *testing.T) {
 //     |                 |              |
 //
 //-----------------------------------------------------------------------------
+
 func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
        CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubReReqToE2, 1},
                Counter{cSubReqTimerExpiry, 2},
@@ -2784,7 +3489,7 @@ func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
                Counter{cSubDelRespFromE2, 1},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
 
@@ -2795,9 +3500,8 @@ func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
        xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
 
        delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
-       xappConn1.ExpectRESTNotification(t, restSubId)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
        e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-       // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)     - TODO:  Should we delete this?
        xappConn1.WaitRESTNotification(t, restSubId)
 
        // Wait that subs is cleaned
@@ -2811,7 +3515,8 @@ func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubReReqToE2, 1},
                Counter{cSubReqTimerExpiry, 2},
@@ -2819,7 +3524,7 @@ func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
                Counter{cSubDelReqTimerExpiry, 2},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
 
@@ -2832,7 +3537,7 @@ func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
        e2termConn1.RecvSubsDelReq(t)
        xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
 
-       xappConn1.ExpectRESTNotification(t, restSubId)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
        e2termConn1.RecvSubsDelReq(t)
        xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
 
@@ -2887,7 +3592,8 @@ func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubReReqToE2, 1},
                Counter{cSubReqTimerExpiry, 2},
@@ -2896,7 +3602,7 @@ func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
                Counter{cSubDelReqTimerExpiry, 2},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
 
@@ -2909,7 +3615,7 @@ func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
        e2termConn1.RecvSubsDelReq(t)
        xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
 
-       xappConn1.ExpectRESTNotification(t, restSubId)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
        e2termConn1.RecvSubsDelReq(t)
        xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
 
@@ -2957,19 +3663,17 @@ func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
        CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubFailFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
 
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
@@ -2978,7 +3682,7 @@ func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
        e2termConn1.SendSubsFail(t, fparams1, cremsg1)
 
        delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
-       xappConn1.ExpectRESTNotification(t, restSubId)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
        e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
        e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
        xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
@@ -3024,15 +3728,16 @@ func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
        CaseBegin("TestRESTSubDelReqRetryInSubmgr")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelReReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
        // Req
        var params *teststube2ap.RESTSubsReqParams = nil
@@ -3083,15 +3788,16 @@ func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
        CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelReReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
@@ -3142,14 +3848,15 @@ func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
        CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelFailFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
@@ -3223,16 +3930,17 @@ func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
                Counter{cMergedSubscriptions, 1},
                Counter{cUnmergedSubscriptions, 1},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -3243,16 +3951,16 @@ func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
 
        xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
-       xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
+       xappConn2.ExpectAnyNotification(t)
        waiter := rtmgrHttp.AllocNextSleep(10, true)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
        waiter.WaitResult(t)
        xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
-       e2SubsId2 := <-xappConn2.RESTNotification
+       e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
        xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
 
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
@@ -3320,21 +4028,22 @@ func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
-       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
 
        xappConn1.ExpectRESTNotification(t, restSubId1)
@@ -3417,28 +4126,26 @@ func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubFailNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
        // Req1
-       params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
        crereq1, _ := e2termConn1.RecvSubsReq(t)
 
        // Req2
        subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
-       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params2.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
        mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
@@ -3523,29 +4230,27 @@ func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
                Counter{cSubFailFromE2, 1},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubFailNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
        // Req1
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
        // Req2
        subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
-       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params2.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
        mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
@@ -3583,22 +4288,20 @@ func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
 
@@ -3670,30 +4373,28 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
        CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const policyParamCount int = 1
 
        // Req
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
 
        // Policy change
-       instanceId := int64(e2SubsId)
        // GetRESTSubsReqPolicyParams sets some coutners on tc side.
-       params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
-       params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
+
+       params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       params.SetSubscriptionID(&restSubId)
        params.SetTimeToWait("w200ms")
        restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
 
@@ -3708,6 +4409,90 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
        mainCtrl.VerifyCounterValues(t)
 }
 
+//-----------------------------------------------------------------------------
+// TestRESTSubReqPolicyChangeNOk
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubResp |
+//     |                 |<-------------|
+//     |                 |              |
+//     |       RESTNotif |              |
+//     |<----------------|              |
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |         RESTSubUpdateFail      |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
+       CaseBegin("TestRESTSubReqPolicyChangeNOk")
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubFailToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       const subReqCount int = 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Policy change
+
+       params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+
+       restSubIdUpd := strings.ToUpper(restSubId)
+       params.SetSubscriptionID(&restSubIdUpd)
+       params.SetTimeToWait("w200ms")
+
+       restSubId2 := xappConn1.SendRESTSubsReq(t, params)
+       assert.Equal(t, restSubId2, "")
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+}
+
 //-----------------------------------------------------------------------------
 // TestRESTSubReqAndSubDelOkTwoE2termParallel
 //
@@ -3754,28 +4539,26 @@ func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
 
        // Init counter check
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
        // Req1
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_11")
        // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
        // would not work as notification would not be received
@@ -3882,22 +4665,20 @@ func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
        CaseBegin("TestRESTInsertSubReqAndSubDelOk")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        const subReqCount int = 1
-       const parameterSet int = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        params.SetSubActionTypes("insert")
 
        // Req
@@ -3946,7 +4727,8 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
        CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
@@ -3954,14 +4736,11 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
        })
 
        const subReqCount int = 1
-       const parameterSet = 1
-       const actionDefinitionPresent bool = true
-       const actionParamCount int = 1
 
        // Remove possible existing subscription
        mainCtrl.removeExistingSubscriptions(t)
 
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
 
        //Req
        mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
@@ -4025,17 +4804,19 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
 //     |<----------------|              |
 //
 //-----------------------------------------------------------------------------
+
 func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 1},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 1},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Remove possible existing subscription
@@ -4123,20 +4904,22 @@ func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
 //     |             |                 |              |
 //
 //-----------------------------------------------------------------------------
+
 func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
        CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 1},
                Counter{cSubRespFromE2, 1},
-               Counter{cSubRespToXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
                Counter{cMergedSubscriptions, 1},
                Counter{cUnmergedSubscriptions, 1},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 1},
                Counter{cSubDelRespFromE2, 1},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Remove possible existing subscription
@@ -4149,13 +4932,13 @@ func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
        xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
 
        // Create subscription 2 with same action
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
-       xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
+       xappConn2.ExpectAnyNotification(t)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
-       e2SubsId2 := <-xappConn2.RESTNotification
+       e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
        xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
 
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
@@ -4233,21 +5016,19 @@ func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
 //     |<----------------|              |
 //
 //-----------------------------------------------------------------------------
+
 func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
        CaseBegin("TestRESTReportSubReqAndSubDelOk")
        subReqCount := 1
-       parameterSet := 1 // E2SM-gNB-X2
-       actionDefinitionPresent := true
-       actionParamCount := 1
        testIndex := 1
-       RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
+       RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
 }
 
-func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
-       xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
+func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
+       xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
 
        // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
 
        var e2SubsId []uint32
@@ -4289,25 +5070,21 @@ func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
        CaseBegin("TestRESTPolicySubReqAndSubDelOk")
 
        subReqCount := 2
-       actionDefinitionPresent := true
-       policyParamCount := 1
        testIndex := 1
-       RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
+       RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
 
        subReqCount = 19
-       actionDefinitionPresent = false
-       policyParamCount = 0
        testIndex = 2
-       RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
+       RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
 }
 */
-func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
-       xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
+func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
+       xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
 
        // Req
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
-       //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
+       //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
        //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
 
        var e2SubsId []uint32
@@ -4342,18 +5119,19 @@ func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
        subReqCount := 2
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
 
@@ -4374,18 +5152,19 @@ func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
        subReqCount := 19
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 19},
                Counter{cSubRespFromE2, 19},
-               Counter{cSubRespToXapp, 19},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, 19},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, 19},
                Counter{cSubDelRespFromE2, 19},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
 
@@ -4403,23 +5182,21 @@ func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
 func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
 
        subReqCount := 2
-       parameterSet := 1
-       actionDefinitionPresent := true
-       actionParamCount := 1
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, uint64(subReqCount)},
                Counter{cSubRespFromE2, uint64(subReqCount)},
-               Counter{cSubRespToXapp, uint64(subReqCount)},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, uint64(subReqCount)},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, uint64(subReqCount)},
                Counter{cSubDelRespFromE2, uint64(subReqCount)},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
 
@@ -4439,23 +5216,21 @@ func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
 func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
 
        subReqCount := 2
-       parameterSet := 1
-       actionDefinitionPresent := false
-       actionParamCount := 0
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, uint64(subReqCount)},
                Counter{cSubRespFromE2, uint64(subReqCount)},
-               Counter{cSubRespToXapp, uint64(subReqCount)},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, uint64(subReqCount)},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, uint64(subReqCount)},
                Counter{cSubDelRespFromE2, uint64(subReqCount)},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
 
@@ -4475,23 +5250,21 @@ func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
 func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
 
        subReqCount := 19
-       parameterSet := 1
-       actionDefinitionPresent := false
-       actionParamCount := 0
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 1},
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, uint64(subReqCount)},
                Counter{cSubRespFromE2, uint64(subReqCount)},
-               Counter{cSubRespToXapp, uint64(subReqCount)},
-               Counter{cSubDelReqFromXapp, 1},
+               Counter{cRestSubNotifToXapp, uint64(subReqCount)},
+               Counter{cRestSubDelReqFromXapp, 1},
                Counter{cSubDelReqToE2, uint64(subReqCount)},
                Counter{cSubDelRespFromE2, uint64(subReqCount)},
-               Counter{cSubDelRespToXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
 
@@ -4512,14 +5285,15 @@ func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4532,9 +5306,9 @@ func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
-       eventTriggerDefinition := "1234"
+       eventTriggerDefinition := []int64{1234, 1}
        params.SetSubEventTriggerDefinition(eventTriggerDefinition)
 
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4558,14 +5332,15 @@ func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4578,12 +5353,12 @@ func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
 
        actionId := int64(1)
        actionType := "report"
-       actionDefinition := "56781"
+       actionDefinition := []int64{5678, 1}
        subsequestActionType := "continue"
        timeToWait := "w10ms"
        params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
@@ -4609,14 +5384,15 @@ func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4629,7 +5405,7 @@ func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        params.SetSubActionIDs(int64(2))
 
@@ -4654,18 +5430,19 @@ func TestRESTSubReqDiffActionType(t *testing.T) {
        CaseBegin("TestRESTSubReqDiffActionType")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
 
        //Subs Create
        restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
@@ -4674,7 +5451,7 @@ func TestRESTSubReqDiffActionType(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
 
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4698,18 +5475,19 @@ func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
        CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
 
        //Subs Create
        restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
@@ -4718,7 +5496,7 @@ func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
 
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4742,14 +5520,15 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4762,9 +5541,9 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
-       actionDefinition := "5678"
+       actionDefinition := []int64{5678, 1}
        params.SetSubActionDefinition(actionDefinition)
 
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4788,14 +5567,15 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4808,9 +5588,9 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
-       actionDefinition := "56782"
+       actionDefinition := []int64{56782}
        params.SetSubActionDefinition(actionDefinition)
 
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4834,14 +5614,15 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
        CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
-               Counter{cSubReqFromXapp, 2},
+               Counter{cRestSubReqFromXapp, 2},
+               Counter{cRestSubRespToXapp, 2},
                Counter{cSubReqToE2, 2},
                Counter{cSubRespFromE2, 2},
-               Counter{cSubRespToXapp, 2},
-               Counter{cSubDelReqFromXapp, 2},
+               Counter{cRestSubNotifToXapp, 2},
+               Counter{cRestSubDelReqFromXapp, 2},
                Counter{cSubDelReqToE2, 2},
                Counter{cSubDelRespFromE2, 2},
-               Counter{cSubDelRespToXapp, 2},
+               Counter{cRestSubDelRespToXapp, 2},
        })
 
        // Req1
@@ -4854,7 +5635,7 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
 
        // Req2
-       params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        params.SetTimeToWait("w200ms")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@ -4874,19 +5655,896 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
 
 }
 
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionResponseDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubResp | ASN.1 decode fails
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionResponseUnknownInstanceId
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubResp | Unknown instanceId
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+
+       // Unknown instanceId in this response which will result resending original request
+       orgInstanceId := crereq.RequestId.InstanceId
+       crereq.RequestId.InstanceId = 0
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionResponseNoTransaction
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubResp | No transaction for the response
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+
+       mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
+       // No transaction exist for this response which will result resending original request
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Resending happens because there no transaction
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionFailureDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | ASN.1 decode fails
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionResponseUnknownInstanceId
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Unknown instanceId
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+
+       // Unknown instanceId in this response which will result resending original request
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       fparams.Fail.RequestId.InstanceId = 0
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionFailureNoTransaction
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | No transaction for the response
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
+       subReqCount := 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+
+       mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
+
+       // No transaction exist for this response which will result resending original request
+       fparams := &teststube2ap.E2StubSubsFailParams{}
+       fparams.Set(crereq)
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       _, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription already created in E2 Node.
+       fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
+       e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Resending happens because there no transaction
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp | ASN.1 decode fails
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
+
+       // E2t: Receive 2nd SubsDelReq and send SubsDelResp
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp | Unknown instanceId
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       // Unknown instanceId in this response which will result resending original request
+       delreq.RequestId.InstanceId = 0
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // E2t: Receive 2nd SubsDelReq
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp | No transaction for the response
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       mainCtrl.MakeTransactionNil(t, e2SubsId)
+
+       // No transaction exist for this response which will result resending original request
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // E2t: Receive 2nd SubsDelReq
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | ASN.1 decode fails
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
+
+       // E2t: Receive 2nd SubsDelReq and send SubsDelResp
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Unknown instanceId
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       // Unknown instanceId in this response which will result resending original request
+       delreq.RequestId.InstanceId = 0
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // E2t: Receive 2nd SubsDelReq
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | No transaction for the response
+//     |                 |<-------------|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelFail | Subscription does exist any more
+//     |                 |<-------------|
+//
+//-----------------------------------------------------------------------------
+func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
+       xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
+
+       // Req
+       var params *teststube2ap.RESTSubsReqParams = nil
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // E2t: Receive 1st SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+       mainCtrl.MakeTransactionNil(t, e2SubsId)
+
+       // No transaction exist for this response which will result resending original request
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // E2t: Receive 2nd SubsDelReq
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqFailAsn1PackSubReqError
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |        ASN.1 encode fails      |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |  SubDelFail  |
+//     |                 |<-------------|
+//     |                 |              |
+//     |       RESTNotif |              |
+//     |       unsuccess |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |            [SUBS DELETE]       |
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelFailFromE2, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+       })
+
+       subReqCount := 1
+
+       var params *teststube2ap.RESTSubsReqParams = nil
+       params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
+
+       // Req
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+       xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
+
+       // E2t: Receive SubsDelReq
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       // Subscription does not exist in in E2 Node.
+       e2termConn1.SendSubsDelFail(t, delreq, delmsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+       xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
+
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
+       // Wait that subs is cleaned
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+}
+
 ////////////////////////////////////////////////////////////////////////////////////
 //   Services for UT cases
 ////////////////////////////////////////////////////////////////////////////////////
 const subReqCount int = 1
-const parameterSet = 1
-const actionDefinitionPresent bool = true
-const actionParamCount int = 1
-const policyParamCount int = 1
 const host string = "localhost"
 
 func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
        if params == nil {
-               params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+               params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
        }
        restSubId := fromXappConn.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
@@ -4902,7 +6560,7 @@ func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2ter
 
 func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
 
-       params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        if meid != "" {
                params.SetMeid(meid)
        }
@@ -4917,7 +6575,7 @@ func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
 }
 
 func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
-       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
 
@@ -4931,7 +6589,7 @@ func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
 }
 
 func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
-       params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
 
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)