Commit 22376542 authored by Simon Pastor's avatar Simon Pastor
Browse files

rnis first merge

parent ba128342
Loading
Loading
Loading
Loading
+3888 −4128

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ require (
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-cache v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-http-logger v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metric-store v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis v0.0.0
+34 −0
Original line number Diff line number Diff line
/*
 * AdvantEDGE Radio Network Information Service REST API
 *
 * Radio Network Information Service is AdvantEDGE's implementation of [ETSI MEC ISG MEC012 RNI API](http://www.etsi.org/deliver/etsi_gs/MEC/001_099/012/02.01.01_60/gs_MEC012v020101p.pdf) <p>[Copyright (c) ETSI 2017](https://forge.etsi.org/etsi-forge-copyright-notice.txt) <p>**Micro-service**<br>[meep-rnis](https://github.com/InterDigitalInc/AdvantEDGE/tree/master/go-apps/meep-rnis) <p>**Type & Usage**<br>Edge Service used by edge applications that want to get information about radio conditions in the network <p>**Details**<br>API details available at _your-AdvantEDGE-ip-address/api_
 *
 * API version: 2.1.1
 * Contact: AdvantEDGE@InterDigital.com
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */
package server

type AllOfbodyNotificationSubscription struct {
	Links *CaReconfSubscriptionLinks `json:"_links,omitempty"`
	// URI selected by the service consumer, to receive notifications on the subscribed RNIS information. This shall be included in the request and response.
	CallbackReference string `json:"callbackReference"`

	ExpiryDeadline *TimeStamp `json:"expiryDeadline,omitempty"`

	FilterCriteriaQci *RabModSubscriptionFilterCriteriaQci `json:"filterCriteriaQci"`
	// Shall be set to \"S1BearerSubscription\".
	SubscriptionType string `json:"subscriptionType"`

	FilterCriteriaAssocTri *MeasRepUeSubscriptionFilterCriteriaAssocTri `json:"filterCriteriaAssocTri"`

	FilterCriteriaNrMrs *NrMeasRepUeSubscriptionFilterCriteriaNrMrs `json:"filterCriteriaNrMrs"`

	FilterCriteriaAssoc *CaReconfSubscriptionFilterCriteriaAssoc `json:"filterCriteriaAssoc"`

	S1BearerSubscriptionCriteria *S1BearerSubscriptionS1BearerSubscriptionCriteria `json:"S1BearerSubscriptionCriteria"`
	// Description of the subscribed event. The event is included both in the request and in the response. \\nFor the eventType, the following values are currently defined: 0 = RESERVED. 1 = S1_BEARER_ESTABLISH. 2 = S1_BEARER_MODIFY. 3 = S1_BEARER_RELEASE.
	EventType []string `json:"eventType"`

	FilterCriteriaAssocHo *CellChangeSubscriptionFilterCriteriaAssocHo `json:"filterCriteriaAssocHo"`
}
+96 −26
Original line number Diff line number Diff line
@@ -376,11 +376,11 @@ func checkForExpiredSubscriptions() {
				var expiryTimeStamp clientNotif.TimeStamp
				expiryTimeStamp.Seconds = int32(expiryTime)

				link := new(clientNotif.Link)
				link := new(clientNotif.ExpiryNotificationLinks)
				link.Self = cbRef
				notif.Links = link

				notif.Timestamp = &timeStamp
				notif.TimeStamp = &timeStamp
				notif.ExpiryDeadline = &expiryTimeStamp

				sendExpiryNotification(link.Self, context.TODO(), subsIdStr, notif)
@@ -506,6 +506,16 @@ func isMatchRabFilterCriteriaAppInsId(filterCriteria interface{}, appId string)
	return (appId == filter.AppInstanceId)
}

func isMatchRabRelFilterCriteriaAppInsId(filterCriteria interface{}, appId string) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	//if filter criteria is not set, it acts as a wildcard and accepts all
	if filter.AppInstanceId == "" {
		return true
	}
	return (appId == filter.AppInstanceId)
}

func isMatchCcFilterCriteriaAssociateId(filterCriteria interface{}, assocId *AssociateId) bool {
	filter := filterCriteria.(*CellChangeSubscriptionFilterCriteriaAssocHo)

@@ -594,6 +604,32 @@ func isMatchRabFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, old
	return false
}

func isMatchRabRelFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	//if filter criteria is not set, it acts as a wildcard and accepts all
	if filter.Ecgi == nil {
		return true
	}

	//either of the Plmn should match the filter,
	for _, ecgi := range filter.Ecgi {

		if newPlmn != nil {
			if newPlmn.Mnc == ecgi.Plmn.Mnc && newPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
			}
		}
		if oldPlmn != nil {
			if oldPlmn.Mnc == ecgi.Plmn.Mnc && oldPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
			}
		}
	}

	return false
}

func isMatchCcFilterCriteriaCellId(filterCriteria interface{}, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*CellChangeSubscriptionFilterCriteriaAssocHo)

@@ -635,12 +671,34 @@ func isMatchRabFilterCriteriaCellId(filterCriteria interface{}, newCellId string
	return false
}

func isMatchRabRelFilterCriteriaCellId(filterCriteria interface{}, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	if filter.Ecgi == nil {
		return true
	}

	//either the old of new cellId should match one of the cellId in the filter list
	for _, ecgi := range filter.Ecgi {
		if newCellId == ecgi.CellId {
			return true
		}
		if oldCellId == ecgi.CellId {
			return true
		}
	}

	return false
}

func isMatchFilterCriteriaAppInsId(subscriptionType string, filterCriteria interface{}, appId string) bool {
	switch subscriptionType {
	case cellChangeSubscriptionType:
		return isMatchCcFilterCriteriaAppInsId(filterCriteria, appId)
	case rabEstSubscriptionType, rabRelSubscriptionType:
	case rabEstSubscriptionType:
		return isMatchRabFilterCriteriaAppInsId(filterCriteria, appId)
	case rabRelSubscriptionType:
		return isMatchRabRelFilterCriteriaAppInsId(filterCriteria, appId)
	}
	return true
}
@@ -659,8 +717,10 @@ func isMatchFilterCriteriaPlmn(subscriptionType string, filterCriteria interface
	switch subscriptionType {
	case cellChangeSubscriptionType:
		return isMatchCcFilterCriteriaPlmn(filterCriteria, newPlmn, oldPlmn)
	case rabEstSubscriptionType, rabRelSubscriptionType:
	case rabEstSubscriptionType:
		return isMatchRabFilterCriteriaPlmn(filterCriteria, newPlmn, oldPlmn)
	case rabRelSubscriptionType:
		return isMatchRabRelFilterCriteriaPlmn(filterCriteria, newPlmn, oldPlmn)
	}
	return true
}
@@ -669,8 +729,10 @@ func isMatchFilterCriteriaCellId(subscriptionType string, filterCriteria interfa
	switch subscriptionType {
	case cellChangeSubscriptionType:
		return isMatchCcFilterCriteriaCellId(filterCriteria, newCellId, oldCellId)
	case rabEstSubscriptionType, rabRelSubscriptionType:
	case rabEstSubscriptionType:
		return isMatchRabFilterCriteriaCellId(filterCriteria, newCellId, oldCellId)
	case rabRelSubscriptionType:
		return isMatchRabRelFilterCriteriaCellId(filterCriteria, newCellId, oldCellId)
	}
	return true
}
@@ -727,7 +789,7 @@ func checkCcNotificationRegisteredSubscriptions(appId string, assocId *Associate
					notifNewPlmn.Mcc = ""
				}
				newEcgi.Plmn = &notifNewPlmn
				newEcgi.CellId = []string{newCellId}
				newEcgi.CellId = newCellId
				var oldEcgi clientNotif.Ecgi
				var notifOldPlmn clientNotif.Plmn
				if oldPlmn != nil {
@@ -738,7 +800,7 @@ func checkCcNotificationRegisteredSubscriptions(appId string, assocId *Associate
					notifOldPlmn.Mcc = ""
				}
				oldEcgi.Plmn = &notifOldPlmn
				oldEcgi.CellId = []string{oldCellId}
				oldEcgi.CellId = oldCellId

				var notifAssociateId clientNotif.AssociateId
				notifAssociateId.Type_ = assocId.Type_
@@ -748,12 +810,11 @@ func checkCcNotificationRegisteredSubscriptions(appId string, assocId *Associate
				var timeStamp clientNotif.TimeStamp
				timeStamp.Seconds = int32(seconds)

				notif.Timestamp = &timeStamp
				notifHoStatus := clientNotif.COMPLETED_HoStatus
				notif.HoStatus = &notifHoStatus
				notif.TimeStamp = &timeStamp
				notif.HoStatus = "3" //only supporting 3 = COMPLETED
				notif.SrcEcgi = &oldEcgi
				notif.TrgEcgi = []clientNotif.Ecgi{newEcgi}
				notif.AssociateId = &notifAssociateId
				notif.AssociateId = append(notif.AssociateId, notifAssociateId)

				sendCcNotification(subscription.CallbackReference, context.TODO(), subsIdStr, notif)
				log.Info("Cell_change Notification" + "(" + subsIdStr + ")")
@@ -812,9 +873,9 @@ func checkReNotificationRegisteredSubscriptions(appId string, assocId *Associate
				notifNewPlmn.Mnc = newPlmn.Mnc
				notifNewPlmn.Mcc = newPlmn.Mcc
				newEcgi.Plmn = &notifNewPlmn
				newEcgi.CellId = []string{newCellId}
				newEcgi.CellId = newCellId

				var erabQos clientNotif.ErabQosParameters
				var erabQos clientNotif.RabEstNotificationErabQosParameters
				erabQos.Qci = defaultSupportedQci

				var notifAssociateId clientNotif.AssociateId
@@ -825,11 +886,11 @@ func checkReNotificationRegisteredSubscriptions(appId string, assocId *Associate
				var timeStamp clientNotif.TimeStamp
				timeStamp.Seconds = int32(seconds)

				notif.Timestamp = &timeStamp
				notif.TimeStamp = &timeStamp
				notif.ErabId = erabId
				notif.Ecgi = &newEcgi
				notif.ErabQosParameters = &erabQos
				notif.AssociateId = &notifAssociateId
				notif.AssociateId = append(notif.AssociateId, notifAssociateId)

				sendReNotification(subscription.CallbackReference, context.TODO(), subsIdStr, notif)
				log.Info("Rab_establishment Notification" + "(" + subsIdStr + ")")
@@ -888,7 +949,7 @@ func checkRrNotificationRegisteredSubscriptions(appId string, assocId *Associate
				notifOldPlmn.Mnc = oldPlmn.Mnc
				notifOldPlmn.Mcc = oldPlmn.Mcc
				oldEcgi.Plmn = &notifOldPlmn
				oldEcgi.CellId = []string{oldCellId}
				oldEcgi.CellId = oldCellId

				var notifAssociateId clientNotif.AssociateId
				notifAssociateId.Type_ = assocId.Type_
@@ -898,12 +959,12 @@ func checkRrNotificationRegisteredSubscriptions(appId string, assocId *Associate
				var timeStamp clientNotif.TimeStamp
				timeStamp.Seconds = int32(seconds)

				var erabRelInfo clientNotif.ErabReleaseInfo
				var erabRelInfo clientNotif.RabRelNotificationErabReleaseInfo
				erabRelInfo.ErabId = erabId
				notif.Timestamp = &timeStamp
				notif.TimeStamp = &timeStamp
				notif.Ecgi = &oldEcgi
				notif.ErabReleaseInfo = &erabRelInfo
				notif.AssociateId = &notifAssociateId
				notif.AssociateId = append(notif.AssociateId, notifAssociateId)

				sendRrNotification(subscription.CallbackReference, context.TODO(), subsIdStr, notif)
				log.Info("Rab_release Notification" + "(" + subsIdStr + ")")
@@ -922,12 +983,15 @@ func sendCcNotification(notifyUrl string, ctx context.Context, subscriptionId st
		return
	}

	jsonNotif, err := json.Marshal(notification)
	var body clientNotif.Body1
	body.Notification = &notification

	jsonNotif, err := json.Marshal(body)
	if err != nil {
		log.Error(err.Error())
	}

	resp, err := client.NotificationsApi.PostCellChangeNotification(ctx, subscriptionId, notification)
	resp, err := client.NotificationsApi.PostCellChangeNotification(ctx, body, subscriptionId)
	_ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime)
	if err != nil {
		log.Error(err)
@@ -946,12 +1010,15 @@ func sendReNotification(notifyUrl string, ctx context.Context, subscriptionId st
		return
	}

	jsonNotif, err := json.Marshal(notification)
	var body clientNotif.Body4
	body.Notification = &notification

	jsonNotif, err := json.Marshal(body)
	if err != nil {
		log.Error(err.Error())
	}

	resp, err := client.NotificationsApi.PostRabEstNotification(ctx, subscriptionId, notification)
	resp, err := client.NotificationsApi.PostRabEstNotification(ctx, body, subscriptionId)
	_ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime)
	if err != nil {
		log.Error(err)
@@ -970,12 +1037,15 @@ func sendRrNotification(notifyUrl string, ctx context.Context, subscriptionId st
		return
	}

	jsonNotif, err := json.Marshal(notification)
	var body clientNotif.Body6
	body.Notification = &notification

	jsonNotif, err := json.Marshal(body)
	if err != nil {
		log.Error(err.Error())
	}

	resp, err := client.NotificationsApi.PostRabRelNotification(ctx, subscriptionId, notification)
	resp, err := client.NotificationsApi.PostRabRelNotification(ctx, body, subscriptionId)
	_ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime)
	if err != nil {
		log.Error(err)
@@ -999,7 +1069,7 @@ func sendExpiryNotification(notifyUrl string, ctx context.Context, subscriptionI
		log.Error(err.Error())
	}

	resp, err := client.NotificationsApi.PostExpiryNotification(ctx, subscriptionId, notification)
	resp, err := client.NotificationsApi.PostExpiryNotification(ctx, notification, subscriptionId)
	_ = httpLog.LogTx(notifyUrl, "POST", string(jsonNotif), resp, startTime)
	if err != nil {
		log.Error(err)
+49 −41
Original line number Diff line number Diff line
@@ -29,16 +29,14 @@ import (
	"time"

	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
	ms "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metric-store"
	mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model"
	mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq"
	rnisNotif "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-rnis-notification-client"

	"github.com/gorilla/mux"
)

//	to be added in import above when notifications are in. Removed to get rid of goimports error
//      ms "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metric-store"
//      rnisNotif "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-rnis-notification-client"

const INITIAL = 0
const UPDATED = 1

@@ -776,7 +774,7 @@ func testSubscriptionCellChangePost(t *testing.T) string {
	expectedFilter := CellChangeSubscriptionFilterCriteriaAssocHo{"myApp", expectedAssocId, expectedEcgi, []string{"3"}}
	expectedCallBackRef := "myCallbakRef"
	expectedLinkType := LinkType{"/" + testScenarioName + "/rni/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)}
	//expectedExpiry := TimeStamp{1998599770, 0}
	//expectedExpiry := TimeStamp{0, 1998599770}
	expectedResponse := InlineResponse201{&OneOfinlineResponse201NotificationSubscription{&CaReconfSubscriptionLinks{&expectedLinkType}, expectedCallBackRef, nil, CELL_CHANGE_SUBSCRIPTION, nil, &expectedFilter, nil, nil, nil, nil, nil}}

	expectedResponseStr, err := json.Marshal(expectedResponse)
@@ -838,7 +836,7 @@ func testSubscriptionCellChangePut(t *testing.T, subscriptionId string, expectSu
	expectedFilter := CellChangeSubscriptionFilterCriteriaAssocHo{"myApp", expectedAssocId, expectedEcgi, []string{"3"}}
	expectedCallBackRef := "myCallbakRef"
	expectedLinkType := LinkType{"/" + testScenarioName + "/rni/v2/subscriptions/" + subscriptionId}
	//expectedExpiry := TimeStamp{1998599770, 0}
	//expectedExpiry := TimeStamp{0, 1998599770}
	expectedResponse := InlineResponse2006{&OneOfinlineResponse2006NotificationSubscription{OneOfinlineResponse201NotificationSubscription{&CaReconfSubscriptionLinks{&expectedLinkType}, expectedCallBackRef, nil, CELL_CHANGE_SUBSCRIPTION, nil, &expectedFilter, nil, nil, nil, nil, nil}}}

	expectedResponseStr, err := json.Marshal(expectedResponse)
@@ -988,7 +986,7 @@ func testSubscriptionRabEstPost(t *testing.T) string {
	expectedFilter := RabModSubscriptionFilterCriteriaQci{"myApp", expectedEcgi, 0, 80}
	expectedCallBackRef := "myCallbakRef"
	expectedLinkType := LinkType{"/" + testScenarioName + "/rni/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)}
	//expectedExpiry := TimeStamp{1998599770, 0}
	//expectedExpiry := TimeStamp{0, 1998599770}
	expectedResponse := InlineResponse201{&OneOfinlineResponse201NotificationSubscription{&CaReconfSubscriptionLinks{&expectedLinkType}, expectedCallBackRef, nil, RAB_EST_SUBSCRIPTION, nil, nil, nil, nil, &expectedFilter, nil, nil}}

	expectedResponseStr, err := json.Marshal(expectedResponse)
@@ -1046,7 +1044,7 @@ func testSubscriptionRabEstPut(t *testing.T, subscriptionId string, expectSucces
	expectedFilter := RabModSubscriptionFilterCriteriaQci{"myApp", expectedEcgi, 0, 88}
	expectedCallBackRef := "myCallbakRef"
	expectedLinkType := LinkType{"/" + testScenarioName + "/rni/v2/subscriptions/" + subscriptionId}
	//expectedExpiry := TimeStamp{1998599770, 0}
	//expectedExpiry := TimeStamp{0, 1998599770}
	expectedResponse := InlineResponse2006{&OneOfinlineResponse2006NotificationSubscription{OneOfinlineResponse201NotificationSubscription{&CaReconfSubscriptionLinks{&expectedLinkType}, expectedCallBackRef, nil, RAB_EST_SUBSCRIPTION, nil, nil, nil, nil, &expectedFilter, nil, nil}}}

	expectedResponseStr, err := json.Marshal(expectedResponse)
@@ -1113,7 +1111,7 @@ func testSubscriptionRabRelPost(t *testing.T) string {
	expectedFilter := RabModSubscriptionFilterCriteriaQci{"myApp", expectedEcgi, 1, 80}
	expectedCallBackRef := "myCallbakRef"
	expectedLinkType := LinkType{"/" + testScenarioName + "/rni/v2/subscriptions/" + strconv.Itoa(nextSubscriptionIdAvailable)}
	//	expectedExpiry := TimeStamp{1988599770, 0}
	//expectedExpiry := TimeStamp{0, 1988599770}
	expectedResponse := InlineResponse201{&OneOfinlineResponse201NotificationSubscription{&CaReconfSubscriptionLinks{&expectedLinkType}, expectedCallBackRef, nil, RAB_REL_SUBSCRIPTION, nil, nil, nil, nil, &expectedFilter, nil, nil}}

	expectedResponseStr, err := json.Marshal(expectedResponse)
@@ -1258,19 +1256,20 @@ func TestSubscriptionCellChangeNotification(t *testing.T) {
        expectedSrcEcgiInSub := Ecgi{Plmn: &expectedSrcPlmn, CellId: expectedSrcCellId}
        expectedEcgi := []Ecgi{expectedSrcEcgiInSub}
	expectedDstPlmnInNotif := rnisNotif.Plmn{Mcc: "123", Mnc: "456"}
	expectedDstCellId := []string{"3456789"}
	expectedDstCellId := "3456789"
	expectedDstEcgi := rnisNotif.Ecgi{Plmn: &expectedDstPlmnInNotif, CellId: expectedDstCellId}
	movingUeAddr := "ue1" //based on the scenario change
	expectedAssocId1 := AssociateId{"1", movingUeAddr}
        expectedAssocId := []AssociateId{expectedAssocId1}
        expectedEcgi1 := Ecgi{"1234567", &Plmn{"123", "456"}}
        expectedEcgi := []Ecgi{expectedEcgi1}
        //expectedEcgi1 := Ecgi{"1234567", &Plmn{"123", "456"}}
        //expectedEcgi := []Ecgi{expectedEcgi1}

	expectedAssocIdInNotif := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedAssocIdInNotif1 := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedAssocIdInNotif := []rnisNotif.AssociateId{expectedAssocIdInNotif1}
	expectedFilter := CellChangeSubscriptionFilterCriteriaAssocHo{"", expectedAssocId, expectedEcgi, []string{"3"}}
//FilterCriteriaAssocHo{"", &expectedAssocId, &expectedSrcPlmn, expectedSrcCellId, &hostatus}
	expectedCallBackRef := "myCallbakRef"
	//expectedExpiry := TimeStamp{1988599770, 0}
	//expectedExpiry := TimeStamp{0, 1988599770}

	//******************************
	// * request vars section
@@ -1318,11 +1317,18 @@ func TestSubscriptionCellChangeNotification(t *testing.T) {
		t.Fatalf("Failed to get metric")
	}

	var notification rnisNotif.CellChangeNotification
	err = json.Unmarshal([]byte(httpLog[0].Body), &notification)
	var notificationBody rnisNotif.Body1
	err = json.Unmarshal([]byte(httpLog[0].Body), &notificationBody)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}
	notification := notificationBody.Notification

        jsonResultAll, err := json.Marshal(notification)
        if err != nil {
                t.Fatalf(err.Error())
        }
	log.Info("SIMON ", string(jsonResultAll))

	//transform the src and target ecgi in string for comparison purpose
	jsonResult, err := json.Marshal(notification.SrcEcgi)
@@ -1395,7 +1401,7 @@ func TestSubscriptionCellChangeNotification(t *testing.T) {
	updateScenario("mobility1")

	//cleanup allocated subscription
	testSubscriptionCellChangeDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1))
	testSubscriptionDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1), true)

	//******************************
	// * back to initial state section
@@ -1403,7 +1409,7 @@ func TestSubscriptionCellChangeNotification(t *testing.T) {
	terminateScenario()

}

*/
func TestSubscriptionRabEstNotification(t *testing.T) {

	fmt.Println("--- ", t.Name())
@@ -1428,16 +1434,16 @@ func TestSubscriptionRabEstNotification(t *testing.T) {
	// ****************************** /
	qci := int32(80)
	expectedPlmnInNotif := rnisNotif.Plmn{Mcc: "123", Mnc: "456"}
	expectedCellId := []string{"2345678"}
	expectedCellId := "2345678"
	expectedEcgi := rnisNotif.Ecgi{Plmn: &expectedPlmnInNotif, CellId: expectedCellId}
	expectedErabId := 2
	expectedErabQosParameters := rnisNotif.ErabQosParameters{Qci: qci}
	expectedErabQosParameters := rnisNotif.RabEstNotificationErabQosParameters{Qci: qci}
	movingUeAddr := "ue1" //based on the scenario change
	expectedAssocId := AssociateId{"1", movingUeAddr}
	expectedAssocIdInNotif := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedFilter := FilterCriteriaAssocQci{"", &expectedAssocId, nil, nil, qci}
	expectedAssocIdInNotif1 := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedAssocIdInNotif := []rnisNotif.AssociateId{expectedAssocIdInNotif1}
	expectedFilter := RabModSubscriptionFilterCriteriaQci{Qci: qci} //"", nil, 0, qci}
	expectedCallBackRef := "myCallbakRef"
	expectedExpiry := TimeStamp{1988599770, 0}
	//expectedExpiry := TimeStamp{0, 1988599770}

	//******************************
	// * request vars section
@@ -1447,7 +1453,7 @@ func TestSubscriptionRabEstNotification(t *testing.T) {
	// * request body section
	// ****************************** /

	rabEstSubscriptionPost1 := RabEstSubscriptionPost1{&RabEstSubscriptionPost{expectedCallBackRef, &expectedFilter, &expectedExpiry}}
	rabEstSubscriptionPost1 := Body{&OneOfbodyNotificationSubscription{nil, expectedCallBackRef, nil, RAB_EST_SUBSCRIPTION, nil, nil, nil, nil, &expectedFilter, nil, nil}}

	body, err := json.Marshal(rabEstSubscriptionPost1)
	if err != nil {
@@ -1462,7 +1468,7 @@ func TestSubscriptionRabEstNotification(t *testing.T) {
	// * request execution section
	// ****************************** /

	_, err = sendRequest(http.MethodPost, "/subscriptions/rab_est", bytes.NewBuffer(body), nil, nil, http.StatusCreated, RabEstSubscriptionSubscriptionsPOST)
	_, err = sendRequest(http.MethodPost, "/subscriptions", bytes.NewBuffer(body), nil, nil, http.StatusCreated, SubscriptionsPOST)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}
@@ -1481,11 +1487,12 @@ func TestSubscriptionRabEstNotification(t *testing.T) {
		t.Fatalf("Failed to get metric")
	}

	var notification rnisNotif.RabEstNotification
	err = json.Unmarshal([]byte(httpLog[0].Body), &notification)
	var notificationBody rnisNotif.Body4
	err = json.Unmarshal([]byte(httpLog[0].Body), &notificationBody)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}
	notification := notificationBody.Notification

	//transform the assocId in string for comparison purpose
	jsonResult, err := json.Marshal(notification.AssociateId)
@@ -1534,7 +1541,7 @@ func TestSubscriptionRabEstNotification(t *testing.T) {
	}

	//cleanup allocated subscription
	testSubscriptionRabEstDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1))
	testSubscriptionDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1), true)

	//******************************
	// * back to initial state section
@@ -1567,15 +1574,15 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
	// ****************************** /
	qci := int32(80)
	expectedPlmnInNotif := rnisNotif.Plmn{Mcc: "123", Mnc: "456"}
	expectedCellId := []string{"2345678"}
	expectedCellId := "2345678"
	expectedEcgi := rnisNotif.Ecgi{Plmn: &expectedPlmnInNotif, CellId: expectedCellId}
	expectedErabReleaseInfo := rnisNotif.ErabReleaseInfo{ErabId: 1}
	expectedErabReleaseInfo := rnisNotif.RabRelNotificationErabReleaseInfo{ErabId: 1}
	movingUeAddr := "ue1" //based on the scenario change
	expectedAssocId := AssociateId{"1", movingUeAddr}
	expectedAssocIdInNotif := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedFilter := FilterCriteriaAssocQci{"", &expectedAssocId, nil, nil, qci}
	expectedAssocIdInNotif1 := rnisNotif.AssociateId{Type_: "1", Value: movingUeAddr}
	expectedAssocIdInNotif := []rnisNotif.AssociateId{expectedAssocIdInNotif1}
	expectedFilter := RabModSubscriptionFilterCriteriaQci{"", nil, 1, qci}
	expectedCallBackRef := "myCallbakRef"
	expectedExpiry := TimeStamp{1988599770, 0}
	//expectedExpiry := TimeStamp{0, 1988599770}

	//******************************
	// * request vars section
@@ -1585,7 +1592,7 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
	// * request body section
	// ****************************** /

	rabRelSubscriptionPost1 := RabRelSubscriptionPost1{&RabRelSubscriptionPost{expectedCallBackRef, &expectedFilter, &expectedExpiry}}
	rabRelSubscriptionPost1 := Body{&OneOfbodyNotificationSubscription{nil, expectedCallBackRef, nil, RAB_REL_SUBSCRIPTION, nil, nil, nil, nil, &expectedFilter, nil, nil}}

	body, err := json.Marshal(rabRelSubscriptionPost1)
	if err != nil {
@@ -1600,7 +1607,7 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
	// * request execution section
	// ****************************** /

	_, err = sendRequest(http.MethodPost, "/subscriptions/rab_rel", bytes.NewBuffer(body), nil, nil, http.StatusCreated, RabRelSubscriptionSubscriptionsPOST)
	_, err = sendRequest(http.MethodPost, "/subscriptions", bytes.NewBuffer(body), nil, nil, http.StatusCreated, SubscriptionsPOST)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}
@@ -1617,11 +1624,12 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
		t.Fatalf("Failed to get metric")
	}

	var notification rnisNotif.RabRelNotification
	err = json.Unmarshal([]byte(httpLog[0].Body), &notification)
	var notificationBody rnisNotif.Body6
	err = json.Unmarshal([]byte(httpLog[0].Body), &notificationBody)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}
	notification := notificationBody.Notification

	//transform the assocId in string for comparison purpose
	jsonResult, err := json.Marshal(notification.AssociateId)
@@ -1670,7 +1678,7 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
	}

	//cleanup allocated subscription
	testSubscriptionRabEstDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1))
	testSubscriptionDelete(t, strconv.Itoa(nextSubscriptionIdAvailable-1), true)

	//******************************
	// * back to initial state section
@@ -1678,7 +1686,7 @@ func TestSubscriptionRabRelNotification(t *testing.T) {
	terminateScenario()

}
*/

func TestSbi(t *testing.T) {

	fmt.Println("--- ", t.Name())
Loading